Fix codespeed python version #2930
Workflow file for this run
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: Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 9 * * *" | |
| concurrency: | |
| group: test-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: >- | |
| ${{ matrix.py || matrix.name }} on | |
| ${{ matrix.os == 'windows-latest' && 'Windows' || (matrix.os == 'macos-latest' && 'macOS' || 'Ubuntu') }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| py: ["3.14", "3.13", "3.12", "3.11", "3.10"] | |
| os: [ubuntu-24.04, windows-latest, macos-latest] | |
| tox_env: [''] | |
| include: | |
| - tox_env: py312-black24-parallel | |
| name: py312-black24 | |
| - tox_env: py312-black23-parallel | |
| name: py312-black23 | |
| - tox_env: py312-black22-parallel | |
| name: py312-black22 | |
| - tox_env: py312-isort7-parallel | |
| name: py312-isort7 | |
| - tox_env: py312-isort6-parallel | |
| name: py312-isort6 | |
| - tox_env: py312-isort5-parallel | |
| name: py312-isort5 | |
| - tox_env: py312-pydantic1-parallel | |
| name: py312-pydantic1 | |
| 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: | |
| enable-cache: true | |
| cache-suffix: "${{ matrix.py || matrix.tox_env }}" | |
| - name: Install tox | |
| run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv | |
| - name: Setup Python test environment | |
| run: | | |
| if [ -n "${{ matrix.py }}" ]; then | |
| TOX_ENV="py${{ matrix.py }}-parallel" | |
| TOX_ENV="${TOX_ENV//.}" | |
| else | |
| TOX_ENV="${{ matrix.tox_env }}" | |
| fi | |
| tox run -vv --notest --skip-missing-interpreters false -e $TOX_ENV | |
| shell: bash | |
| env: | |
| UV_PYTHON_PREFERENCE: "only-managed" | |
| - name: Run test suite | |
| run: | | |
| if [ -n "${{ matrix.py }}" ]; then | |
| TOX_ENV="py${{ matrix.py }}-parallel" | |
| TOX_ENV="${TOX_ENV//.}" | |
| else | |
| TOX_ENV="${{ matrix.tox_env }}" | |
| fi | |
| tox run --skip-uv-sync --skip-pkg-install -e $TOX_ENV | |
| shell: bash | |
| env: | |
| UV_PYTHON_PREFERENCE: "only-managed" | |
| - name: Rename coverage report file | |
| run: | | |
| import os; import sys | |
| py = "${{ matrix.py }}" | |
| if py: | |
| env_name = f"py{py.replace('.', '')}-parallel" | |
| base_name = py | |
| else: | |
| env_name = "${{ matrix.tox_env }}" | |
| base_name = "${{ matrix.tox_env }}" | |
| os.rename(f".tox/.coverage.{env_name}", f".tox/.coverage.{base_name}-${{ matrix.os }}") | |
| shell: python | |
| - name: Upload coverage data | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| include-hidden-files: true | |
| name: .coverage.${{ matrix.py || matrix.tox_env }}-${{ matrix.os == '' && 'ubuntu-24.04' || matrix.os }} | |
| path: ".tox/.coverage.*" | |
| retention-days: 3 | |
| coverage: | |
| name: combine coverage | |
| runs-on: ubuntu-latest | |
| needs: test | |
| 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 coverage tool | |
| run: tox run -e coverage --notest | |
| env: | |
| UV_PYTHON_PREFERENCE: only-managed | |
| - name: Download coverage data | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: .tox | |
| pattern: .coverage.* | |
| merge-multiple: true | |
| - name: Combine and report coverage | |
| id: coverage | |
| run: tox run -e coverage --skip-uv-sync --skip-pkg-install | |
| continue-on-error: true | |
| env: | |
| UV_PYTHON_PREFERENCE: only-managed | |
| - name: Show uncovered lines on failure | |
| if: steps.coverage.outcome == 'failure' | |
| run: | | |
| echo "::error::Coverage check failed. Lines not covered:" | |
| COVERAGE_FILE=.tox/.coverage .tox/coverage/bin/coverage report --show-missing --fail-under=0 | grep -v "100%" | |
| - name: Upload HTML report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: html-report | |
| path: .tox/htmlcov | |
| - name: Upload coverage to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| flags: unittests | |
| files: .tox/coverage.xml | |
| fail_ci_if_error: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Fail if coverage check failed | |
| if: steps.coverage.outcome == 'failure' | |
| run: exit 1 | |
| check: | |
| name: ${{ matrix.tox_env }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| tox_env: | |
| - type | |
| - docs | |
| - pkg_meta | |
| 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 }} | |
| env: | |
| UV_PYTHON_PREFERENCE: "only-managed" | |
| - name: Run check for ${{ matrix.tox_env }} | |
| run: tox run --skip-uv-sync --skip-pkg-install -e ${{ matrix.tox_env }} | |
| env: | |
| UV_PYTHON_PREFERENCE: "only-managed" |