mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 08:06:27 +00:00
fix: update to use local app/ dir (#1872)
* fix: update to use local app/ dir * fix: update if statement on macos xlarge
This commit is contained in:
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@@ -16,9 +16,9 @@ jobs:
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Install dependencies
|
||||
run: pip install -r src/scripts/app/requirements.txt
|
||||
run: pip install -r app/requirements.txt
|
||||
- name: Run tests and collect coverage
|
||||
run: pytest src/scripts/app/ --cov
|
||||
run: pytest app/ --cov
|
||||
|
||||
- name: Upload coverage to Codecov (script)
|
||||
uses: ./
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
run-macos-latest-xlarge:
|
||||
if: github.head.repo.full_name == 'codecov/codecov-action'
|
||||
if: github.event.pull_request.head.repo.full_name == 'codecov/codecov-action'
|
||||
runs-on: macos-latest-xlarge
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -58,9 +58,9 @@ jobs:
|
||||
with:
|
||||
submodules: "true"
|
||||
- name: Install dependencies
|
||||
run: pip install -r src/scripts/app/requirements.txt
|
||||
run: pip install -r app/requirements.txt
|
||||
- name: Run tests and collect coverage
|
||||
run: pytest src/scripts/app/ --cov
|
||||
run: pytest app/ --cov
|
||||
- name: Upload coverage to Codecov (script)
|
||||
uses: ./
|
||||
with:
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -93,3 +93,6 @@ public/
|
||||
|
||||
# macOS Finder metadata
|
||||
.DS_Store
|
||||
|
||||
# pycache dirs
|
||||
__pycache__/
|
||||
|
||||
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
15
app/calculator.py
Normal file
15
app/calculator.py
Normal file
@@ -0,0 +1,15 @@
|
||||
class Calculator:
|
||||
|
||||
def add(x, y):
|
||||
return x + y
|
||||
|
||||
def subtract(x, y):
|
||||
return x - y
|
||||
|
||||
def multiply(x, y):
|
||||
return x * y
|
||||
|
||||
def divide(x, y):
|
||||
if y == 0:
|
||||
return 'Cannot divide by 0'
|
||||
return x * 1.0 / y
|
||||
1
app/requirements.txt
Normal file
1
app/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
pytest-cov
|
||||
31
app/test_calculator.py
Normal file
31
app/test_calculator.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from .calculator import Calculator
|
||||
|
||||
|
||||
def test_add():
|
||||
assert Calculator.add(1, 2) == 3.0
|
||||
assert Calculator.add(1.0, 2.0) == 3.0
|
||||
assert Calculator.add(0, 2.0) == 2.0
|
||||
assert Calculator.add(2.0, 0) == 2.0
|
||||
assert Calculator.add(-4, 2.0) == -2.0
|
||||
|
||||
def test_subtract():
|
||||
assert Calculator.subtract(1, 2) == -1.0
|
||||
assert Calculator.subtract(2, 1) == 1.0
|
||||
assert Calculator.subtract(1.0, 2.0) == -1.0
|
||||
assert Calculator.subtract(0, 2.0) == -2.0
|
||||
assert Calculator.subtract(2.0, 0.0) == 2.0
|
||||
assert Calculator.subtract(-4, 2.0) == -6.0
|
||||
|
||||
def test_multiply():
|
||||
assert Calculator.multiply(1, 2) == 2.0
|
||||
assert Calculator.multiply(1.0, 2.0) == 2.0
|
||||
assert Calculator.multiply(0, 2.0) == 0.0
|
||||
assert Calculator.multiply(2.0, 0.0) == 0.0
|
||||
assert Calculator.multiply(-4, 2.0) == -8.0
|
||||
|
||||
def test_divide():
|
||||
# assert Calculator.divide(1, 2) == 0.5
|
||||
assert Calculator.divide(1.0, 2.0) == 0.5
|
||||
assert Calculator.divide(0, 2.0) == 0
|
||||
assert Calculator.divide(-4, 2.0) == -2.0
|
||||
# assert Calculator.divide(2.0, 0.0) == 'Cannot divide by 0'
|
||||
Reference in New Issue
Block a user