-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathconfig.yml
More file actions
407 lines (404 loc) · 12.7 KB
/
config.yml
File metadata and controls
407 lines (404 loc) · 12.7 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/configuration-reference
version: 2.1
parameters:
python_version:
type: string
default: "3.13"
executors:
default_image:
docker:
- image: ghcr.io/astral-sh/uv:python<<pipeline.parameters.python_version>>-bookworm
working_directory: /codegen-sdk
environment:
UV_COMPILE_BYTECODE: 1
UV_LINK_MODE: copy
default_vm:
machine:
image: ubuntu-2404:current
orbs:
aws-cli: circleci/aws-cli@5.1.2
codecov: codecov/codecov@5.2.0
node: circleci/node@7.0.0
github-cli: circleci/github-cli@2.6.2
slack: circleci/slack@5.1.1
commands:
install-lfs:
steps:
- run:
command: |
apt update && apt install -y git-lfs
git lfs install
setup-lfs:
steps:
- run:
command: |
./scripts/setup-lfs.sh
install-uv:
steps:
- run:
command: |
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
clone-repos:
parameters:
extra_repos:
type: boolean
default: true
steps:
- restore_cache:
keys:
- repos-<<parameters.extra_repos>>
- run:
command: |
EXTRA_REPOS_ARG=""
if [ "<<parameters.extra_repos>>" = "true" ]; then
EXTRA_REPOS_ARG="--extra-repos"
fi
uv run --frozen python -m tests.shared.codemod.commands clone-repos ${EXTRA_REPOS_ARG} --token ${CODEGEN_BOT_GHE_TOKEN} --clean-cache
- save_cache:
paths:
- $GITHUB_WORKSPACE
key: repos-<<parameters.extra_repos>>
fetch-verified-codemods:
steps:
- run:
command: |
uv run --frozen python -m tests.shared.codemod.commands fetch-verified-codemods --cli-api-key ${PROD_CLI_API_KEY}
cache-verified-codemod-repos:
steps:
- restore_cache:
keys:
- v1-verified-codemod-repos-{{ checksum "tests/integration/verified_codemods/codemod_data/repo_commits.json" }}-{{.Environment.CIRCLE_NODE_INDEX}}-{{.Environment.CIRCLE_NODE_TOTAL}}
- run:
command: |
uv run --frozen python -m tests.shared.codemod.commands clone-repos --verified-codemod-repos --token ${CODEGEN_BOT_GHE_TOKEN}
- save_cache:
paths:
- $GITHUB_WORKSPACE
key: v1-verified-codemod-repos-{{ checksum "tests/integration/verified_codemods/codemod_data/repo_commits.json" }}-{{.Environment.CIRCLE_NODE_INDEX}}-{{.Environment.CIRCLE_NODE_TOTAL}}
build-wheels:
steps:
- install-uv
- restore_cache:
keys:
- cibuildwheel-cache-<<pipeline.parameters.python_version>>-{{ .Environment.CIRCLE_JOB }}-{{ checksum "uv.lock" }}--{{ checksum "pyproject.toml" }}-{{ arch }}
- run:
command: |
uv run --frozen cibuildwheel --output-dir dist
rm dist/.gitignore || true
environment:
HATCH_BUILD_HOOKS_ENABLE: "true"
- save_cache:
paths:
- /home/circleci/.cache/cibuildwheel
key: cibuildwheel-cache-<<pipeline.parameters.python_version>>-{{ .Environment.CIRCLE_JOB }}-{{ checksum "uv.lock" }}--{{ checksum "pyproject.toml" }}-{{ arch }}
setup-uv:
steps:
- install-lfs
- checkout
- restore_cache:
keys:
- uv-cache-1-<<pipeline.parameters.python_version>>-{{ .Environment.CIRCLE_WORKING_DIRECTORY }}-{{ arch }}-{{ checksum "uv.lock" }}
- run:
shell: bash
command: |
uv tool install codecov-cli --python 3.10 --with coverage
pip install coverage
uv sync --frozen --all-extras --python <<pipeline.parameters.python_version>>
- save_cache:
paths:
- ~/.cache/uv
key: uv-cache-1-<<pipeline.parameters.python_version>>-{{ .Environment.CIRCLE_WORKING_DIRECTORY }}-{{ arch }}-{{ checksum "uv.lock" }}
- setup-lfs
upload-tests:
steps:
- store_test_results:
path: build/test-results/test/TEST.xml
- codecov/upload:
binary: ../root/.local/bin/codecovcli
files: build/test-results/test/TEST.xml
report_type: test_results
run_ats:
parameters:
default_tests:
type: string
default: "tests/unit"
codecov_flags:
type: string
default: "smart-tests"
ats_collect_args:
type: string
default: ""
collect_args:
type: string
default: ""
split_tests:
type: boolean
default: true
steps:
- run:
command: |
export BASE_SHA=<<pipeline.git.base_revision>>
export DEFAULT_TESTS="<<parameters.default_tests>>"
export CODECOV_STATIC_TOKEN="${CODECOV_STATIC_TOKEN}"
export CODECOV_TOKEN="${CODECOV_TOKEN}"
export COLLECT_ARGS="<<parameters.collect_args>>"
export ATS_COLLECT_ARGS="<<parameters.ats_collect_args>>"
uv run --frozen bash ./.circleci/ats.sh
- store_artifacts:
path: codecov_ats
destination: ${CIRCLE_NODE_INDEX}-${CIRCLE_JOB}-
- when:
condition: <<parameters.split_tests>>
steps:
- run:
name: Run tests
command: |
TESTS_TO_RUN=$(cat codecov_ats/tests_to_run.txt)
echo $TESTS_TO_RUN
echo $TESTS_TO_RUN | circleci tests run --command "xargs uv run --frozen pytest --cov \
-o junit_suite_name="${CIRCLE_JOB}-${CIRCLE_NODE_INDEX}" \
-n auto \
-vv \
--cov \
--cov-append \
<<parameters.collect_args>>
" --split-by=timings --timings-type=name
- unless:
condition: <<parameters.split_tests>>
steps:
- run:
name: Run tests
command: |
cat codecov_ats/tests_to_run.txt | xargs uv run --frozen pytest \
--cov \
-vv \
-o junit_suite_name="${CIRCLE_JOB}-${CIRCLE_NODE_INDEX}" \
-n auto \
--cov-append \
<<parameters.collect_args>>
- upload-tests
- codecov/upload:
flags: <<parameters.codecov_flags>>
plugins: pycoverage,compress-pycoverage
files: coverage.codecov.json
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs
jobs:
unit-tests:
parallelism: 8
executor: default_image
resource_class: "xlarge"
steps:
- setup-uv
- node/install:
use-nvm-cache: true
- run_ats:
default_tests: "tests/unit"
collect_args: --timeout 50
integration-tests:
executor: default_image
resource_class: "large"
steps:
- setup-uv
- run:
command: |
uv run --frozen pytest -o junit_suite_name="${CIRCLE_JOB}" -n auto tests/integration/codegen
- upload-tests
doctests:
executor: default_image
steps:
- setup-uv
- run:
command: |
uv run --frozen pytest -o junit_suite_name="${CIRCLE_JOB}" -n auto docs
- upload-tests
codemod-tests:
parallelism: 8
executor: default_vm
resource_class: "2xlarge+"
steps:
- install-uv
- setup-uv
- fetch-verified-codemods
- cache-verified-codemod-repos
- run_ats:
default_tests: "tests/integration/codemod/test_verified_codemods.py"
codecov_flags: "smart-tests-codemod"
collect_args: --cli-api-key ${PROD_CLI_API_KEY} --token ${CODEGEN_BOT_GHE_TOKEN}
ats_collect_args: --cli-api-key=${PROD_CLI_API_KEY},--token=${CODEGEN_BOT_GHE_TOKEN},
split_tests: false
- slack/notify:
event: fail
branch_pattern: "develop"
channel: "alerts-codemod-tests"
template: basic_fail_1
oss-codemod-tests:
parameters:
sync_graph:
type: boolean
default: true
size:
type: string
default: "small"
parallelism: 2
executor: default_vm
resource_class: xlarge
steps:
- install-uv
- setup-uv
- clone-repos:
extra_repos: false
- run_ats:
default_tests: "tests/integration/codemod/test_codemods.py"
codecov_flags: "smart-tests-codemod-oss"
collect_args: --size=<<parameters.size>> --sync-graph=<<parameters.sync_graph>> --token ${CODEGEN_BOT_GHE_TOKEN}
ats_collect_args: --size=<<parameters.size>>,--sync-graph=<<parameters.sync_graph>>,--token=${CODEGEN_BOT_GHE_TOKEN},
split_tests: false
- slack/notify:
event: fail
branch_pattern: "develop"
channel: "alerts-codemod-tests"
template: basic_fail_1
parse-tests:
parameters:
extra_repos:
type: boolean
default: true
executor: default_vm
resource_class: "2xlarge"
parallelism: 2
steps:
- install-uv
- setup-uv
- node/install:
install-pnpm: true
install-yarn: true
use-nvm-cache: true
- clone-repos:
extra_repos: <<parameters.extra_repos>>
- run:
command: |
EXTRA_REPOS_ARG=""
if [ "<<parameters.extra_repos>>" = "true" ]; then
EXTRA_REPOS_ARG="--extra-repos=true"
fi
PYTEST_ARGS="${EXTRA_REPOS_ARG} --token ${CODEGEN_BOT_GHE_TOKEN} -o junit_suite_name=\"${CIRCLE_JOB}\" tests/integration/codemod/test_parse.py"
echo "Running tests with args: $PYTEST_ARGS"
TESTS_TO_RUN=$(PYTEST_ARGS=${PYTEST_ARGS} ./.circleci/collect.sh)
echo $TESTS_TO_RUN | circleci tests run --command "ulimit -s unlimited; xargs uv run --frozen pytest -n auto ${PYTEST_ARGS}"
- store_test_results:
path: build/test-results/test/TEST.xml
- when:
condition: <<parameters.extra_repos>>
steps:
- slack/notify:
event: fail
branch_pattern: "develop"
channel: "alerts-parse-tests"
template: basic_fail_1
linux-wheels:
parameters:
resource_class:
type: string
default: "large"
working_directory: ~/linux-wheels
machine:
image: ubuntu-2404:2024.05.1
docker_layer_caching: true
resource_class: <<parameters.resource_class>>
steps:
- checkout
- build-wheels
- persist_to_workspace:
root: .
paths:
- dist/
osx-wheels:
working_directory: ~/osx-wheels
macos:
xcode: 15.4.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- build-wheels
- persist_to_workspace:
root: .
paths:
- dist/
release-aws:
executor: default_image
steps:
- checkout
- attach_workspace:
at: .
- aws-cli/setup:
role_arn: $AWS_OIDC_ARN
- run:
name: Release
command: |
uv tool install keyring --with keyrings.codeartifact
export UV_PUBLISH_PASSWORD="$(aws codeartifact get-authorization-token --domain codegen --domain-owner 922078275900 --region us-east-1 --query authorizationToken --output text)"
export UV_PUBLISH_USERNAME=aws
uv publish
release-pypi:
executor: default_image
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Release
command: |
export UV_PUBLISH_PASSWORD="${PYPI_TOKEN}"
export UV_PUBLISH_USERNAME="__token__"
uv publish --publish-url https://upload.pypi.org/legacy/ --keyring-provider disabled
- slack/notify:
event: fail
branch_pattern: "develop"
channel: "release"
template: basic_fail_1
- slack/notify:
event: pass
channel: "release"
template: success_tagged_deploy_1
workflows:
pr_checks:
jobs:
- unit-tests
- integration-tests
publish-packages:
jobs:
- linux-wheels:
filters:
tags:
only: /^v.*/
matrix:
parameters:
resource_class: [large, arm.large]
- osx-wheels:
filters:
tags:
only: /^v.*/
- release-aws:
filters:
tags:
only: /^v.*/
context:
- AWS
requires:
- linux-wheels
- osx-wheels
- release-pypi:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
context:
- pypi
- slack
requires:
- linux-wheels
- osx-wheels