-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (79 loc) · 3.21 KB
/
Copy pathcontract.yml
File metadata and controls
82 lines (79 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Contract Tests
"on":
push:
paths:
- "config/contracts/**"
- "scripts/generate_contracts.py"
- "src/**"
- "sdk/**"
- "docs/openapi.json"
- "docs/agent-tools/**"
- "scripts/export_openapi.py"
- "tests/contract/**"
- "tests/unit/test_contracts_in_sync.py"
- ".github/workflows/contract.yml"
- "pyproject.toml"
- "sdk/pyproject.toml"
- ".github/workflows/**"
- "infrastructure/terraform/**"
- "sdk-ts/**"
- "Dockerfile*"
# No `paths:` filter on pull_request: `contract` is a required
# branch-protection check, so the job must COMPLETE on every PR.
# A paths filter would leave contract-irrelevant PRs stuck forever on
# "Expected - waiting for status" (the Lessons 1/4 trap, closed for
# build-smoke in PR #37). Path-gating happens inside the job via the
# `changes` step instead.
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
contract:
name: contract
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Detect contract-relevant changes
id: changes
shell: bash
run: |
set -euo pipefail
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "Non-PR event (${{ github.event_name }}): full suite runs."
echo "relevant=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base="${{ github.event.pull_request.base.sha }}"
changed="$(git diff --name-only "${base}...HEAD")"
printf 'Changed files:\n%s\n' "${changed}"
if printf '%s\n' "${changed}" | grep -E -q \
'^(config/contracts/|scripts/generate_contracts\.py$|src/|sdk/|docs/openapi\.json$|docs/agent-tools/|scripts/export_openapi\.py$|tests/contract/|tests/unit/test_contracts_in_sync\.py$|\.github/workflows/|infrastructure/terraform/|sdk-ts/|pyproject\.toml$|Dockerfile)'; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
else
echo "relevant=false" >> "$GITHUB_OUTPUT"
fi
- name: Skip note (no contract-relevant changes)
if: steps.changes.outputs.relevant == 'false'
run: echo "No contract-relevant changes - suite skipped, required check passes."
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
if: steps.changes.outputs.relevant == 'true'
with:
python-version: "3.11"
cache: "pip"
- run: python -m pip install --upgrade pip
if: steps.changes.outputs.relevant == 'true'
- run: pip install -e ".[dev,cloud,contract]"
if: steps.changes.outputs.relevant == 'true'
- run: pip install -e "./sdk"
if: steps.changes.outputs.relevant == 'true'
- run: python scripts/generate_contracts.py --check
if: steps.changes.outputs.relevant == 'true'
- run: python scripts/export_openapi.py --check
if: steps.changes.outputs.relevant == 'true'
- run: mkdir -p .tmp
if: steps.changes.outputs.relevant == 'true'
- run: python -m pytest tests/contract -v --tb=short
if: steps.changes.outputs.relevant == 'true'