| 1 |
name: Run Tests |
| 2 |
|
| 3 |
on: |
| 4 |
|
| 5 |
push: |
| 6 |
branches: [main, master, 'release/**'] |
| 7 |
|
| 8 |
pull_request: |
| 9 |
branches: [main, master] |
| 10 |
|
| 11 |
workflow_dispatch: |
| 12 |
|
| 13 |
jobs: |
| 14 |
test: |
| 15 |
name: Python ${{ matrix.python-version }} – ${{ matrix.tox_env }} on ${{ matrix.os }} |
| 16 |
runs-on: ${{ matrix.os || 'ubuntu-latest' }} |
| 17 |
|
| 18 |
strategy: |
| 19 |
fail-fast: false |
| 20 |
matrix: |
| 21 |
include: |
| 22 |
- python-version: "3.9" |
| 23 |
tox_env: qa |
| 24 |
- python-version: "3.10" |
| 25 |
tox_env: qa |
| 26 |
- python-version: "3.11" |
| 27 |
tox_env: qa |
| 28 |
- python-version: "3.12" |
| 29 |
tox_env: qa |
| 30 |
|
| 31 |
|
| 32 |
- python-version: "3.13-dev" |
| 33 |
tox_env: qa |
| 34 |
continue-on-error: true |
| 35 |
|
| 36 |
- python-version: "3.14-dev" |
| 37 |
tox_env: qa |
| 38 |
continue-on-error: true |
| 39 |
|
| 40 |
- python-version: "3.15-dev" |
| 41 |
tox_env: qa |
| 42 |
continue-on-error: true |
| 43 |
|
| 44 |
|
| 45 |
- os: windows-latest |
| 46 |
python-version: "3.12" |
| 47 |
tox_env: qa |
| 48 |
|
| 49 |
- os: macos-latest |
| 50 |
python-version: "3.12" |
| 51 |
tox_env: qa |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
- python-version: "3.12" |
| 56 |
tox_env: minimal |
| 57 |
|
| 58 |
steps: |
| 59 |
- uses: actions/checkout@v7 |
| 60 |
|
| 61 |
|
| 62 |
- name: Install tox |
| 63 |
run: python -m pip install tox |
| 64 |
|
| 65 |
|
| 66 |
- name: Run tox for ${{ matrix.tox_env }} |
| 67 |
run: tox -e ${{ matrix.tox_env }} |
| 68 |
|
| 69 |
- name: Upload coverage report |
| 70 |
if: always() |
| 71 |
uses: actions/upload-artifact@v7 |
| 72 |
with: |
| 73 |
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.tox_env }} |
| 74 |
path: .coverage |
| 75 |
include-hidden-files: true |
| 76 |
|
| 77 |
codecov: |
| 78 |
name: Upload merged coverage to Codecov |
| 79 |
runs-on: ubuntu-latest |
| 80 |
needs: test |
| 81 |
if: always() |
| 82 |
|
| 83 |
steps: |
| 84 |
- uses: actions/checkout@v7 |
| 85 |
|
| 86 |
- name: Download all coverage reports |
| 87 |
uses: actions/download-artifact@v8 |
| 88 |
with: |
| 89 |
path: coverage-artifacts |
| 90 |
|
| 91 |
- name: Combine and generate coverage |
| 92 |
run: | |
| 93 |
pip install coverage |
| 94 |
|
| 95 |
# Create a consistent temp dir |
| 96 |
mkdir -p coverage-inputs |
| 97 |
|
| 98 |
# Copy and rename each coverage file to .coverage.job_name |
| 99 |
i=0 |
| 100 |
for f in $(find coverage-artifacts -name .coverage); do |
| 101 |
cp "$f" "coverage-inputs/.coverage.$i" |
| 102 |
i=$((i+1)) |
| 103 |
done |
| 104 |
|
| 105 |
# Confirm files staged |
| 106 |
ls -alh coverage-inputs |
| 107 |
|
| 108 |
# Combine them all |
| 109 |
coverage combine coverage-inputs |
| 110 |
coverage report |
| 111 |
coverage xml -o coverage.xml |
| 112 |
|
| 113 |
|
| 114 |
- name: Upload to Codecov |
| 115 |
uses: codecov/codecov-action@v7 |
| 116 |
with: |
| 117 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 118 |
files: coverage.xml |
| 119 |
verbose: false |
| 120 |
fail_ci_if_error: false |
| 121 |
env: |
| 122 |
CODECOV_PR: ${{ github.event.pull_request.number }} |
| 123 |
CODECOV_SHA: ${{ github.sha }} |