fix coverage data file naming #11
This file contains 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
name: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
# See: https://hynek.me/articles/ditch-codecov-python/ | |
test-with-coverage: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.10", "3.11" ] | |
os: [ ubuntu-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install project | |
run: python -Im pip install .[coverage,testsuite] | |
- name: Test and measure coverage, on Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
run: coverage run --data-file=.coverage.$(echo ${{ matrix.python-version }} | tr -d .) -m pytest -vv | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data-${{ matrix.python-version }} | |
path: .coverage.* | |
if-no-files-found: ignore | |
# See: https://hynek.me/articles/ditch-codecov-python/ | |
report-coverage: | |
name: Combine and check coverage | |
needs: test-with-coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version-file: .python-version-default | |
cache: pip | |
- run: python -Im pip install .[coverage] | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-data-* | |
merge-multiple: true | |
- name: Combine coverage & fail if it's <100%. | |
run: | | |
python -Im coverage combine | |
python -Im coverage html --skip-covered --skip-empty | |
# Report and write to summary. | |
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | |
# Report again and fail if under 100%. | |
python -Im coverage report --fail-under=100 | |
- name: Upload HTML report if check failed. | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report | |
path: htmlcov | |
if: ${{ failure() }} | |
# See: https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html | |
- name: Create coverage status badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_BADGE_SECRET }} | |
gistID: 5d09224ecea8b55443fb2c92b8e8c6a7 | |
filename: badge.json | |
label: Coverage | |
message: ${{ env.total }}% | |
minColorRange: 50 | |
maxColorRange: 90 | |
valColorRange: ${{ env.total }} | |
other-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.10", "3.11" ] | |
os: [ macos-latest, windows-latest, ubuntu-20.04 ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install project | |
run: python -Im pip install .[testsuite] | |
- name: Run unit tests on Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
run: pytest -vv |