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:
Tom Hu
2025-09-04 16:18:57 +02:00
committed by GitHub
parent 206148c4b8
commit 18fdacf0ce
6 changed files with 55 additions and 5 deletions

View File

@@ -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
View File

@@ -93,3 +93,6 @@ public/
# macOS Finder metadata
.DS_Store
# pycache dirs
__pycache__/

0
app/__init__.py Normal file
View File

15
app/calculator.py Normal file
View 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
View File

@@ -0,0 +1 @@
pytest-cov

31
app/test_calculator.py Normal file
View 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'