Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: CI
2 on:
3 push:
4 branches:
5 - '**'
6 - '!integrated/**'
7 - '!stl-preview-head/**'
8 - '!stl-preview-base/**'
9 - '!generated'
10 - '!codegen/**'
11 - 'codegen/stl/**'
12 pull_request:
13 branches-ignore:
14 - 'stl-preview-head/**'
15 - 'stl-preview-base/**'
16
17 concurrency:
18 group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.sha || github.ref }}
19 cancel-in-progress: true
20
21 jobs:
22 lint:
23 timeout-minutes: 10
24 name: lint
25 runs-on: 'ubuntu-latest'
26 if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
27 steps:
28 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29
30 - name: Install uv
31 uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
32 with:
33 version: '0.10.2'
34
35 - name: Install dependencies
36 run: uv sync --all-extras
37
38 - name: Run lints
39 run: ./scripts/lint
40
41 build:
42 if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
43 timeout-minutes: 10
44 name: build
45 permissions:
46 contents: read
47 id-token: write
48 runs-on: 'ubuntu-latest'
49 steps:
50 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51
52 - name: Install uv
53 uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
54 with:
55 version: '0.10.2'
56
57 - name: Install dependencies
58 run: uv sync --all-extras
59
60 - name: Run build
61 run: uv build
62
63 - name: Get GitHub OIDC Token
64 if: |-
65 github.repository == 'anthropics/anthropic-sdk-python-private' &&
66 !startsWith(github.ref, 'refs/heads/stl/')
67 id: github-oidc
68 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
69 with:
70 script: core.setOutput('github_token', await core.getIDToken());
71
72 - name: Upload tarball
73 if: |-
74 github.repository == 'anthropics/anthropic-sdk-python-private' &&
75 !startsWith(github.ref, 'refs/heads/stl/')
76 env:
77 URL: https://pkg.stainless.com/s
78 AUTH: ${{ steps.github-oidc.outputs.github_token }}
79 SHA: ${{ github.sha }}
80 run: ./scripts/utils/upload-artifact.sh
81
82 test:
83 timeout-minutes: 10
84 name: test
85 runs-on: 'ubuntu-latest'
86 if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
87 steps:
88 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89
90 - name: Install uv
91 uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
92 with:
93 version: '0.10.2'
94
95 - name: Bootstrap
96 run: ./scripts/bootstrap
97
98 - name: Run tests
99 run: ./scripts/test
100
101 detect_breaking_changes:
102 timeout-minutes: 10
103 name: detect-breaking-changes
104 runs-on: 'ubuntu-latest'
105 if: |-
106 (github.event_name == 'push' &&
107 !startsWith(github.ref, 'refs/heads/release-please--')) ||
108 github.event.pull_request.head.repo.fork
109 steps:
110 # fetch-depth: 0 fetches full commit history (all branches and
111 # tags, so the base ref is available) so `git merge-base`
112 # below can resolve the fork point. filter: blob:none keeps the
113 # fetch cheap: commit metadata is downloaded eagerly, file blobs
114 # only when a later `git checkout` asks for them.
115 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
116 with:
117 fetch-depth: 0
118 filter: blob:none
119
120 - name: Install uv
121 uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
122 with:
123 version: '0.10.2'
124
125 - name: Install dependencies
126 run: uv sync --all-extras
127
128 - name: Determine base SHA
129 run: |
130 # A breaking-change-baseline tag, when the repo keeps one, marks the API
131 # surface to compare against; it is moved by force, so refetch it.
132 git fetch --quiet --force origin '+refs/tags/breaking-change-baseline:refs/tags/breaking-change-baseline' 2>/dev/null || true
133 if git rev-parse --quiet --verify 'refs/tags/breaking-change-baseline^{commit}' >/dev/null; then
134 BASE_REF='refs/tags/breaking-change-baseline'
135 elif git rev-parse --quiet --verify 'origin/main^{commit}' >/dev/null; then
136 BASE_REF='origin/main'
137 else
138 echo 'No breaking-change-baseline tag or origin/main to compare against; skipping.'
139 echo "BASE_SHA=" >> "$GITHUB_ENV"
140 exit 0
141 fi
142 echo "Comparing against $BASE_REF"
143 BASE_SHA=$(git merge-base HEAD "$BASE_REF" 2>/dev/null || echo "")
144 echo "BASE_SHA=$BASE_SHA" >> "$GITHUB_ENV"
145
146 - name: Detect removed symbols
147 if: env.BASE_SHA != ''
148 run: |
149 uv run python scripts/detect-breaking-changes.py "$BASE_SHA"
150
151 - name: Detect breaking changes
152 if: env.BASE_SHA != ''
153 run: |
154 # Try to check out previous versions of the breaking change detection script. This ensures that
155 # we still detect breaking changes when entire files and their tests are removed.
156 git checkout "$BASE_SHA" -- ./scripts/detect-breaking-changes 2>/dev/null || true
157 ./scripts/detect-breaking-changes "$BASE_SHA"