diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 713583b..341a579 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,19 +28,19 @@ jobs: python: '3.9' nox_session: tests-3.9 - - name: Tests, Python 3.11, macOS + - name: Tests, Python 3.11, with code coverage, macOS os: macos-latest python: '3.11' - nox_session: tests-3.11 + nox_session: tests-3.11(cov) - name: Tests, Python 3.10, macOS os: macos-latest python: '3.9' nox_session: tests-3.9 - - name: Documentation, Python 3.12, Ubuntu + - name: Documentation, Python 3.11, Ubuntu os: ubuntu-latest - python: '3.12' + python: '3.11' nox_session: docs steps: @@ -67,10 +67,12 @@ jobs: run: python -m pip install --progress-bar off --upgrade nox - name: Run tests - run: nox -s ${{ matrix.nox_session }} + run: nox -s '${{ matrix.nox_session }}' - name: Upload coverage to codecov if: ${{ contains(matrix.nox_session,'cov') }} - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: file: ./coverage.xml + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..930d53f --- /dev/null +++ b/codecov.yml @@ -0,0 +1,16 @@ +codecov: + notify: + wait_for_ci: false + require_ci_to_pass: false +# coverage: +# range: 90..98 +# status: +# project: +# default: +# # Temporarily allow a greater project coverage threshold; see #2757 +# threshold: 0.9% +# removed_code_behavior: adjust_base +# patch: +# default: +# threshold: 0.5% +# removed_code_behavior: adjust_base diff --git a/mamba_environment.yml b/mamba_environment.yml index 901e5ce..06489b1 100644 --- a/mamba_environment.yml +++ b/mamba_environment.yml @@ -6,7 +6,7 @@ channels: dependencies: - python - jupyter - - numpy + - numpy < 2 - scipy - matplotlib - mdsplus @@ -16,5 +16,6 @@ dependencies: - sphinx - pip - pip: - - pytest - nox + - pytest + - pytest-cov diff --git a/noxfile.py b/noxfile.py index 0c6aafc..8668288 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,13 +23,42 @@ def install_environment(session, environment_path="mamba_environment.yml"): ], silent=False, ) + session.run( + *[ + session.venv_backend, + "list", + "--prefix", + session.virtualenv.location, + ] + ) + + +test_specifiers: list = [ + nox.param("run all tests", id="all"), + nox.param("with code coverage", id="cov"), +] + +with_coverage: tuple[str, ...] = ( + "--cov=wipplpy", + "--cov-report=xml", + "--cov-config=pyproject.toml", + "--cov-append", + "--cov-report", + "xml:coverage.xml", +) @nox.session(python=supported_python_versions) -def tests(session): +@nox.parametrize("test_specifier", test_specifiers) +def tests(session, test_specifier): """Run tests with pytest.""" install_environment(session) - session.run("pytest") + + options = [] + if test_specifier == "with code coverage": + options += with_coverage + + session.run("pytest", *options) @nox.session(python=maxpython)