-
Notifications
You must be signed in to change notification settings - Fork 5k
277 lines (236 loc) · 9.28 KB
/
Copy pathci.yml
File metadata and controls
277 lines (236 loc) · 9.28 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
name: CI
on:
push:
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'
workflow_dispatch:
# Exercise the complete supported matrix and the next CPython prerelease
# even when the repository has not changed.
schedule:
- cron: '47 9 * * *'
jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
with:
version: '0.44.0'
enable-cache: true
- name: Install dependencies
run: rye sync --all-features
- name: Run lints
run: ./scripts/lint
build:
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
with:
version: '0.44.0'
enable-cache: true
- name: Install dependencies
run: rye sync --all-features
- name: Run build
run: rye build
- name: Validate Python version metadata
run: rye run python scripts/utils/validate-python-version-wheel.py
- name: Validate Bedrock wheel
run: rye run python scripts/utils/validate-bedrock-wheel.py
- name: Validate HTTPX2 wheel on Python 3.10
run: rye run python scripts/utils/validate-httpx2-wheel.py
- name: Set up Python 3.9 for resolver rejection
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.9'
- name: Prove Python 3.9 rejects the wheel
run: python scripts/utils/validate-python-version-wheel.py --check-python-39
- name: Set up Python 3.14
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.14'
- name: Validate HTTPX2 wheel on Python 3.14
run: python scripts/utils/validate-httpx2-wheel.py
- name: Get GitHub OIDC Token
if: |-
github.repository == 'stainless-sdks/openai-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: core.setOutput('github_token', await core.getIDToken());
- name: Upload tarball
if: |-
github.repository == 'stainless-sdks/openai-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
run: ./scripts/utils/upload-artifact.sh
test:
timeout-minutes: 15
name: test (Python ${{ matrix.python-version }})
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
strategy:
fail-fast: false
matrix:
# Per-PR coverage protects both ends of the support window.
python-version: ["3.10", "3.14"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
with:
version: '0.44.0'
enable-cache: false
- name: Select Python ${{ matrix.python-version }}
run: |
rye toolchain register "${{ steps.setup-python.outputs.python-path }}"
rye pin --relaxed --no-update-requires-python "${{ matrix.python-version }}"
- name: Bootstrap
run: ./scripts/bootstrap
- name: Run tests
run: ./scripts/test
test-httpx2:
timeout-minutes: 20
name: test (HTTPX2)
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Python 3.14
id: setup-python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.14'
- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
with:
version: '0.44.0'
enable-cache: false
- name: Install HTTPX2 test dependencies
run: |
rye toolchain register "${{ steps.setup-python.outputs.python-path }}"
rye pin --relaxed --no-update-requires-python 3.14
rye sync --all-features
- name: Run tests with HTTPX and HTTPX2 installed
env:
OPENAI_TEST_HTTP_CLIENT: httpx
run: ./scripts/test
- name: Run tests with HTTPX2
env:
OPENAI_TEST_HTTP_CLIENT: httpx2
run: ./scripts/test
examples:
timeout-minutes: 10
name: examples
environment: ci
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.repository == 'openai/openai-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
with:
version: '0.44.0'
enable-cache: true
- name: Install dependencies
run: |
rye sync --all-features
- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
rye run python examples/demo.py
- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
rye run python examples/async_demo.py
python-policy:
timeout-minutes: 5
name: Python support policy
runs-on: ubuntu-latest
if: github.event_name != 'schedule'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Check version-policy surfaces
run: python scripts/check-python-version-policy.py
compatibility:
timeout-minutes: 20
name: compatibility (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.10"
experimental: false
- python-version: "3.11"
experimental: false
- python-version: "3.12"
experimental: false
- python-version: "3.13"
experimental: false
- python-version: "3.14"
experimental: false
- python-version: "3.15"
experimental: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: ${{ matrix.experimental }}
- name: Set up Rye
uses: eifinger/setup-rye@c694239a43768373e87d0103d7f547027a23f3c8
with:
version: '0.44.0'
enable-cache: false
- name: Select Python ${{ matrix.python-version }}
run: |
rye toolchain register "${{ steps.setup-python.outputs.python-path }}"
rye pin --relaxed --no-update-requires-python "${{ matrix.python-version }}"
- name: Install dependencies
run: rye sync --all-features
- name: Smoke-test the supported runtime
run: |
rye run python -c 'import openai; from openai import AsyncOpenAI, OpenAI'
rye run pytest -o addopts= --quiet \
tests/test_client.py \
tests/test_streaming.py \
tests/lib/test_pydantic.py