Unify tests for speed #985
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: ${{ github.workflow }}-${{ 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 | |
| security-events: write | |
| 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.28.4 --with tox-uv | |
| - name: Run tox | |
| run: tox ${TOX_ARGS} | |
| env: | |
| TOX_ARGS: ${{ matrix.use_factor && format('-f {0}', matrix.name) || format('-e {0}', matrix.name) }} | |
| - name: Upload zizmor SARIF report into the GitHub repo code scanning | |
| if: contains(matrix.name, 'linting') | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| sarif_file: zizmor.sarif | |
| category: zizmor | |
| - name: Report coverage | |
| if: contains(matrix.name, 'coverage') | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| fail_ci_if_error: true | |
| files: ./coverage.xml | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: linting,docs | |
| python: '3.13' | |
| allow_failure: false | |
| use_factor: false | |
| - name: py39-sqlite-xdist-coverage | |
| python: '3.9' | |
| allow_failure: false | |
| use_factor: true | |
| - name: py310-sqlite-xdist-coverage | |
| python: '3.10' | |
| allow_failure: false | |
| use_factor: true | |
| - name: py311-sqlite-xdist-coverage | |
| python: '3.11' | |
| allow_failure: false | |
| use_factor: true | |
| # start: Speeding up tests by running them in parallel. | |
| - name: py312-dj42-sqlite-xdist-coverage | |
| python: '3.12' | |
| allow_failure: false | |
| use_factor: false | |
| - name: py312-dj51-sqlite-xdist-coverage | |
| python: '3.12' | |
| allow_failure: false | |
| use_factor: false | |
| - name: py312-dj52-sqlite-xdist-coverage | |
| python: '3.12' | |
| allow_failure: false | |
| use_factor: false | |
| # end: Speeding up tests by running them in parallel. | |
| - name: py313-sqlite-xdist-coverage | |
| python: '3.13' | |
| 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-dj52-sqlite | |
| python: 'pypy3.11' | |
| allow_failure: false | |
| use_factor: false | |
| check: # This job does nothing and is only used for the branch protection | |
| if: always() | |
| needs: | |
| - test | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Decide whether the needed jobs succeeded or failed | |
| uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6 | |
| with: | |
| jobs: ${{ toJSON(needs) }} |