Repository navigation
2103 lines (1994 loc) · 76.3 KB
/
Copy pathci.yml
File metadata and controls
2103 lines (1994 loc) · 76.3 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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: CI
on:
# A pull request runs for any base, so that one stacked on another pull
# request's branch gets its own checks, and keeps them when GitHub retargets
# it to dev (doc/ci.md#stacked-pull-requests).
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
# The merge queue's groups of dev report the required check on the commit
# that the queue merges (doc/ci.md#merge-queue).
merge_group:
types:
- checks_requested
branches:
- dev
push:
branches:
- dev
schedule:
- cron: "17 5 * * *"
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && format('full-{0}', github.run_id) || github.event_name == 'merge_group' && format('merge-group-{0}', github.run_id) || github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# dev pushes wait in order instead of cancelling the run that waits. GitHub
# rejects queueing together with cancel-in-progress, so pull requests keep
# the single waiting run that a newer push replaces. Each merge group's run
# has a group of its own: a pull request that returns to the queue on the
# same base gets its earlier group's ref again, whose run must not hold the
# new one.
queue: ${{ github.event_name == 'pull_request' && 'single' || 'max' }}
permissions:
contents: read
env:
PERFORMANCE_BASELINE_WINDOW: 10
PERFORMANCE_BASELINE_MINIMUM_HISTORY: 10
PERFORMANCE_REGRESSION_THRESHOLD: 50
PERFORMANCE_REGRESSION_ABSOLUTE_TOLERANCE_MS: 10
jobs:
# The merge queue builds a pull request a new group whenever the queue ahead
# of it changes, as when a group ahead fails or dev changes outside the
# queue, and deletes the replaced group's branch but leaves its run running.
# Each group's run cancels the unfinished runs of its pull request's earlier
# groups, so that they free their runners (doc/ci.md#superseded-merge-groups).
# Nothing waits for it, so a failure only warns.
cancel-superseded-merge-groups:
name: Cancel superseded merge group runs
if: github.event_name == 'merge_group'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: write
contents: read
steps:
# The token can cancel any of the repository's runs, so the job runs the
# command that the group's base branch has merged rather than the
# group's copy. These steps still come from the group's ci.yml, though,
# so this is no isolation boundary (doc/ci.md, "Superseded merge
# groups").
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event.merge_group.base_ref }}
persist-credentials: false
- name: Cancel superseded merge group runs
shell: bash
env:
GH_TOKEN: ${{ github.token }}
MERGE_GROUP_REF: ${{ github.event.merge_group.head_ref }}
run: >-
python3 scripts/nvx.py cancel-superseded-merge-groups
--repository "${GITHUB_REPOSITORY}"
--workflow-ref "${GITHUB_WORKFLOW_REF}"
--run-id "${GITHUB_RUN_ID}"
--ref "${MERGE_GROUP_REF}"
--summary "${GITHUB_STEP_SUMMARY}"
quality:
name: Lint, typing, and formatting
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
# Scheduled and manually dispatched full runs save no caches, and neither
# do merge groups, whose entries no other run could restore.
- name: Check code quality
uses: ./.github/actions/check-quality
with:
save-cache: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
nvx-rs:
name: nvx-rs / ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Check nvx-rs
uses: ./.github/actions/check-nvx-rs
# The microVM tests run their microVMs and sandboxes with nvx-rs, and every
# release package ships it, so one GitHub-hosted job per OS builds it, as the
# OpenVMM producers build OpenVMM, and hands it to the microVM and package
# jobs of its OS as soon as it is built, and to the NVX CLI job of its OS,
# which tests with it (doc/ci.md#job-graph-and-runner-capacity). The jobs
# that it feeds run only for pushes, merge groups, full runs, and
# same-repository pull requests, so it does too.
build-nvx-rs-linux-musl:
name: nvx-rs binary / Linux musl
if: >-
${{
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
# The release that the self-hosted runners provide.
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# A static musl build runs on every self-hosted Linux runner. It goes
# where `cargo build --release` puts it, where nvx.py looks for it.
- name: Build nvx-rs
shell: bash
run: |
set -euo pipefail
toolchain=$(sed -n 's/^channel = "\([^"]*\)".*/\1/p' rust-toolchain.toml)
test -n "${toolchain}"
rustup toolchain install "${toolchain}" --profile minimal --no-self-update \
--target x86_64-unknown-linux-musl
cargo "+${toolchain}" build --release --locked --features cli \
--manifest-path nvx-rs/Cargo.toml --target x86_64-unknown-linux-musl
install -D -m 0755 nvx-rs/target/x86_64-unknown-linux-musl/release/nvx-rs \
nvx-rs/target/release/nvx-rs
# Packages ship the build with its provenance, which binds it to the
# nvx-rs sources, the pinned Rust release, the target, and the features.
- name: Record nvx-rs provenance
shell: bash
run: >-
python3 scripts/nvx.py record-nvx-rs-provenance
--target x86_64-unknown-linux-musl
- name: Upload nvx-rs executable
uses: actions/upload-artifact@v7
with:
name: nvx-rs-linux-musl-executable
path: nvx-rs/target/release/nvx-rs
if-no-files-found: error
overwrite: true
retention-days: 1
- name: Upload nvx-rs provenance
uses: actions/upload-artifact@v7
with:
name: nvx-rs-linux-musl-provenance
path: build/nvx-rs.provenance.json
if-no-files-found: error
overwrite: true
retention-days: 1
build-nvx-rs-windows-msvc:
name: nvx-rs binary / Windows MSVC
if: >-
${{
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}
runs-on: windows-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
# The release that the self-hosted runners provide.
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# The next step builds nvx-rs with the release that rust-toolchain.toml
# pins, which rustup would otherwise install with its default profile.
- name: Install the pinned Rust release
shell: powershell
run: |
$ErrorActionPreference = "Stop"
$channel = Select-String -LiteralPath "rust-toolchain.toml" `
-Pattern '^channel = "([^"]+)"' | Select-Object -First 1
if ($null -eq $channel) {
throw "rust-toolchain.toml does not pin a Rust release"
}
rustup toolchain install $channel.Matches[0].Groups[1].Value `
--profile minimal --no-self-update
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# As on Linux. The static C runtime spares the self-hosted runners the
# Visual C++ redistributable.
- name: Build nvx-rs
shell: powershell
env:
RUSTFLAGS: -C target-feature=+crt-static
run: |
$ErrorActionPreference = "Stop"
cargo build --release --locked --features cli --manifest-path nvx-rs/Cargo.toml
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Record nvx-rs provenance
shell: powershell
run: |
python scripts\nvx.py record-nvx-rs-provenance --target x86_64-pc-windows-msvc
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Upload nvx-rs executable
uses: actions/upload-artifact@v7
with:
name: nvx-rs-windows-msvc-executable
path: nvx-rs/target/release/nvx-rs.exe
if-no-files-found: error
overwrite: true
retention-days: 1
- name: Upload nvx-rs provenance
uses: actions/upload-artifact@v7
with:
name: nvx-rs-windows-msvc-provenance
path: build/nvx-rs.provenance.json
if-no-files-found: error
overwrite: true
retention-days: 1
# The NVX CLI tests do not depend on the backend, so they run once per OS on
# GitHub-hosted runners rather than in every hypervisor job, with the nvx-rs
# that the microVM jobs of the OS run. They read OpenVMM's pinned CPU
# profiles from the submodule, so they follow its checkout, which needs the
# deploy key that fork pull requests lack.
nvx-cli-linux:
name: NVX CLI / Linux
needs: [build-nvx-rs-linux-musl]
if: >-
${{
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}
runs-on: ubuntu-latest
timeout-minutes: 15
# The build that the microVM jobs run, which a step below downloads where
# `cargo build --release` puts it, and where nvx.py, and so the CLI tests,
# look for it, named for the tests that run it directly.
env:
NVX_RS: ${{ github.workspace }}/nvx-rs/target/release/nvx-rs
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Checkout OpenVMM
uses: ./.github/actions/checkout-openvmm
with:
ssh-key: ${{ secrets.OPENVMM_DEPLOY_KEY }}
# The release that the self-hosted runners provide.
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# The steps that compare OpenVMM's data test nvx-rs with Cargo, with the
# release that rust-toolchain.toml pins, which rustup would otherwise
# install with its default profile.
- name: Install the pinned Rust release
shell: bash
run: |
set -euo pipefail
toolchain=$(sed -n 's/^channel = "\([^"]*\)".*/\1/p' rust-toolchain.toml)
test -n "${toolchain}"
rustup toolchain install "${toolchain}" --profile minimal --no-self-update
- name: Download nvx-rs executable
uses: actions/download-artifact@v8
with:
name: nvx-rs-linux-musl-executable
path: nvx-rs/target/release
- name: Download nvx-rs provenance
uses: actions/download-artifact@v8
with:
name: nvx-rs-linux-musl-provenance
path: build
- name: Make nvx-rs executable
shell: bash
run: chmod +x nvx-rs/target/release/nvx-rs
- name: Validate NVX CLI
uses: ./.github/actions/validate-nvx
# nvx-rs's protocol and template tests read copies of OpenVMM's
# control-session protocol vectors and of the lines of its platform
# allowlist, because the nvx-rs job cannot check out OpenVMM. This job
# can, so it compares the copies with the submodule's files, and
# nvx::contract's versions of OpenVMM's contracts with OpenVMM's.
- name: Compare OpenVMM's protocol vectors
shell: bash
run: >-
cargo test --locked --manifest-path nvx-rs/Cargo.toml
--no-default-features --test openvmm_vectors -- --ignored
# nvx-rs run reads a copy of the identities of OpenVMM's built-in CPU
# profiles, to guide a failed cold boot on a CPU that none serves, which
# this job compares with the submodule's profiles as it does the vectors.
- name: Compare OpenVMM's CPU profiles
shell: bash
run: >-
cargo test --locked --manifest-path nvx-rs/Cargo.toml
--no-default-features --test openvmm_cpu_profiles -- --ignored
nvx-cli-windows:
name: NVX CLI / Windows
needs: [build-nvx-rs-windows-msvc]
if: >-
${{
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}
runs-on: windows-latest
timeout-minutes: 15
# As on Linux.
env:
NVX_RS: ${{ github.workspace }}\nvx-rs\target\release\nvx-rs.exe
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Checkout OpenVMM
uses: ./.github/actions/checkout-openvmm
with:
ssh-key: ${{ secrets.OPENVMM_DEPLOY_KEY }}
# The release that the self-hosted runners provide.
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# The curl shim test compiles the shim, and the steps that compare
# OpenVMM's data test nvx-rs with Cargo, with the release that
# rust-toolchain.toml pins, which rustup would otherwise install with its
# default profile.
- name: Install the pinned Rust release
shell: powershell
run: |
$ErrorActionPreference = "Stop"
$channel = Select-String -LiteralPath "rust-toolchain.toml" `
-Pattern '^channel = "([^"]+)"' | Select-Object -First 1
if ($null -eq $channel) {
throw "rust-toolchain.toml does not pin a Rust release"
}
rustup toolchain install $channel.Matches[0].Groups[1].Value `
--profile minimal --no-self-update
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Download nvx-rs executable
uses: actions/download-artifact@v8
with:
name: nvx-rs-windows-msvc-executable
path: nvx-rs/target/release
- name: Download nvx-rs provenance
uses: actions/download-artifact@v8
with:
name: nvx-rs-windows-msvc-provenance
path: build
- name: Validate NVX CLI
uses: ./.github/actions/validate-nvx
# As on Linux.
- name: Compare OpenVMM's protocol vectors
shell: powershell
run: |
$ErrorActionPreference = "Stop"
cargo test --locked --manifest-path nvx-rs/Cargo.toml --no-default-features `
--test openvmm_vectors -- --ignored
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# As on Linux.
- name: Compare OpenVMM's CPU profiles
shell: powershell
run: |
$ErrorActionPreference = "Stop"
cargo test --locked --manifest-path nvx-rs/Cargo.toml --no-default-features `
--test openvmm_cpu_profiles -- --ignored
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
openvmm-changes:
name: Detect CI workload inputs
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
run-guest-artifacts: ${{ steps.changes.outputs.run-guest-artifacts }}
run-openvmm-binaries: ${{ steps.changes.outputs.run-openvmm-binaries }}
run-openvmm-ci-check: ${{ steps.changes.outputs.run-openvmm-ci-check }}
run-microvm-tests: ${{ steps.changes.outputs.run-microvm-tests }}
run-benchmarks: ${{ steps.changes.outputs.run-benchmarks }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: false
# `nvx.py classify-ci-changes` selects the suites for pushes, pull
# requests, and merge groups; this script selects the full matrix for
# full-run events and whenever it cannot classify changed files. A merge
# group compares its head, GITHUB_SHA, with the commit on which the
# queue built it: the latest dev, or the group of the pull request ahead
# of it, which checks that pull request's change.
- name: Detect relevant changes
id: changes
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: >-
${{
github.event_name == 'pull_request' && github.event.pull_request.base.sha ||
github.event_name == 'merge_group' && github.event.merge_group.base_sha ||
github.event.before
}}
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
run: |
set -euo pipefail
outputs=(
run-guest-artifacts run-openvmm-binaries run-openvmm-ci-check
run-microvm-tests run-benchmarks
)
run_everything() {
for output in "${outputs[@]}"; do
echo "${output}=true" >> "${GITHUB_OUTPUT}"
done
{
echo "### Full matrix: run"
echo "$1"
} >> "${GITHUB_STEP_SUMMARY}"
}
if [[ "${EVENT_NAME}" == "schedule" ||
"${EVENT_NAME}" == "workflow_dispatch" ]]; then
run_everything "The ${EVENT_NAME} event runs the full matrix without change classification."
exit 0
fi
if [[ -z "${BASE_SHA}" || "${BASE_SHA}" =~ ^0+$ ]]; then
run_everything "The comparison base is unavailable, so the safe fallback is to run the full matrix."
exit 0
fi
if ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null ||
! git cat-file -e "${HEAD_SHA}^{commit}" 2>/dev/null; then
run_everything "A comparison commit is unavailable, so the safe fallback is to run the full matrix."
exit 0
fi
changed_files="${RUNNER_TEMP}/ci-changed-files"
if ! git diff --name-only --no-renames -z "${BASE_SHA}" "${HEAD_SHA}" > "${changed_files}"; then
run_everything "The changed files could not be determined, so the safe fallback is to run the full matrix."
exit 0
fi
echo "Changes between \`${BASE_SHA}\` and \`${HEAD_SHA}\`:" >> "${GITHUB_STEP_SUMMARY}"
classification="${RUNNER_TEMP}/ci-classification"
if ! python3 scripts/nvx.py classify-ci-changes \
--event-name "${EVENT_NAME}" \
--changed-files "${changed_files}" --null \
--summary "${GITHUB_STEP_SUMMARY}" > "${classification}"; then
run_everything "The changes could not be classified, so the safe fallback is to run the full matrix."
exit 0
fi
# A missing or malformed output would silently skip its suites.
for output in "${outputs[@]}"; do
if [[ "$(grep -Ecx "${output}=(true|false)" "${classification}")" != 1 ]]; then
run_everything "The classification did not report \`${output}\`, so the safe fallback is to run the full matrix."
exit 0
fi
done
grep -Ex '[a-z-]+=(true|false)' "${classification}" >> "${GITHUB_OUTPUT}"
# The kernel and the Alpine initramfs, which every job that boots a guest
# reads, build beside the Ubuntu and Azure Linux images, which only the
# microVM test and package jobs read, so that a rebuild of those images
# delays neither the default microVM suite nor the debug-kernel jobs.
artifacts:
name: Build kernel and Alpine artifacts
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-guest-artifacts == 'true'
)
}}
runs-on: ubuntu-latest
timeout-minutes: 60
# A push or a merge group reads its pull request's runs and downloads their
# artifacts.
permissions:
actions: read
contents: read
outputs:
guest-cache-keys: ${{ steps.guest-artifacts.outputs.cache-keys }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
# Full runs and merge groups build the guest artifacts that miss the
# cache without saving them. A push or a merge group installs those that
# its pull request's latest run built instead, when they check out.
- name: Build guest artifacts
id: guest-artifacts
uses: ./.github/actions/build-guest-artifacts
with:
components: kernel alpine
save-cache: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
record-artifact: kernel-alpine-record
reuse: ${{ github.event_name == 'merge_group' || github.event_name == 'push' }}
# One artifact per component, so that each job downloads only the
# components that it reads (doc/ci.md, "Guest artifact handoff").
- name: Upload guest kernel
uses: actions/upload-artifact@v7
with:
name: guest-kernel
path: |
build/vmlinux
build/vmlinux.config
build/vmlinux.provenance.json
if-no-files-found: error
retention-days: 1
- name: Upload Alpine initramfs
uses: actions/upload-artifact@v7
with:
name: guest-alpine
path: |
build/initramfs.cpio.gz
build/initramfs.cpio.gz.packages.json
build/initramfs.provenance.json
if-no-files-found: error
retention-days: 1
distro-artifacts:
name: Build Ubuntu and Azure Linux artifacts
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-guest-artifacts == 'true'
)
}}
runs-on: ubuntu-latest
timeout-minutes: 60
# A push or a merge group reads its pull request's runs and downloads their
# artifacts.
permissions:
actions: read
contents: read
outputs:
guest-cache-keys: ${{ steps.guest-artifacts.outputs.cache-keys }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
# Full runs and merge groups build the guest artifacts that miss the
# cache without saving them. A push or a merge group installs those that
# its pull request's latest run built instead, when they check out.
- name: Build guest artifacts
id: guest-artifacts
uses: ./.github/actions/build-guest-artifacts
with:
components: ubuntu azurelinux
save-cache: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
record-artifact: ubuntu-azurelinux-record
reuse: ${{ github.event_name == 'merge_group' || github.event_name == 'push' }}
- name: Upload Ubuntu initramfs
uses: actions/upload-artifact@v7
with:
name: guest-ubuntu
path: |
build/initramfs-ubuntu.cpio.gz
build/initramfs-ubuntu.cpio.gz.packages.json
if-no-files-found: error
retention-days: 1
- name: Upload Ubuntu distro layer
uses: actions/upload-artifact@v7
with:
name: guest-ubuntu-distro
path: |
build/ubuntu-distro.erofs
build/ubuntu-distro.erofs.manifest.json
build/ubuntu-smoke-scratch.ext4
if-no-files-found: error
retention-days: 1
- name: Upload Azure Linux initramfs
uses: actions/upload-artifact@v7
with:
name: guest-azurelinux
path: |
build/initramfs-azurelinux.cpio.gz
build/initramfs-azurelinux.cpio.gz.packages.json
if-no-files-found: error
retention-days: 1
# The Windows guest and sandbox job runs the runtime adapter's scenarios
# with its guest agent, a static musl executable that Linux builds, as
# it builds the images that the job reads. The Linux jobs build their
# own.
- name: Build the runtime adapter's guest agent
shell: bash
working-directory: tests/runtime-adapter
run: |
set -euo pipefail
toolchain=$(sed -n 's/^channel = "\([^"]*\)".*/\1/p' ../../rust-toolchain.toml)
test -n "${toolchain}"
rustup toolchain install "${toolchain}" --profile minimal --no-self-update \
--target x86_64-unknown-linux-musl
cargo "+${toolchain}" build --locked --release --features guest \
--target x86_64-unknown-linux-musl --bin runtime-adapter-guest
- name: Upload the runtime adapter's guest agent
uses: actions/upload-artifact@v7
with:
name: runtime-adapter-guest
path: tests/runtime-adapter/target/x86_64-unknown-linux-musl/release/runtime-adapter-guest
if-no-files-found: error
retention-days: 1
# A dev push and a merge group reuse the guest artifact components that the
# pull request that they merge built (see build-guest-artifacts). A
# same-repository pull request rehearses that selection and check on the
# artifacts that its own run uploaded, beside the jobs that use them, and
# installs nothing; its merge group doesn't rehearse them again.
guest-artifact-reuse:
name: Rehearse guest artifact reuse
needs: [openvmm-changes, artifacts, distro-artifacts]
if: >-
${{
always() &&
!cancelled() &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
needs.artifacts.result == 'success' &&
needs.distro-artifacts.result == 'success' &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-guest-artifacts == 'true'
)
}}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Rehearse kernel and Alpine artifact reuse
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GUEST_CACHE_KEYS: ${{ needs.artifacts.outputs.guest-cache-keys }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: >-
python3 scripts/nvx.py reuse-guest-artifacts --dry-run
--repository "${GITHUB_REPOSITORY}"
--workflow-ref "${GITHUB_WORKFLOW_REF}"
--head-sha "${HEAD_SHA}"
--components "kernel alpine"
--record-artifact kernel-alpine-record
--keys "${GUEST_CACHE_KEYS}"
- name: Rehearse Ubuntu and Azure Linux artifact reuse
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GUEST_CACHE_KEYS: ${{ needs.distro-artifacts.outputs.guest-cache-keys }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: >-
python3 scripts/nvx.py reuse-guest-artifacts --dry-run
--repository "${GITHUB_REPOSITORY}"
--workflow-ref "${GITHUB_WORKFLOW_REF}"
--head-sha "${HEAD_SHA}"
--components "ubuntu azurelinux"
--record-artifact ubuntu-azurelinux-record
--keys "${GUEST_CACHE_KEYS}"
# Beside the shared artifacts, so that a kernel rebuild doesn't delay the
# jobs that don't use the debug kernel.
debug-kernel:
name: Build CI debug kernel
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-guest-artifacts == 'true'
)
}}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Build the CI debug kernel
uses: ./.github/actions/build-guest-artifacts
with:
components: debug-kernel
save-cache: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
- name: Upload guest debug kernel
uses: actions/upload-artifact@v7
with:
name: guest-debug-kernel
path: |
build/vmlinux-debug
build/vmlinux-debug.config
build/vmlinux-debug.provenance.json
if-no-files-found: error
retention-days: 1
build-openvmm-linux-gnu:
name: OpenVMM binary / Linux GNU
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-openvmm-binaries == 'true'
)
}}
uses: ./.github/workflows/build-openvmm-binary.yml
with:
display-name: Linux GNU
runner: '["self-hosted", "linux", "kvm", "virtual-machine", "general"]'
backend: kvm
artifact: openvmm-linux-gnu
binary: openvmm/target/release/openvmm
secrets:
OPENVMM_DEPLOY_KEY: ${{ secrets.OPENVMM_DEPLOY_KEY }}
build-openvmm-linux-musl:
name: OpenVMM binary / Linux musl
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-openvmm-binaries == 'true'
)
}}
uses: ./.github/workflows/build-openvmm-binary.yml
with:
display-name: Linux musl
runner: '["self-hosted", "linux", "mshv", "virtual-machine", "general"]'
backend: mshv
artifact: openvmm-linux-musl
binary: openvmm/target/release/openvmm
secrets:
OPENVMM_DEPLOY_KEY: ${{ secrets.OPENVMM_DEPLOY_KEY }}
build-openvmm-windows-msvc:
name: OpenVMM binary / Windows MSVC
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-openvmm-binaries == 'true'
)
}}
uses: ./.github/workflows/build-openvmm-binary.yml
with:
display-name: Windows MSVC
runner: '["self-hosted", "windows", "whp", "virtual-machine", "general"]'
backend: whp
artifact: openvmm-windows-msvc
binary: openvmm/target/release/openvmm.exe
secrets:
OPENVMM_DEPLOY_KEY: ${{ secrets.OPENVMM_DEPLOY_KEY }}
# OpenVMM's own checkin gates test the revision that NVX pins, on each pull
# request into feature/microvm/dev and on each push to it, so CI runs none of
# OpenVMM's tests: this job checks that those gates passed the jobs that
# cover NVX's use of OpenVMM for the pinned revision (doc/ci.md#openvmm-ci).
# It reads only the public OpenVMM repository's runs, so it needs neither an
# OpenVMM checkout nor a deploy key, and a pull request from a fork runs it
# too. A pull request or a manual run waits while the gates still run, so
# that a pin promotion passes once OpenVMM's CI does. Every other event
# checks a pin that passed the check before it merged, so it fails at once
# rather than hold up the dev pushes and merge groups that queue behind it.
openvmm-ci:
name: OpenVMM CI of the pinned revision
needs: [openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-openvmm-ci-check == 'true'
)
}}
runs-on: ubuntu-latest
timeout-minutes: 320
steps:
- name: Checkout
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Check OpenVMM's CI of the pinned revision
shell: bash
env:
GH_TOKEN: ${{ github.token }}
WAIT_MINUTES: >-
${{
(
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch'
) && '300' || '0'
}}
run: >-
python3 scripts/nvx.py check-openvmm-ci
--wait-minutes "${WAIT_MINUTES}"
--summary "${GITHUB_STEP_SUMMARY}"
# Each backend runs its default suite in parallel shards of about equal
# duration, one leg of this matrix each, as
# scripts/nvx_tools/microvm_shards.json splits it
# (doc/ci.md#microvm-test-shards). A shard fails unless that file puts every
# default scenario in exactly one shard of every backend and splits this
# backend's suite into as many shards as the matrix runs. The job's result,
# which the required status check, the release, and the performance
# persistence read, succeeds only when every shard does.
nvx-microvm-tests-kvm:
name: NVX microVM tests / Linux / KVM / Shard ${{ matrix.shard }} of ${{ strategy.job-total }}
needs: [artifacts, build-openvmm-linux-gnu, build-nvx-rs-linux-musl, openvmm-changes]
if: >-
${{
always() &&
!cancelled() &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.draft == false
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
) &&
needs.artifacts.result == 'success' &&
needs.build-openvmm-linux-gnu.result == 'success' &&
needs.build-nvx-rs-linux-musl.result == 'success' &&
(
needs.openvmm-changes.result != 'success' ||
needs.openvmm-changes.outputs.run-microvm-tests == 'true'
)
}}
strategy:
fail-fast: false
matrix:
shard: [1, 2]
uses: ./.github/workflows/run-nvx-microvm-tests.yml
with:
display-name: Linux / KVM / Shard ${{ matrix.shard }} of ${{ strategy.job-total }}