Skip to content

Commit

Permalink
ci(coverage): Add code coverage; Fix test path
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Aug 10, 2024
1 parent 02e6649 commit cf84086
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ jobs:
run: cd core && python -m pip install -r requirements.txt
- name: Test with pytest
run: cd core && pytest --log-cli-level=INFO
# TODO: Only prepare code coverage data if on the master branch
- name: Prepare code coverage data
run: pytest --cov core
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions core/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ ortools==9.10.4067
pandas
ruamel.yaml
munch
# For CI
pytest
pytest-cov
8 changes: 5 additions & 3 deletions core/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import pytest


current_dir = os.path.dirname(os.path.realpath(__file__))

def test_all():
for filepath in glob.glob("tests/testcases/*.yaml"):
base_filepath = os.path.splitext(filepath)[0]
for filepath in glob.glob(f"{current_dir}/testcases/*.yaml"):
base_filepath = os.path.splitext(os.path.basename(filepath))[0]
logging.info(f"Testing '{base_filepath}' ...")
df = nurse_scheduling.schedule(filepath, validate=False, deterministic=True)
with open(f"{base_filepath}.csv", 'r') as f:
with open(f"{current_dir}/testcases/{base_filepath}.csv", 'r') as f:
expected_csv = f.read()
actual_csv = df.to_csv(index=False, header=False)
if actual_csv != expected_csv:
Expand Down

0 comments on commit cf84086

Please sign in to comment.