From a7aec6d29368a4f0014df60e497cbf2293e50a1e Mon Sep 17 00:00:00 2001 From: Santhosh <52504160+santacodes@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:33:59 +0530 Subject: [PATCH] Added CodeCov workflow (#19) + Set up codecov workflow as discussed in today's meet + Added a `codecov.yml` config file --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/codecov.yml | 10 ++++++++++ .github/workflows/test_on_push.yml | 11 +++++++++++ noxfile.py | 8 ++++++++ 3 files changed, 29 insertions(+) create mode 100644 .github/codecov.yml 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"""