fix: merge test coverage before upload #3195
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: Test | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
test: | |
name: >- | |
Test ${{ matrix.py }} | |
${{ matrix.os == 'windows-latest' && 'Windows' || (matrix.os == 'macos-latest' && 'macOS' || 'Ubuntu') }} | |
${{ matrix.isort != '' && format('isort={0} ', matrix.isort) || ''}} | |
${{ matrix.black != '' && format('black={0} ', matrix.black) || ''}} | |
${{ matrix.pydantic != '' && format('pydantic={0} ', matrix.pydantic) || ''}} | |
strategy: | |
fail-fast: false | |
matrix: | |
py: ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"] | |
os: [ubuntu-24.04, windows-latest, macos-latest] | |
isort: [''] # '' mean not set, aka use the default | |
black: [''] | |
pydantic: [''] | |
include: | |
- py: 3.12 | |
black: 24.1.0 | |
- py: 3.12 | |
black: 23.12.1 | |
- py: 3.12 | |
black: 22.1.0 | |
- py: 3.9 | |
black: 19.10b0 | |
pydantic: 1.8.2 | |
- py: 3.8 | |
pydantic: 1.8.2 | |
- py: 3.8 | |
isort: 4.3.21 | |
pydantic: 1.5.1 | |
runs-on: ${{ matrix.os == '' && 'ubuntu-24.04' || matrix.os }} | |
env: | |
OS: ${{ matrix.os == '' && 'ubuntu-24.04' || matrix.os}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: ${{ matrix.py }} | |
- name: Install tox | |
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv | |
- name: Setup Python test environment | |
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }} | |
- name: Install custom package versions | |
if: ${{ matrix.isort != '' || matrix.black != '' || matrix.pydantic != ''}} | |
run: >- | |
tox exec --no-list-dependencies --skip-pkg-install -e ${{ matrix.py }} -- uv pip install | |
${{ matrix.isort != '' && format('isort=={0} ', matrix.isort) || ''}} | |
${{ matrix.black != '' && format('black=={0} ', matrix.black) || ''}} | |
${{ matrix.pydantic != '' && format('pydantic=={0} ', matrix.pydantic) || ''}} | |
- name: Run test suite | |
run: tox run --skip-pkg-install -e ${{ matrix.py }} | |
env: | |
COVERAGE_XML: coverage.${{ matrix.py }}.xml | |
- name: Upload .coverage file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.py }}-${{ matrix.os }}-${{ matrix.isort }}-${{ matrix.black }}-${{ matrix.pydantic }} | |
path: coverage.${{ matrix.py }}.xml | |
coverage-check: | |
name: Combine Coverage Reports and Check | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Download all coverage artifacts | |
uses: actions/download-artifact@v4 | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Combine coverage reports and generate XML | |
run: | | |
ls -la | |
uv run coverage combine | |
uv run coverage xml -o combined_coverage.xml | |
- name: Check combined coverage with diff-cover | |
run: uv run diff-cover --compare-branch ${DIFF_AGAINST:-origin/main} combined_coverage.xml --fail-under 100 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
flags: unittests | |
files: ./combined_coverage.xml | |
fail_ci_if_error: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
check: | |
name: tox env ${{ matrix.tox_env }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
tox_env: | |
- type | |
- dev | |
- docs | |
- pkg_meta | |
- readme | |
os: | |
- ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install the latest version of uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Install tox | |
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv | |
- name: Setup check suite | |
run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }} | |
- name: Run check for ${{ matrix.tox_env }} | |
run: tox r --skip-pkg-install -e ${{ matrix.tox_env }} |