Repository navigation
491 lines (447 loc) · 18.4 KB
/
Copy pathci.yml
File metadata and controls
491 lines (447 loc) · 18.4 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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
# An older commit's rerun must not cancel the latest push to the same PR.
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.run_attempt == 1 && github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
UV_LOCKED: 1
jobs:
detect-vet-workspaces:
# CI on main is redundant in the security repository.
if: ${{ github.repository != 'astral-sh/uv-security' || github.ref != 'refs/heads/main' }}
runs-on: ${{ github.repository_owner == 'astral-sh' && 'github-ubuntu-24.04-x86_64-2' || 'ubuntu-latest' }}
outputs:
workspaces: ${{ steps.detect.outputs.workspaces }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
persist-credentials: false
- name: "Install uv"
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
# renovate: datasource=github-release-attachments depName=astral-sh/uv
version: "0.13.6"
checksum: "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645"
- name: "Detect Cargo Vet workspaces"
id: detect
env:
HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
UV_PYTHON_DOWNLOADS_JSON_URL: ${{ github.workspace }}/crates/uv-python-managed/download-metadata.json
run: uv run --script scripts/cargo-vet-workspaces.py >> "$GITHUB_OUTPUT"
check-vet:
name: "Cargo Vet"
needs: detect-vet-workspaces
uses: astral-sh/github-actions/.github/workflows/cargo-vet.yml@c064e17eb42bf9ac71f66d7f5eda694f326d16cd
with:
runner: ${{ github.repository_owner == 'astral-sh' && 'github-ubuntu-24.04-x86_64-4' || 'ubuntu-latest' }}
workspaces: ${{ needs.detect-vet-workspaces.outputs.workspaces }}
# renovate: datasource=github-release-attachments depName=astral-sh/uv
uv-version: "0.13.6"
secrets: inherit
permissions:
contents: read
id-token: write
plan:
needs: check-vet
uses: $/.github/workflows/plan.yml
check-fmt:
needs: plan
uses: $/.github/workflows/check-fmt.yml
review:
needs: plan
if: ${{ github.event_name == 'pull_request' && github.repository == 'astral-sh/uv' && github.event.pull_request.head.repo.full_name == github.repository && needs.plan.outputs.review-security == 'true' }}
uses: astral-sh/github-actions/.github/workflows/pull-request-security-review.yml@f11dbff15181b71f2cc5e8487b1ac7d7bb03ea7d
with:
runner: depot-ubuntu-24.04-16
helper-runner: github-ubuntu-24.04-x86_64-4
# renovate: datasource=github-release-attachments depName=astral-sh/uv
uv-version: "0.13.6"
uv-checksum: "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645"
# Install Rust tools such as cargo-nextest so the reviewer can test PR code.
# Keep the environment outside the checkout when switching to the PR head.
setup-command: |
export UV_PROJECT_ENVIRONMENT="$RUNNER_TEMP/pull-request-review-tools"
export UV_PYTHON_DOWNLOADS_JSON_URL="$GITHUB_WORKSPACE/crates/uv-python-managed/download-metadata.json"
uv sync --locked --only-dev
echo "$UV_PROJECT_ENVIRONMENT/bin" >> "$GITHUB_PATH"
secrets: inherit
permissions:
contents: read
id-token: write
issues: read
pull-requests: read
review-code-quality:
needs: plan
if: >-
${{
github.event_name == 'pull_request' &&
(github.repository == 'astral-sh/uv' || github.repository == 'astral-sh/uv-dev') &&
github.event.pull_request.head.repo.full_name == github.repository &&
needs.plan.outputs.run-checks == 'true'
}}
uses: $/.github/workflows/pull-request-code-quality-review.yml
secrets: inherit
permissions:
contents: read
id-token: write
issues: read
pull-requests: read
check-lint:
needs: plan
uses: $/.github/workflows/check-lint.yml
with:
code-changed: ${{ needs.plan.outputs.test-code }}
save-rust-cache: ${{ needs.plan.outputs.save-rust-cache }}
check-docs:
needs: plan
if: ${{ needs.plan.outputs.run-checks == 'true' }}
uses: $/.github/workflows/check-docs.yml
secrets: inherit
check-zizmor:
needs: plan
if: ${{ needs.plan.outputs.run-checks == 'true' }}
uses: $/.github/workflows/check-zizmor.yml
permissions:
contents: read
security-events: write
check-publish:
needs: plan
if: ${{ needs.plan.outputs.test-code == 'true' }}
uses: $/.github/workflows/check-publish.yml
check-release:
needs: plan
if: ${{ needs.plan.outputs.run-checks == 'true' || needs.plan.outputs.require-check-release == 'true' }}
uses: $/.github/workflows/check-release.yml
check-crates-policies:
needs: plan
if: ${{ needs.plan.outputs.check-crates-policies == 'true' }}
uses: $/.github/workflows/check-crates-policies.yml
secrets: inherit
permissions:
contents: read
id-token: write
check-cargo-cooldowns:
name: "check | crates cooldowns"
needs: plan
runs-on: ${{ github.repository_owner == 'astral-sh' && 'github-ubuntu-24.04-x86_64-2' || 'ubuntu-latest' }}
timeout-minutes: 15
permissions:
actions: read # Download publication times from a successful main run.
contents: read
env:
UV_PYTHON_DOWNLOADS_JSON_URL: ${{ github.workspace }}/crates/uv-python-managed/download-metadata.json
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install uv"
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
# renovate: datasource=github-release-attachments depName=astral-sh/uv
version: "0.13.6"
checksum: "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645"
- name: "Restore crate publication times from main"
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p "$RUNNER_TEMP/cargo-cooldowns"
if run_id=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml \
--branch main --event push --status success --limit 1 \
--json databaseId --jq '.[0].databaseId // empty') && [[ -n "$run_id" ]]; then
gh run download "$run_id" --repo "$GITHUB_REPOSITORY" --name cargo-publication-times --dir "$RUNNER_TEMP/cargo-cooldowns" ||
echo "No publication times available from main run $run_id; checking crates.io."
fi
- name: "Check Cargo dependency cooldowns"
run: uv run --script scripts/check_cargo_cooldowns.py --cache "$RUNNER_TEMP/cargo-cooldowns/cargo-publication-times.json"
- name: "Store crate publication times"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cargo-publication-times
path: ${{ runner.temp }}/cargo-cooldowns/cargo-publication-times.json
retention-days: 7
overwrite: true
check-cargo-lock-changes:
name: "Cargo lockfile changes"
if: >-
${{
github.event_name == 'pull_request' &&
github.repository_owner == 'astral-sh' &&
github.event.pull_request.head.repo.full_name != github.repository
}}
runs-on: github-ubuntu-24.04-x86_64-2
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
- name: "Install uv"
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
# renovate: datasource=github-release-attachments depName=astral-sh/uv
version: "0.13.6"
checksum: "f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645"
- name: "Check Cargo lockfile changes"
env:
GH_REPOSITORY: ${{ github.repository }}
UV_PYTHON_DOWNLOADS_JSON_URL: ${{ github.workspace }}/crates/uv-python-managed/download-metadata.json
run: uv run --script scripts/check-cargo-lock-changes.py HEAD^1 HEAD
check-lock:
needs: plan
if: ${{ needs.plan.outputs.run-checks == 'true' }}
uses: $/.github/workflows/check-lock.yml
check-generated-files:
needs: plan
if: ${{ needs.plan.outputs.test-code == 'true' }}
uses: $/.github/workflows/check-generated-files.yml
with:
schema-changed: ${{ needs.plan.outputs.check-schema }}
save-rust-cache: ${{ needs.plan.outputs.save-rust-cache }}
test:
needs: plan
if: ${{ needs.plan.outputs.test-code == 'true' }}
uses: $/.github/workflows/test.yml
with:
save-rust-cache: ${{ needs.plan.outputs.save-rust-cache }}
test-macos: ${{ needs.plan.outputs.test-macos }}
test-windows-trampolines:
needs: plan
if: ${{ needs.plan.outputs.test-windows-trampoline == 'true' }}
uses: $/.github/workflows/test-windows-trampolines.yml
with:
trampoline-build: ${{ needs.plan.outputs.test-windows-trampoline-check-binary }}
build-dev-binaries:
needs: plan
if: ${{ needs.plan.outputs.test-code == 'true' }}
uses: $/.github/workflows/build-dev-binaries.yml
with:
save-rust-cache: ${{ needs.plan.outputs.save-rust-cache }}
test-smoke:
needs:
- plan
- build-dev-binaries
if: ${{ needs.plan.outputs.test-smoke == 'true' }}
uses: $/.github/workflows/test-smoke.yml
with:
sha: ${{ github.sha }}
test-integration:
needs:
- plan
- build-dev-binaries
if: ${{ needs.plan.outputs.test-integration == 'true' }}
uses: $/.github/workflows/test-integration.yml
secrets: inherit
permissions:
contents: read
id-token: write
with:
sha: ${{ github.sha }}
test-system:
needs:
- plan
- build-dev-binaries
if: ${{ needs.plan.outputs.test-system == 'true' }}
uses: $/.github/workflows/test-system.yml
with:
sha: ${{ github.sha }}
test-ecosystem:
needs:
- plan
- build-dev-binaries
if: ${{ needs.plan.outputs.test-ecosystem == 'true' }}
uses: $/.github/workflows/test-ecosystem.yml
with:
sha: ${{ github.sha }}
build-release-artifacts:
needs: plan
if: ${{ needs.plan.outputs.build-release-binaries == 'true' }}
uses: $/.github/workflows/build-release-binaries.yml
secrets: inherit
build-docker:
needs: plan
if: ${{ needs.plan.outputs.build-docker == 'true' }}
uses: $/.github/workflows/build-docker.yml
with:
push-dev: ${{ needs.plan.outputs.push-docker == 'true' }}
secrets: inherit
permissions:
contents: read
id-token: write
publish-docker:
needs: build-docker
if: ${{ needs.build-docker.outputs.publish-dev == 'true' }}
uses: $/.github/workflows/publish-docker.yml
with:
manifest: ${{ needs.build-docker.outputs.manifest }}
push-dev: true
secrets: inherit
permissions:
contents: read
id-token: write
packages: write
attestations: write
bench:
needs: plan
if: ${{ needs.plan.outputs.run-bench == 'true' }}
uses: $/.github/workflows/bench.yml
secrets: inherit
with:
save-rust-cache: ${{ needs.plan.outputs.save-rust-cache }}
permissions:
contents: read
id-token: write
# This job cannot be moved into a reusable workflow because it includes coverage for uploading
# attestations and PyPI does not support attestations in reusable workflows.
test-publish:
cache-mode: none
name: "test uv publish"
timeout-minutes: 20
needs:
- plan
- build-dev-binaries
runs-on: ${{ github.repository_owner == 'astral-sh' && 'github-ubuntu-24.04-x86_64-4' || 'ubuntu-latest' }}
# Only the main repository is a trusted publisher
if: ${{ github.repository == 'astral-sh/uv' && github.event.pull_request.head.repo.fork != true && needs.plan.outputs.test-publish == 'true' }}
environment:
name: uv-test-publish
deployment: false
env:
PYTHON_VERSION: 3.12
permissions:
# For trusted publishing
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: "Download binary"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: uv-linux-libc-${{ github.sha }}
- name: "Prepare binary"
run: chmod +x ./uv
- name: "Build astral-test-pypa-gh-action"
shell: bash -eo pipefail {0}
run: |
# Build a yet unused version of `astral-test-pypa-gh-action`
mkdir astral-test-pypa-gh-action
cd astral-test-pypa-gh-action
../uv init --package --no-workspace
# Get the latest patch version
patch_version=$(curl https://test.pypi.org/simple/astral-test-pypa-gh-action/?format=application/vnd.pypi.simple.v1+json | jq --raw-output '[.files[].filename | select(endswith(".tar.gz"))] | last' | grep -oP '(?<=astral_test_pypa_gh_action-0\.1\.)\d+(?=\.tar\.gz)')
# Set the current version to one higher (which should be unused)
sed -i "s/0.1.0/0.1.$((patch_version + 1))/g" pyproject.toml
../uv build
- name: "Publish astral-test-pypa-gh-action"
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
# With this GitHub action, we can't do as rigid checks as with our custom Python script, so we publish more
# leniently
skip-existing: "true"
verbose: "true"
repository-url: "https://test.pypi.org/legacy/"
packages-dir: "astral-test-pypa-gh-action/dist"
- name: "Request GitLab OIDC tokens for impersonation"
uses: digital-blueprint/gitlab-pipeline-trigger-action@c59b56e9d2688ab42c1304322ac8831a4ef6f7d2 # v1.4.0
with:
host: gitlab.com
id: astral-test-publish/astral-test-gitlab-pypi-tp
ref: main
trigger_token: ${{ secrets.GITLAB_TEST_PUBLISH_TRIGGER_TOKEN }}
access_token: ${{ secrets.GITLAB_TEST_PUBLISH_ACCESS_TOKEN }}
download_artifacts: true
fail_if_no_artifacts: true
download_path: ./gitlab-artifacts
- name: "Load GitLab OIDC tokens from GitLab job artifacts"
id: load-gitlab-oidc-token
run: |
# we expect ./gitlab-artifacts/*/artifacts/pypi-id-token to exist
pypi_id_token_file=$(find ./gitlab-artifacts -type f -name pypi-id-token | head -n 1)
if [ -z "${pypi_id_token_file}" ]; then
echo "No pypi-id-token file found in GitLab artifacts"
exit 1
fi
GITLAB_PYPI_OIDC_TOKEN=$(cat "${pypi_id_token_file}")
# Add secret masks for the tokens.
echo "::add-mask::$GITLAB_PYPI_OIDC_TOKEN"
echo "GITLAB_PYPI_OIDC_TOKEN=${GITLAB_PYPI_OIDC_TOKEN}" >> "${GITHUB_OUTPUT}"
- name: "Add password to uv text store"
run: |
./uv auth login https://test.pypi.org/legacy/?astral-test-text-store --token ${UV_TEST_PUBLISH_TEXT_STORE}
env:
UV_TEST_PUBLISH_TEXT_STORE: ${{ secrets.UV_TEST_PUBLISH_TEXT_STORE }}
- name: "Publish test packages"
# `-p 3.12` prefers the python we just installed over the one locked in `.python_version`.
run: ./uv run --no-project -p "${PYTHON_VERSION}" scripts/publish/test_publish.py --uv ./uv all
env:
UV_TEST_PUBLISH_RUST_LOG: uv=debug,uv_publish=trace
UV_TEST_PUBLISH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_TOKEN }}
UV_TEST_PUBLISH_PASSWORD: ${{ secrets.UV_TEST_PUBLISH_PASSWORD }}
UV_TEST_PUBLISH_KEYRING: ${{ secrets.UV_TEST_PUBLISH_KEYRING }}
UV_TEST_PUBLISH_GITLAB_PAT: ${{ secrets.UV_TEST_PUBLISH_GITLAB_PAT }}
UV_TEST_PUBLISH_CODEBERG_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CODEBERG_TOKEN }}
UV_TEST_PUBLISH_CLOUDSMITH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CLOUDSMITH_TOKEN }}
UV_TEST_PUBLISH_PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
UV_TEST_PUBLISH_GITLAB_PYPI_OIDC_TOKEN: ${{ steps.load-gitlab-oidc-token.outputs.GITLAB_PYPI_OIDC_TOKEN }}
required-checks-passed:
name: "all required jobs passed"
if: ${{ always() && github.ref != 'refs/heads/main' }}
needs:
- plan
- check-cargo-cooldowns
- check-cargo-lock-changes
- check-vet
- check-fmt
- check-lint
- check-docs
- check-lock
- check-crates-policies
- check-release
- check-generated-files
- test
- test-integration
- test-system
- build-dev-binaries
- build-release-artifacts
- build-docker
runs-on: ${{ github.repository_owner == 'astral-sh' && 'github-ubuntu-24.04-x86_64-2' || 'ubuntu-slim' }}
steps:
- name: "Check required jobs passed"
run: |
failing=$(
echo "$NEEDS_JSON" | jq -r --argjson conditional_jobs "$CONDITIONAL_JOBS" '
to_entries[]
| select($conditional_jobs[.key] != false)
| select(.value.result != "success" and (.value.result != "skipped" or .key == "check-vet" or .key == "check-cargo-cooldowns"))
| "\(.key): \(.value.result)"
'
)
if [ -n "$failing" ]; then
echo "$failing"
exit 1
fi
env:
NEEDS_JSON: ${{ toJSON(needs) }}
# Jobs not listed here are always required.
CONDITIONAL_JOBS: >-
{
"build-release-artifacts": ${{ contains(github.event.pull_request.labels.*.name, 'build:release') }},
"check-release": ${{ needs.plan.outputs.require-check-release == 'true' }},
"test-integration": ${{ contains(github.event.pull_request.labels.*.name, 'test:integration') }},
"test-system": ${{ contains(github.event.pull_request.labels.*.name, 'test:system') }}
}