Skip to content

finalise v0.1.2 release date #16

finalise v0.1.2 release date

finalise v0.1.2 release date #16

Workflow file for this run

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 --omit=tests/*.py --data-file=.coverage.$(echo ${{ matrix.python-version }} | tr -d .) -m pytest -vv
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
# To be kept in sync with combiner step to follow
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, report, and check coverage
needs: test-with-coverage # To be kept in sync with name of coverage-emitting job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# Only need to RUN with one Python here, and it shouldn't really matter which one.
python-version: "3.11"
cache: pip
- run: python -Im pip install coverage
- uses: actions/download-artifact@v4
with:
# To be kept in sync with upload/emission step already done
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
python -Im coverage html
# Report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# Report and write to JSON for parsing for badge.
# See: https://github.com/nedbat/coveragepy/blob/8ab9ff17409e3f6f3f5f2c0076d8b3250e8da4a0/coverage/jsonreport.py#L62-L67
python -Im coverage json --pretty-print
export TOTAL_COVERAGE_PERCENTAGE=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
export COVER_STATEMENTS=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['covered_lines'])")
export TOTAL_STATEMENTS=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['num_statements'])")
echo "cov_pct=$TOTAL_COVERAGE_PERCENTAGE" >> $GITHUB_ENV
echo "covered_statement_count=$COVER_STATEMENTS" >> $GITHUB_ENV
echo "total_statement_count=$TOTAL_STATEMENTS" >> $GITHUB_ENV
# 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.cov_pct }}% (${{ env.covered_statement_count }} of ${{ env.total_statement_count }})
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.cov_pct }}
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