diff --git a/.github/workflows/test-core.yaml b/.github/workflows/test-core.yaml index 6598b61..d377a15 100644 --- a/.github/workflows/test-core.yaml +++ b/.github/workflows/test-core.yaml @@ -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 }} diff --git a/core/requirements.txt b/core/requirements.txt index 6a492ba..4be8cfc 100644 --- a/core/requirements.txt +++ b/core/requirements.txt @@ -2,4 +2,6 @@ ortools==9.10.4067 pandas ruamel.yaml munch +# For CI pytest +pytest-cov diff --git a/core/tests/test_all.py b/core/tests/test_all.py index 924aed3..ea4f6c8 100644 --- a/core/tests/test_all.py +++ b/core/tests/test_all.py @@ -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: