-
Notifications
You must be signed in to change notification settings - Fork 5
622 lines (524 loc) · 18 KB
/
Copy pathci.yml
File metadata and controls
622 lines (524 loc) · 18 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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
name: CI
on:
push:
branches: [main, "release/**"]
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CI_MAIN_PUSH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
jobs:
preflight:
name: preflight
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/omnifs-just
- uses: dtolnay/rust-toolchain@stable
- name: Run preflight checks
run: |
set -euo pipefail
just ci-preflight-fast
just ci-preflight-policy
- name: Check release metadata
if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')
run: |
set -euo pipefail
just release-check
components:
name: components
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip2
- uses: Swatinem/rust-cache@v2
with:
shared-key: components
cache-on-failure: true
- uses: taiki-e/install-action@v2
with:
tool: wasm-tools@1.246.2
- name: Check, build, and validate WASM components
run: just ci-wasm
- name: Stage WASM components
run: |
set -euo pipefail
mkdir -p dist-wasm
cp target/wasm32-wasip2/release/*.wasm dist-wasm/
test -n "$(find dist-wasm -maxdepth 1 -name 'omnifs_provider_*.wasm' -print -quit)"
test -f dist-wasm/omnifs_tool_archive.wasm
test -f dist-wasm/test_provider.wasm
- name: Attest WASM components
if: env.CI_MAIN_PUSH == 'true'
uses: actions/attest-build-provenance@v4
with:
subject-path: dist-wasm/*.wasm
- name: Upload WASM components
uses: actions/upload-artifact@v7
with:
name: omnifs-wasm
path: dist-wasm/*.wasm
retention-days: 90
if-no-files-found: error
host-build:
name: host build
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
CARGO_INCREMENTAL: "0"
CARGO_TARGET_DIR: ${{ github.workspace }}/target/host-build
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: host-build
cache-on-failure: true
- uses: taiki-e/install-action@v2
with:
tool: nextest@0.9.132
- name: Lint and archive host tests
run: just ci-host-build
- name: Upload host test archive
uses: actions/upload-artifact@v7
with:
name: host-tests
path: dist/host-tests/*
retention-days: 1
if-no-files-found: error
host-test:
name: host test
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [components, host-build]
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: nextest@0.9.132
- name: Download host test archive
uses: actions/download-artifact@v8
with:
name: host-tests
path: dist/host-tests
- name: Prepare WASM sidecar directory
run: rm -rf target/wasm32-wasip2/release
- name: Download WASM sidecar inputs
uses: actions/download-artifact@v8
with:
name: omnifs-wasm
path: target/wasm32-wasip2/release
- name: Cache wasmtime component compilations
# Wasmtime's on-disk cache is internally content-addressed (WASM hash +
# wasmtime version), so stale entries are harmless and won't be served
# to mismatched callers. GitHub caches are immutable, so use a unique
# write key but restore through a stable OS/arch namespace shared by
# push and pull_request runs.
uses: actions/cache@v5
with:
path: ~/.cache/wasmtime
key: wasmtime-cache-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
wasmtime-cache-${{ runner.os }}-${{ runner.arch }}-
wasmtime-cache-${{ runner.os }}-
- name: Run host tests
run: just ci-host-test
cli-linux-x64:
name: cli linux x64
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
CARGO_INCREMENTAL: "0"
CARGO_TARGET_DIR: ${{ github.workspace }}/target/cli-linux-x64
permissions:
contents: read
packages: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: ./.github/actions/omnifs-docker
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: cli-linux-x64
cache-on-failure: true
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- name: Build Linux x64 CLI
id: build
run: just ci-build-linux x86_64-unknown-linux-gnu.2.17
- name: Package Linux x64 CLI
run: just ci-package-cli linux-x64 "${{ steps.build.outputs.artifact }}"
- name: Attest Linux x64 CLI archive
if: env.CI_MAIN_PUSH == 'true'
uses: actions/attest-build-provenance@v4
with:
subject-path: dist/cli/linux-x64/omnifs-cli-linux-x64.tar.xz
- name: Upload Linux x64 CLI archive
uses: actions/upload-artifact@v7
with:
name: omnifs-cli-linux-x64
path: dist/cli/linux-x64/omnifs-cli-linux-x64.tar.xz*
retention-days: 90
if-no-files-found: error
cli-linux-arm64:
name: cli linux arm64
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: blacksmith-4vcpu-ubuntu-2404-arm
env:
CARGO_INCREMENTAL: "0"
CARGO_TARGET_DIR: ${{ github.workspace }}/target/cli-linux-arm64
permissions:
contents: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: cli-linux-arm64
cache-on-failure: true
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- name: Build Linux arm64 CLI
id: build
run: just ci-build-linux aarch64-unknown-linux-gnu.2.17
- name: Package Linux arm64 CLI
run: just ci-package-cli linux-arm64 "${{ steps.build.outputs.artifact }}"
- name: Attest Linux arm64 CLI archive
if: env.CI_MAIN_PUSH == 'true'
uses: actions/attest-build-provenance@v4
with:
subject-path: dist/cli/linux-arm64/omnifs-cli-linux-arm64.tar.xz
- name: Upload Linux arm64 CLI archive
uses: actions/upload-artifact@v7
with:
name: omnifs-cli-linux-arm64
path: dist/cli/linux-arm64/omnifs-cli-linux-arm64.tar.xz*
retention-days: 90
if-no-files-found: error
cli-darwin:
name: cli darwin
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
CARGO_INCREMENTAL: "0"
CARGO_TARGET_DIR: ${{ github.workspace }}/target/cli-darwin
permissions:
contents: read
packages: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: ./.github/actions/omnifs-docker
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: cli-darwin
cache-on-failure: true
cache-directories: .cache/darwin-rustup
- name: Build Darwin CLI binaries
id: build
env:
DARWIN_RUSTUP_HOME: ${{ github.workspace }}/.cache/darwin-rustup
run: just ci-build-darwin
- name: Package Darwin CLI archives
run: |
set -euo pipefail
just ci-package-cli darwin-x64 "${{ steps.build.outputs.x64_artifact }}"
just ci-package-cli darwin-arm64 "${{ steps.build.outputs.arm64_artifact }}"
- name: Attest Darwin CLI archives
if: env.CI_MAIN_PUSH == 'true'
uses: actions/attest-build-provenance@v4
with:
subject-path: dist/cli/*/omnifs-cli-*.tar.xz
- name: Upload Darwin x64 CLI archive
uses: actions/upload-artifact@v7
with:
name: omnifs-cli-darwin-x64
path: dist/cli/darwin-x64/omnifs-cli-darwin-x64.tar.xz*
retention-days: 90
if-no-files-found: error
- name: Upload Darwin arm64 CLI archive
uses: actions/upload-artifact@v7
with:
name: omnifs-cli-darwin-arm64
path: dist/cli/darwin-arm64/omnifs-cli-darwin-arm64.tar.xz*
retention-days: 90
if-no-files-found: error
docker-amd64:
name: docker amd64
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: ubuntu-latest
needs: [components, cli-linux-x64]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: ./.github/actions/omnifs-docker
- name: Download WASM components
uses: actions/download-artifact@v8
with:
name: omnifs-wasm
path: dist-wasm
- name: Download Linux x64 CLI archive
uses: actions/download-artifact@v8
with:
name: omnifs-cli-linux-x64
path: dist-cli
- name: Extract Linux x64 CLI binary
run: |
set -euo pipefail
mkdir -p dist-cli/bin
tar -C dist-cli/bin -xJf dist-cli/omnifs-cli-linux-x64.tar.xz
test -x dist-cli/bin/omnifs
- name: Build and push amd64 Docker image
id: docker
env:
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:docker-amd64-${{ github.sha }}
PLATFORM: linux/amd64
PUSH: "true"
OMNIFS_BINARY: ${{ github.workspace }}/dist-cli/bin/omnifs
OMNIFS_WASM_DIR: ${{ github.workspace }}/dist-wasm
run: just ci-build-runtime
- name: Export amd64 image digest
run: |
set -euo pipefail
digest="${{ steps.docker.outputs.digest }}"
test -n "$digest"
mkdir -p /tmp/digests
touch "/tmp/digests/${digest#sha256:}"
- name: Upload amd64 image digest
uses: actions/upload-artifact@v7
with:
name: docker-digest-amd64
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# The arm64 Docker build and smoke run on an arm64 runner so the image is
# assembled and smoked natively. amd64 uses ubuntu-latest for lower queue time.
docker-arm64:
name: docker arm64
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: blacksmith-4vcpu-ubuntu-2404-arm
needs: [components, cli-linux-arm64]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: ./.github/actions/omnifs-docker
- name: Download WASM components
uses: actions/download-artifact@v8
with:
name: omnifs-wasm
path: dist-wasm
- name: Download Linux arm64 CLI archive
uses: actions/download-artifact@v8
with:
name: omnifs-cli-linux-arm64
path: dist-cli
- name: Extract Linux arm64 CLI binary
run: |
set -euo pipefail
mkdir -p dist-cli/bin
tar -C dist-cli/bin -xJf dist-cli/omnifs-cli-linux-arm64.tar.xz
test -x dist-cli/bin/omnifs
- name: Build and push arm64 Docker image
id: docker
env:
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:docker-arm64-${{ github.sha }}
PLATFORM: linux/arm64
PUSH: "true"
OMNIFS_BINARY: ${{ github.workspace }}/dist-cli/bin/omnifs
OMNIFS_WASM_DIR: ${{ github.workspace }}/dist-wasm
run: just ci-build-runtime
- name: Export arm64 image digest
run: |
set -euo pipefail
digest="${{ steps.docker.outputs.digest }}"
test -n "$digest"
mkdir -p /tmp/digests
touch "/tmp/digests/${digest#sha256:}"
- name: Upload arm64 image digest
uses: actions/upload-artifact@v7
with:
name: docker-digest-arm64
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
smoke-amd64:
name: smoke amd64
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: ubuntu-latest
needs: docker-amd64
timeout-minutes: 30
permissions:
contents: read
packages: read
env:
CONTAINER: omnifs
IMAGE: ghcr.io/${{ github.repository }}:smoke
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: ./.github/actions/omnifs-docker
- name: Download amd64 image digest
uses: actions/download-artifact@v8
with:
name: docker-digest-amd64
path: /tmp/digests
- name: Pull the amd64 image and tag it for smoke
run: |
set -euo pipefail
digest_path=$(find /tmp/digests -mindepth 1 -maxdepth 1 -type f | head -n 1)
test -n "$digest_path"
digest_file="${digest_path##*/}"
ref="${REGISTRY}/${IMAGE_NAME}@sha256:${digest_file}"
docker pull "$ref"
docker tag "$ref" "$IMAGE"
- name: Run container smoke test
env:
GITHUB_TOKEN: ${{ github.token }}
run: just ci-smoke-container
smoke-arm64:
name: smoke arm64
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
(github.event.pull_request.user.login == 'raulk' ||
contains(github.event.pull_request.labels.*.name, 'ci-full')))
runs-on: blacksmith-4vcpu-ubuntu-2404-arm
needs: docker-arm64
timeout-minutes: 30
permissions:
contents: read
packages: read
env:
CONTAINER: omnifs
IMAGE: ghcr.io/${{ github.repository }}:smoke
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-just
- uses: ./.github/actions/omnifs-docker
- name: Download arm64 image digest
uses: actions/download-artifact@v8
with:
name: docker-digest-arm64
path: /tmp/digests
- name: Pull the arm64 image and tag it for smoke
run: |
set -euo pipefail
digest_path=$(find /tmp/digests -mindepth 1 -maxdepth 1 -type f | head -n 1)
test -n "$digest_path"
digest_file="${digest_path##*/}"
ref="${REGISTRY}/${IMAGE_NAME}@sha256:${digest_file}"
docker pull "$ref"
docker tag "$ref" "$IMAGE"
- name: Run container smoke test
env:
GITHUB_TOKEN: ${{ github.token }}
run: just ci-smoke-container
publish:
name: publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- preflight
- components
- host-build
- host-test
- cli-linux-x64
- cli-linux-arm64
- cli-darwin
- docker-amd64
- docker-arm64
- smoke-amd64
- smoke-arm64
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/omnifs-docker
- name: Download image digests
uses: actions/download-artifact@v8
with:
pattern: docker-digest-*
path: /tmp/digests
merge-multiple: true
- name: Publish multi-platform manifest
run: |
set -euo pipefail
refs=()
for digest_file in /tmp/digests/*; do
digest="${digest_file##*/}"
refs+=("${REGISTRY}/${IMAGE_NAME}@sha256:${digest}")
done
test "${#refs[@]}" -ge 2
tag="${REGISTRY}/${IMAGE_NAME}:sha-${GITHUB_SHA}"
docker buildx imagetools create -t "$tag" "${refs[@]}"
docker buildx imagetools inspect "$tag" > manifest.txt
grep -q 'Platform:.*linux/amd64' manifest.txt
grep -q 'Platform:.*linux/arm64' manifest.txt
awk '/^Digest:/ { print $2; exit }' manifest.txt > manifest-digest.txt
- name: Upload manifest digest
uses: actions/upload-artifact@v7
with:
name: docker-manifest-digest
path: |
manifest.txt
manifest-digest.txt
retention-days: 90
if-no-files-found: error