diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..34d56ca --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,10 @@ +codecov: + token: ${{ secrets.CODECOV_TOKEN }} + ci: + - "test_on_push" + strict_yaml_branch: "main" + disable_default_path_fixes: no + require_ci_to_pass: yes + +github_checks: + annotations: true diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 76d8ec1..c68e04d 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -6,6 +6,7 @@ on: push: branches: - main + jobs: style: runs-on: ubuntu-latest @@ -52,3 +53,13 @@ jobs: - name: Test Template Generation run: | nox -s test-generation + + - name: Run coverage tests + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + run: python -m nox -s coverage + + - name: Upload coverage report + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + uses: codecov/codecov-action@v4.5.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/noxfile.py b/noxfile.py index f4cb85c..228223b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -31,6 +31,14 @@ def run_template_generation(session): session.install("-e", ".[dev]", silent=False) session.run("pytest", "tests") +@nox.session(name="coverage") +def run_coverage(session): + """Run the coverage tests and generate an XML report.""" + session.install("setuptools", silent=False) + session.install("coverage", silent=False) + session.install("-e", ".[all,dev,jax]", silent=False) + session.run("pytest", "--cov=src/pybamm_cookiecutter", "--cov-report=xml", "tests/") + @nox.session(name="dev") def set_dev(session): """Install pybamm-cookiecutter in editable mode"""