Repository navigation
test: cover repeated headers per RFC 9110 §5.3 #10
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 | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - ready_for_review | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| env: | |
| STABLE_PYTHON_VERSION: '3.11' | |
| PYTEST_ADDOPTS: --color=yes | |
| HATCH_VERBOSE: '1' | |
| FORCE_COLOR: '1' | |
| jobs: | |
| complete: | |
| name: Test completion check | |
| if: always() | |
| permissions: | |
| contents: none | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test | |
| - example | |
| - format | |
| - lint | |
| - typecheck | |
| - prek | |
| steps: | |
| - name: Failed | |
| run: exit 1 | |
| if: | | |
| contains(needs.*.result, 'failure') | |
| || contains(needs.*.result, 'cancelled') | |
| test: | |
| name: >- | |
| Test Python ${{ matrix.python-version }} | |
| on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} | |
| # TEMP: run on draft PRs to test the fork FFI prerelease, revert before merge. | |
| if: true | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - macos-latest | |
| - ubuntu-latest | |
| - windows-latest | |
| python-version: | |
| - '3.11' | |
| - '3.15' | |
| - 3.15t | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2 | |
| with: | |
| enable-cache: true | |
| - name: Install Python | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Install Pact CLI | |
| uses: jdx/mise-action@8418fedb1110381a0d3ba51a7a415d7c1b884550 # v5.2.2 | |
| - name: Set PATH on Windows | |
| if: startsWith(matrix.os, 'windows-') | |
| shell: pwsh | |
| run: echo "$pwd/pact-python-ffi/src/pact_ffi" >> $env:GITHUB_PATH | |
| - name: Set DYLD_LIBRARY_PATH on macOS | |
| if: startsWith(matrix.os, 'macos-') | |
| run: echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$PWD/pact-python-ffi/src/pact_ffi" >> $GITHUB_ENV | |
| - name: Install Hatch | |
| run: uv tool install hatch | |
| - name: Run tests | |
| run: hatch run test.py${{ matrix.python-version }}:test --junit-xml=junit.xml --cov-report=xml:coverage-tests.xml | |
| - name: Run tests (FFI) | |
| working-directory: pact-python-ffi | |
| run: hatch run test.py${{ matrix.python-version }}:test --junit-xml=junit.xml --cov-report=xml:coverage-ffi.xml | |
| - name: Run tests (lazy imports) | |
| if: matrix.python-version == '3.15' && matrix.os == 'ubuntu-latest' | |
| env: | |
| PACT_TEST_LAZY_IMPORTS: '1' | |
| run: hatch run test.py${{ matrix.python-version }}:test --no-cov | |
| - name: Upload coverage | |
| if: matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest' | |
| uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: tests | |
| files: coverage-tests.xml,pact-python-ffi/coverage-ffi.xml | |
| - name: Upload test results | |
| if: ${{ !cancelled() }} | |
| uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: tests | |
| report_type: test_results | |
| example: | |
| name: >- | |
| Test Python Example ${{ matrix.python-version }} | |
| on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} | |
| # TEMP: run on draft PRs to test the fork FFI prerelease, revert before merge. | |
| if: true | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - macos-latest | |
| - ubuntu-latest | |
| - windows-latest | |
| python-version: | |
| - '3.11' | |
| - '3.15' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2 | |
| with: | |
| enable-cache: true | |
| - name: Install Python | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Run examples | |
| shell: bash | |
| run: | | |
| set -o errexit | |
| set -o pipefail | |
| while IFS= read -r -d $'\0' file <&3; do | |
| cd "$(dirname "$file")" | |
| echo "Running example in $(pwd)" | |
| uv run --python ${{ matrix.python-version }} --group test --with pytest-cov pytest --junit-xml=junit.xml --cov=pact --cov-report=xml:coverage-example.xml | |
| done 3< <(find "$(pwd)/examples" -name pyproject.toml -print0) | |
| - name: Upload coverage | |
| if: matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest' | |
| uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: examples | |
| files: examples/**/coverage-example.xml | |
| - name: Upload test results | |
| if: ${{ !cancelled() }} | |
| uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: examples | |
| report_type: test_results | |
| format: | |
| name: Format | |
| # TEMP: run on draft PRs to test the fork FFI prerelease, revert before merge. | |
| if: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2 | |
| with: | |
| enable-cache: true | |
| - name: Install Python | |
| run: uv python install ${{ env.STABLE_PYTHON_VERSION }} | |
| - name: Install Hatch | |
| run: uv tool install hatch | |
| - name: Format | |
| run: hatch run format --check --output-format github | |
| - name: Format (FFI) | |
| working-directory: pact-python-ffi | |
| run: hatch run format --check --output-format github | |
| lint: | |
| name: Lint | |
| # TEMP: run on draft PRs to test the fork FFI prerelease, revert before merge. | |
| if: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2 | |
| with: | |
| enable-cache: true | |
| - name: Install Python | |
| run: uv python install ${{ env.STABLE_PYTHON_VERSION }} | |
| - name: Install Hatch | |
| run: uv tool install hatch | |
| - name: Lint | |
| run: hatch run lint | |
| - name: Lint (FFI) | |
| working-directory: pact-python-ffi | |
| run: hatch run lint | |
| typecheck: | |
| name: Typecheck | |
| # TEMP: run on draft PRs to test the fork FFI prerelease, revert before merge. | |
| if: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2 | |
| with: | |
| enable-cache: true | |
| - name: Install Python | |
| run: uv python install ${{ env.STABLE_PYTHON_VERSION }} | |
| - name: Install Hatch | |
| run: uv tool install hatch | |
| - name: Typecheck | |
| run: hatch run typecheck | |
| prek: | |
| name: Prek | |
| # TEMP: run on draft PRs to test the fork FFI prerelease, revert before merge. | |
| if: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2 | |
| - name: Install hatch | |
| run: uv tool install hatch | |
| - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0 |