Fix coverage data upload & download #375
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: ["main", "master", "ci-testing-*"] | |
pull_request: | |
branches: ["main", "master"] | |
schedule: | |
- cron: "0 6 * * MON" # Every Monday morning | |
workflow_dispatch: | |
jobs: | |
tests: | |
name: "Python ${{ matrix.python-version }} / ${{ matrix.os }}" | |
runs-on: "${{ matrix.os }}" | |
env: | |
USING_COVERAGE: "3.8,3.9,3.10,3.11,3.12" | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
- "pypy3.9" | |
exclude: | |
- os: macos-latest | |
python-version: pypy3 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# We want our tags here | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- name: "Install dependencies" | |
run: | | |
python -VV | |
python -msite | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions | |
- name: "Run tox targets for ${{ matrix.python-version }}" | |
run: "python -m tox" | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }} | |
path: ".coverage*" | |
if-no-files-found: ignore | |
include-hidden-files: true | |
coverage: | |
needs: | |
- tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install coverage | |
run: python -m pip install --upgrade coverage[toml] | |
- name: Merge coverage data | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: coverage-data | |
pattern: coverage-data-* | |
delete-merged: true | |
include-hidden-files: true | |
- name: Download coverage data | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage-data | |
- name: Combine coverage | |
run: python -m coverage combine | |
# ignore-errors is so that we don't gag on missing code in .tox environments | |
- name: Generate the HTML report | |
run: python -m coverage html --skip-covered --skip-empty --ignore-errors | |
- name: Upload the HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report | |
path: htmlcov | |
# ignore-errors is so that we don't gag on missing code in .tox environments | |
- name: Enforce the coverage | |
run: python -m coverage report --ignore-errors --fail-under 95 | |
package: | |
name: "Build & verify package" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# We want our tags here | |
fetch-depth: 0 | |
- uses: hynek/build-and-inspect-python-package@v2 | |
install-dev: | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
name: "Verify dev env / ${{ matrix.os }}" | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: "Install in dev mode" | |
run: "python -m pip install -e .[dev]" | |
- name: "Import package" | |
run: "python -c 'import hamcrest; print(hamcrest.__version__)'" |