Skip to content

feat: implement the Pact class #2735

feat: implement the Pact class

feat: implement the Pact class #2735

Workflow file for this run

---
name: test
on:
push:
branches:
- main
pull_request:
branches:
- main
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.13'
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')
|| contains(needs.*.result, 'skipped')
test:
name: >-
Test Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os,
'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
submodules: true
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
with:
enable-cache: true
- name: Install Python
run: uv python install ${{ matrix.python-version }}
- 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
- name: Run tests (v2)
run: hatch run v2-test.py${{ matrix.python-version }}:test --junit-xml=v2-junit.xml
- name: Run tests (CLI)
working-directory: pact-python-cli
run: hatch run test.py${{ matrix.python-version }}:test --junit-xml=junit.xml
- name: Run tests (FFI)
working-directory: pact-python-ffi
run: hatch run test.py${{ matrix.python-version }}:test --junit-xml=junit.xml
- name: Upload coverage
if: matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: tests
- name: Upload test results
if: ${{ !cancelled() }}
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
example:
name: >-
Test Python Example ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS'
|| startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
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 pytest --junit-xml=junit.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@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: examples
- name: Upload test results
if: ${{ !cancelled() }}
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
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 (CLI)
working-directory: pact-python-cli
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
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
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 (CLI)
working-directory: pact-python-cli
run: hatch run lint
- name: Lint (FFI)
working-directory: pact-python-ffi
run: hatch run lint
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
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
- name: Typecheck (CLI)
working-directory: pact-python-cli
run: hatch run typecheck
prek:
name: Prek (pre-commit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Cache prek
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: |-
~/.cache/prek
key: >-
${{ runner.os }}-prek-${{
hashFiles(
'**/.pre-commit-config.yaml',
'**/.pre-commit-config.yml'
) }}
restore-keys: |-
${{ runner.os }}-prek-
- name: Set up uv
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
with:
enable-cache: true
cache-suffix: prek
cache-dependency-glob: |-
**/.pre-commit-config.yaml
**/.pre-commit-config.yml
- name: Install prek
run: uv tool install prek
- name: Install hatch
run: uv tool install hatch
- name: Run prek
run: prek run --show-diff-on-failure --color=always --all-files