Back to development: 2.4.1-dev #778
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Based on | |
| # python-package.yml | |
| # and | |
| # https://medium.com/@wkrzywiec/how-to-write-good-quality-python-code-with-github-actions-2f635a2ab09a | |
| name: Coverage | |
| on: | |
| push: | |
| branches: [ master ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| codecov: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.12"] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install tools in CI virtualenv | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pdm | |
| - name: Create in-project virtualenv and install dependencies | |
| run: | | |
| # Point PDM at the interpreter `setup-python` already installed, rather than | |
| # letting it fetch a second one — its index has no prerelease build, so asking | |
| # for a version like "3.15" fails while that very interpreter is on PATH. | |
| # Ask Python for its own path: under Git Bash on Windows, `which python` gives | |
| # an MSYS path that PDM, a native Windows program, cannot resolve. | |
| pdm use -f "$(python -c 'import sys; print(sys.executable)')" | |
| # "When you run pdm install the first time on a new PDM-managed project, whose Python interpreter is not decided yet, | |
| # PDM will create a virtualenv in <project_root>/.venv, and install dependencies into it." | |
| # https://pdm-project.org/en/latest/usage/venv/ | |
| pdm install | |
| - name: Install coverage tool in in-project virtualenv | |
| run: | | |
| pdm run python -m ensurepip | |
| # coverage must run in the same venv as the code being tested. | |
| pdm run python -m pip install coverage | |
| - name: Generate coverage report | |
| run: | | |
| pdm run python -m coverage run -m runtests | |
| pdm run python -m coverage xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml | |
| flags: unittests |