Unify tests for speed #781
This file contains hidden or 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: main | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "*" | |
pull_request: | |
concurrency: | |
group: ci-main-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
env: | |
PYTEST_ADDOPTS: "--color=yes" | |
# Set permissions at the job level. | |
permissions: {} | |
jobs: | |
test: | |
runs-on: ubuntu-24.04 | |
continue-on-error: ${{ matrix.allow_failure }} | |
timeout-minutes: 15 | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: linting,docs | |
python: '3.13' | |
allow_failure: false | |
use_factor: true | |
- name: py313-sqlite-xdist-coverage | |
python: '3.13' | |
allow_failure: false | |
use_factor: true | |
- name: py312-sqlite-xdist-coverage | |
python: '3.12' | |
allow_failure: false | |
use_factor: true | |
- name: py311-sqlite-xdist-coverage | |
python: '3.11' | |
allow_failure: false | |
use_factor: true | |
- name: py310-sqlite-xdist-coverage | |
python: '3.10' | |
allow_failure: false | |
use_factor: true | |
- name: py39-sqlite-xdist-coverage | |
python: '3.9' | |
allow_failure: false | |
use_factor: true | |
- name: py313-djmain-postgres-coverage | |
python: '3.13' | |
allow_failure: false | |
use_factor: false | |
- name: py313-djmain-mysql-coverage | |
python: '3.13' | |
allow_failure: false | |
use_factor: false | |
- name: py313-djmain-sqlite-pytestmin | |
python: '3.13' | |
allow_failure: false | |
use_factor: false | |
# pypy3: not included with coverage reports (much slower then). | |
- name: pypy3-djmain-sqlite | |
python: 'pypy3.11' | |
allow_failure: false | |
use_factor: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Setup mysql | |
if: contains(matrix.name, 'mysql') | |
run: | | |
sudo systemctl start mysql.service | |
echo "TEST_DB_USER=root" >> $GITHUB_ENV | |
echo "TEST_DB_PASSWORD=root" >> $GITHUB_ENV | |
- name: Setup postgresql | |
if: contains(matrix.name, 'postgres') | |
run: | | |
sudo systemctl start postgresql.service | |
sudo -u postgres createuser --createdb $USER | |
- name: Install dependencies | |
run: | | |
python -m pip install uv | |
uv tool install tox==4.26.0 --with tox-uv | |
- name: Run tox | |
run: tox ${{ matrix.use_factor && '-f' || '-e' }} ${{ matrix.name }} | |
- name: Upload temporary coverage artifact | |
if: contains(matrix.name, 'coverage') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-artifact-${{ matrix.name }} | |
path: .coverage.* | |
retention-days: 1 | |
include-hidden-files: true | |
report-coverage: | |
name: Report Combined Coverage | |
runs-on: ubuntu-24.04 | |
needs: test | |
if: always() | |
permissions: | |
contents: read | |
actions: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Install coverage tool | |
run: python -m pip install coverage[toml] | |
- name: Download all coverage artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: . | |
pattern: coverage-artifact-* | |
- name: Combine coverage reports | |
run: | | |
coverage combine coverage-artifact-* | |
coverage xml | |
coverage html | |
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | |
- name: Determine retention days | |
id: determine-retention-days | |
run: | | |
if [ "${{ github.ref }}" = "refs/heads/main" ] || [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
echo "retention_days=90" >> $GITHUB_OUTPUT | |
else | |
echo "retention_days=3" >> $GITHUB_OUTPUT | |
fi | |
- name: Upload combined .coverage file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-file | |
path: .coverage | |
retention-days: ${{ steps.determine-retention-days.outputs.retention_days }} | |
include-hidden-files: true | |
- name: Upload HTML coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-html-report | |
path: htmlcov | |
retention-days: ${{ steps.determine-retention-days.outputs.retention_days }} | |
- name: Delete temporary coverage artifacts from run | |
uses: geekyeggo/delete-artifact@v5 | |
with: | |
name: coverage-artifact-* | |
- name: Report coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
files: ./coverage.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
verbose: true | |
check: # This job does nothing and is only used for the branch protection | |
if: always() | |
needs: | |
- report-coverage | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@223e4bb7a751b91f43eda76992bcfbf23b8b0302 | |
with: | |
jobs: ${{ toJSON(needs) }} |