-
Notifications
You must be signed in to change notification settings - Fork 0
2541 lines (2515 loc) · 124 KB
/
Copy pathci.yml
File metadata and controls
2541 lines (2515 loc) · 124 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:
push:
branches: [main]
workflow_dispatch:
inputs:
release_sha:
description: Full 40-character source commit reachable from main
required: true
type: string
deploy_development:
description: Assume the application roles and mutate the development release
required: true
default: false
type: boolean
probe_development:
description: Assume application roles only for the non-mutating OIDC probe
required: true
default: false
type: boolean
operation:
description: Promote, roll back, or run the non-mutating post-bootstrap probe
required: true
default: promote
type: choice
options: [promote, rollback, probe]
failure_injection:
description: Controlled promotion-only failure drill; leave none for normal releases
required: true
default: none
type: choice
options: [none, migration, post_mutation_smoke]
reuse_existing_image:
description: Verify and reuse an already-published immutable image without Docker
required: true
default: false
type: boolean
published_image_record:
description: Compact non-secret published-image JSON; required only for reuse
required: false
type: string
prior_release_record:
description: Compact successful release JSON; empty only for first bootstrap
required: false
type: string
target_release_record:
description: Compact rollback-target release JSON; required for rollback
required: false
type: string
current_release_record:
description: Compact active release JSON; required for rollback
required: false
type: string
permissions:
contents: read
actions: read
concurrency:
group: website-development-release
cancel-in-progress: false
jobs:
resolve-release:
runs-on: ubuntu-latest
outputs:
release_sha: ${{ steps.release.outputs.release_sha }}
version: ${{ steps.release.outputs.version }}
constructed_at: ${{ steps.release.outputs.constructed_at }}
identity_schema: ${{ steps.release.outputs.identity_schema }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- run: uv sync --locked
- run: uv lock --check
- id: prior-source-identity
name: Restore the sealed source identity on a workflow rerun
if: github.run_attempt > 1 && (github.event_name != 'workflow_dispatch' || inputs.operation != 'probe')
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: release-source-identity-${{ github.run_id }}
path: .tmp/prior-release
- id: release
name: Validate immutable source selection
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_AFTER: ${{ github.event.after }}
INPUT_RELEASE_SHA: ${{ inputs.release_sha }}
INPUT_DEPLOY_DEVELOPMENT: ${{ inputs.deploy_development }}
INPUT_PROBE_DEVELOPMENT: ${{ inputs.probe_development }}
INPUT_OPERATION: ${{ inputs.operation }}
INPUT_FAILURE_INJECTION: ${{ inputs.failure_injection }}
INPUT_REUSE_EXISTING_IMAGE: ${{ inputs.reuse_existing_image }}
INPUT_PUBLISHED_IMAGE_RECORD: ${{ inputs.published_image_record }}
INPUT_PRIOR_RELEASE_RECORD: ${{ inputs.prior_release_record }}
INPUT_TARGET_RELEASE_RECORD: ${{ inputs.target_release_record }}
INPUT_CURRENT_RELEASE_RECORD: ${{ inputs.current_release_record }}
RELEASE_A_SHA: 0f0ae208526fa2e76848cf4f5a87bd4aa26687ec
RELEASE_B_SHA: e2b93beb1544170b6177ba55ea8fd6530b2e57a3
DEVELOPMENT_REPOSITORY_URI: ${{ vars.DEVELOPMENT_ECR_REPOSITORY_URI }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
set -euo pipefail
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
echo "Manual releases must use the reviewed main workflow" >&2
exit 1
fi
candidate="$INPUT_RELEASE_SHA"
case "$INPUT_REUSE_EXISTING_IMAGE" in
true|false) ;;
*) echo "reuse_existing_image must be true or false" >&2; exit 1 ;;
esac
case "$INPUT_FAILURE_INJECTION" in
none|migration|post_mutation_smoke) ;;
*) echo "Unsupported release failure injection" >&2; exit 1 ;;
esac
validate_release_record() {
uv run --frozen python -m deploy.legacy_development_compatibility \
release-record <<< "$1"
}
prior_source=""
if [[ -n "$INPUT_PRIOR_RELEASE_RECORD" ]]; then
validate_release_record "$INPUT_PRIOR_RELEASE_RECORD"
prior_source="$(jq -er '
select(type == "object") |
.source_sha |
select(type == "string" and test("^[0-9a-f]{40}$"))
' <<< "$INPUT_PRIOR_RELEASE_RECORD")"
fi
target_source=""
if [[ -n "$INPUT_TARGET_RELEASE_RECORD" ]]; then
validate_release_record "$INPUT_TARGET_RELEASE_RECORD"
target_source="$(jq -er '
select(type == "object") |
.source_sha |
select(type == "string" and test("^[0-9a-f]{40}$"))
' <<< "$INPUT_TARGET_RELEASE_RECORD")"
fi
current_source=""
if [[ -n "$INPUT_CURRENT_RELEASE_RECORD" ]]; then
validate_release_record "$INPUT_CURRENT_RELEASE_RECORD"
current_source="$(jq -er '
select(type == "object") |
.source_sha |
select(type == "string" and test("^[0-9a-f]{40}$"))
' <<< "$INPUT_CURRENT_RELEASE_RECORD")"
fi
if [[ "$INPUT_REUSE_EXISTING_IMAGE" == "true" ]]; then
if [[ -z "$INPUT_PUBLISHED_IMAGE_RECORD" ]]; then
echo "reuse requires a published-image record" >&2
exit 1
fi
elif [[ -n "$INPUT_PUBLISHED_IMAGE_RECORD" ]]; then
echo "published_image_record is accepted only when reuse_existing_image=true" >&2
exit 1
fi
if [[ "$INPUT_FAILURE_INJECTION" != "none" ]]; then
if [[ "$INPUT_OPERATION" != "promote" ]]; then
echo "Controlled failure injection is promotion-only" >&2
exit 1
fi
if [[ "$candidate" != "$RELEASE_B_SHA" ]]; then
echo "Controlled failure injection requires exact accepted release B" >&2
exit 1
fi
if [[ "$prior_source" != "$RELEASE_A_SHA" ]]; then
echo "Controlled failure injection requires exact accepted release A as prior" >&2
exit 1
fi
if [[ "$INPUT_FAILURE_INJECTION" == "post_mutation_smoke" && "$INPUT_REUSE_EXISTING_IMAGE" != "true" ]]; then
echo "The controlled B post-mutation failure must reuse the published B image" >&2
exit 1
fi
fi
if [[ "$INPUT_OPERATION" == "probe" ]]; then
if [[ "$INPUT_PROBE_DEVELOPMENT" != "true" || "$INPUT_DEPLOY_DEVELOPMENT" != "false" ]]; then
echo "Probe requires probe_development=true and deploy_development=false" >&2
exit 1
fi
if [[ "$INPUT_FAILURE_INJECTION" != "none" ]]; then
echo "Probe cannot inject a release failure" >&2
exit 1
fi
if [[ "$INPUT_REUSE_EXISTING_IMAGE" != "false" || -n "$INPUT_PUBLISHED_IMAGE_RECORD" || -n "$INPUT_PRIOR_RELEASE_RECORD" || -n "$INPUT_TARGET_RELEASE_RECORD" || -n "$INPUT_CURRENT_RELEASE_RECORD" ]]; then
echo "Probe accepts no image reuse or release record" >&2
exit 1
fi
elif [[ "$INPUT_PROBE_DEVELOPMENT" != "false" ]]; then
echo "probe_development is valid only for operation=probe" >&2
exit 1
fi
if [[ "$INPUT_OPERATION" == "rollback" ]]; then
if [[ -n "$INPUT_PRIOR_RELEASE_RECORD" ]]; then
echo "Rollback rejects the promotion prior-release input" >&2
exit 1
fi
if [[ "$INPUT_FAILURE_INJECTION" != "none" || "$INPUT_REUSE_EXISTING_IMAGE" != "true" ]]; then
echo "Rollback requires reuse with no failure injection" >&2
exit 1
fi
if [[ "$target_source" != "$candidate" || -z "$current_source" ]]; then
echo "Rollback records must identify the selected target and an active current release" >&2
exit 1
fi
if [[ "$candidate" == "$RELEASE_A_SHA" && "$current_source" != "$RELEASE_B_SHA" ]]; then
echo "The release-B-to-A drill requires exact accepted release B as current" >&2
exit 1
fi
fi
if [[ "$INPUT_OPERATION" == "promote" && ( -n "$INPUT_TARGET_RELEASE_RECORD" || -n "$INPUT_CURRENT_RELEASE_RECORD" ) ]]; then
echo "Promotion rejects rollback target/current inputs" >&2
exit 1
fi
if [[ "$INPUT_DEPLOY_DEVELOPMENT" == "true" && "$INPUT_OPERATION" == "promote" ]]; then
if [[ "$candidate" == "$RELEASE_A_SHA" ]]; then
if [[ "$INPUT_FAILURE_INJECTION" != "none" || -n "$prior_source" ]]; then
echo "Initial release A requires no prior release" >&2
exit 1
fi
elif [[ "$candidate" == "$RELEASE_B_SHA" ]]; then
if [[ "$prior_source" != "$RELEASE_A_SHA" ]]; then
echo "Every release B exercise requires exact accepted release A as prior" >&2
exit 1
fi
if [[ "$INPUT_FAILURE_INJECTION" != "migration" && "$INPUT_REUSE_EXISTING_IMAGE" != "true" ]]; then
echo "Every B run after its migration drill must reuse the published B image" >&2
exit 1
fi
fi
fi
else
candidate="$GITHUB_SHA"
if [[ "$EVENT_AFTER" != "$candidate" ]]; then
echo "Push after SHA does not match the workflow source" >&2
exit 1
fi
fi
if [[ ! "$candidate" =~ ^[0-9a-f]{40}$ ]]; then
echo "Release SHA must be exactly 40 lowercase hexadecimal characters" >&2
exit 1
fi
git fetch --no-tags origin refs/heads/main:refs/remotes/origin/main
if [[ "$EVENT_NAME" == "workflow_dispatch" && "$(git rev-parse HEAD)" != "$(git rev-parse refs/remotes/origin/main)" ]]; then
echo "Workflow controller is not the current main commit" >&2
exit 1
fi
if [[ "$EVENT_NAME" == "workflow_dispatch" && "$INPUT_OPERATION" == "probe" && "$candidate" != "$(git rev-parse HEAD)" ]]; then
echo "OIDC probes run only from the current main source" >&2
exit 1
fi
if ! git cat-file -e "${candidate}^{commit}"; then
echo "Release SHA is not an existing commit" >&2
exit 1
fi
if [[ "$(git rev-parse "${candidate}^{commit}")" != "$candidate" ]]; then
echo "Release SHA does not resolve exactly" >&2
exit 1
fi
if ! git merge-base --is-ancestor "$candidate" refs/remotes/origin/main; then
echo "Release SHA is not reachable from main" >&2
exit 1
fi
if [[ "$EVENT_NAME" != "workflow_dispatch" || "$INPUT_OPERATION" != "probe" ]]; then
mkdir -p .tmp/release
if (( RUN_ATTEMPT > 1 )); then
test -f .tmp/prior-release/source-identity.json
jq -e --arg sha "$candidate" '
type == "object" and
keys == ["constructed_at", "identity_schema", "source_sha", "version"] and
.source_sha == $sha and
(.identity_schema == 1 or .identity_schema == 2)
' .tmp/prior-release/source-identity.json > /dev/null
cp .tmp/prior-release/source-identity.json .tmp/release/source-identity.json
elif [[ "$EVENT_NAME" == "workflow_dispatch" && "$INPUT_REUSE_EXISTING_IMAGE" == "true" ]]; then
printf '%s\n' "$INPUT_PUBLISHED_IMAGE_RECORD" > .tmp/release/input-published-image.json
uv run --frozen python -m deploy.release_identity inspect-published \
--allow-legacy \
--record .tmp/release/input-published-image.json \
> .tmp/release/normalized-published-image.json
jq -e \
--arg source_sha "$candidate" \
--arg repository_uri "$DEVELOPMENT_REPOSITORY_URI" '
.source_sha == $source_sha and
.repository_uri == $repository_uri and
.platform == "linux/amd64" and
.user == "10001:10001" and
.image_digest != "sha256:1111111111111111111111111111111111111111111111111111111111111111" and
.image_digest != "sha256:0000000000000000000000000000000000000000000000000000000000000000"
' .tmp/release/normalized-published-image.json > /dev/null
jq -ceS '{identity_schema, version, source_sha, constructed_at}' \
.tmp/release/normalized-published-image.json \
> .tmp/release/source-identity.json
else
uv run --frozen python -m deploy.release_identity construct \
--source-sha "$candidate" \
--output .tmp/release/source-identity.json
fi
version="$(jq -er '.version' .tmp/release/source-identity.json)"
constructed_at="$(jq -r '.constructed_at // ""' .tmp/release/source-identity.json)"
identity_schema="$(jq -er '.identity_schema' .tmp/release/source-identity.json)"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "constructed_at=$constructed_at" >> "$GITHUB_OUTPUT"
echo "identity_schema=$identity_schema" >> "$GITHUB_OUTPUT"
fi
echo "release_sha=$candidate" >> "$GITHUB_OUTPUT"
- name: Preserve the one sealed source identity
if: github.run_attempt == 1 && (github.event_name != 'workflow_dispatch' || inputs.operation != 'probe')
uses: actions/upload-artifact@v4
with:
name: release-source-identity-${{ github.run_id }}
path: .tmp/release/source-identity.json
if-no-files-found: error
retention-days: 90
classification:
if: github.event_name != 'workflow_dispatch' || inputs.operation != 'probe'
needs: resolve-release
runs-on: ubuntu-latest
# Selection, history restoration, planning, and artifact upload normally finish
# in under a minute; keep the serialized release queue bounded if they wedge.
timeout-minutes: 10
outputs:
profile: ${{ steps.selection.outputs.profile }}
reason: ${{ steps.selection.outputs.reason }}
artifact_name: ${{ steps.selection.outputs.artifact_name }}
created_attempt: ${{ steps.selection.outputs.created_attempt }}
run_id: ${{ steps.selection.outputs.run_id }}
selection_sha256: ${{ steps.selection.outputs.selection_sha256 }}
verification_profile: ${{ steps.plan.outputs.profile }}
browser_profile: ${{ steps.plan.outputs.browser_profile }}
compatibility_mode: ${{ steps.plan.outputs.compatibility_mode }}
content_invariants_mode: ${{ steps.plan.outputs.content_invariants_mode }}
container_mode: ${{ steps.plan.outputs.container_mode }}
django_mode: ${{ steps.plan.outputs.django_mode }}
playwright_mode: ${{ steps.plan.outputs.playwright_mode }}
quality_mode: ${{ steps.plan.outputs.quality_mode }}
screenshots_mode: ${{ steps.plan.outputs.screenshots_mode }}
defaults:
run:
working-directory: .tmp/ci-controller
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
path: .tmp/ci-controller
- uses: actions/checkout@v4
with:
ref: ${{ needs.resolve-release.outputs.release_sha }}
path: .tmp/release-source
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- id: selection
name: Classify the complete source change safely
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_AFTER: ${{ github.event.after }}
INPUT_OPERATION: ${{ inputs.operation }}
RELEASE_SHA: ${{ needs.resolve-release.outputs.release_sha }}
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
CONTROLLER_SHA: ${{ github.sha }}
run: |
set -euo pipefail
mkdir -p .tmp/ci-selection
uv run --frozen python -m ci.classifier select \
--repository ../release-source \
--event "$EVENT_NAME" \
--base "$EVENT_BEFORE" \
--after "$EVENT_AFTER" \
--github-sha "$GITHUB_SHA" \
--release-sha "$RELEASE_SHA" \
--dispatch-operation "${INPUT_OPERATION:-}" \
--run-id "$RUN_ID" \
--created-attempt "$RUN_ATTEMPT" \
--controller-sha "$CONTROLLER_SHA" \
--source-after-sha "$EVENT_AFTER" \
--source-before-sha "$EVENT_BEFORE" \
--output .tmp/ci-selection/ci-selection.json \
--provenance-output .tmp/ci-selection/ci-selection-provenance.json \
--summary "$GITHUB_STEP_SUMMARY" \
--github-output "$GITHUB_OUTPUT"
- id: history
name: Restore bounded trusted verification evidence
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
uv run --frozen python -m ci.history \
--repository "$GITHUB_REPOSITORY" \
--token "$GITHUB_TOKEN" \
--workflow ci.yml \
--current-run-id "$GITHUB_RUN_ID" \
--output-directory .tmp/prior-evidence \
--history .tmp/ci-selection/evidence-history.json \
--github-output "$GITHUB_OUTPUT"
- id: plan
name: Build the versioned risk and evidence plan
run: |
set -euo pipefail
base="$(jq -er '.base // "null"' .tmp/ci-selection/ci-selection.json)"
head="$(jq -er .head .tmp/ci-selection/ci-selection.json)"
uv run --frozen python -m ci.verification plan \
--repository ../release-source \
--base "$base" --head "$head" \
--selection .tmp/ci-selection/ci-selection.json \
--evidence-directory .tmp/prior-evidence \
--history .tmp/ci-selection/evidence-history.json \
--consumer ci --release-requires-image \
--output .tmp/ci-selection/verification-plan.json \
--summary "$GITHUB_STEP_SUMMARY" \
--github-output "$GITHUB_OUTPUT"
- name: Record the classifier job's actual environment
run: |
set -euo pipefail
mkdir -p .tmp/ci-selection/components
uv run --frozen python -m ci.verification environment \
--plan .tmp/ci-selection/verification-plan.json --component selector \
--allow-hosted-runner-drift \
--output .tmp/ci-selection/components/selector-environment.json
uv run --frozen python -m ci.verification record \
--plan .tmp/ci-selection/verification-plan.json --component selector \
--result success --command "ci.classifier select and ci.verification plan" \
--origin-kind github_actions --repository-id "$GITHUB_REPOSITORY" \
--workflow .github/workflows/ci.yml --ref "$GITHUB_REF" \
--run-id "$GITHUB_RUN_ID" --run-attempt "$GITHUB_RUN_ATTEMPT" \
--job-id classification \
--artifact-id "ci-selection-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--artifact-root .tmp/ci-selection \
--execution-environment .tmp/ci-selection/components/selector-environment.json \
--allow-hosted-runner-drift \
--machine-output .tmp/ci-selection/verification-plan.json \
--output .tmp/ci-selection/components/selector-evidence.json
- name: Carry forward only evidence selected by the exact plan
run: |
uv run --frozen python -m ci.verification materialize-reuse \
--plan .tmp/ci-selection/verification-plan.json \
--evidence-directory .tmp/prior-evidence \
--output-directory .tmp/ci-selection/components-reused
- name: Preserve the machine-readable CI selection and plan
uses: actions/upload-artifact@v4
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/ci-selection
if-no-files-found: error
retention-days: 30
quality:
if: github.event_name != 'workflow_dispatch' || inputs.operation != 'probe'
needs: [resolve-release, classification]
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
# The versioned quality contract normally completes in under two minutes;
# retain setup and evidence-recording headroom without an unbounded queue.
timeout-minutes: 15
defaults:
run:
working-directory: .tmp/release-source
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.resolve-release.outputs.release_sha }}
path: .tmp/release-source
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
path: .tmp/ci-controller
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- name: Restore the reviewed verification plan
uses: actions/download-artifact@v4
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/verification-input
- run: uv sync --locked
- run: uv lock --check
- name: Run the current versioned quality contract against the selected release
working-directory: .tmp/ci-controller
run: |
set -euo pipefail
mkdir -p .tmp/components-quality
uv run --frozen python -m ci.quality_contract \
--repository ../release-source 2>&1 | \
tee .tmp/components-quality/quality-output.log
- name: Cancel remaining release jobs after a quality failure
if: failure()
env:
GH_TOKEN: ${{ github.token }}
run: gh run cancel --repo "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID"
- name: Run CI orchestration contract tests from the workflow controller
working-directory: .tmp/ci-controller
run: |
set -euo pipefail
mkdir -p .tmp/components-quality
make test-ci 2>&1 | tee .tmp/components-quality/evidence-validation-output.log
- name: Build exact pinned compatibility source inputs
if: needs.classification.outputs.compatibility_mode == 'rerun'
run: |
set -euo pipefail
uv run --frozen python scripts/build_pinned_legacy_sources.py
- name: Run the compatibility contract when selected
if: needs.classification.outputs.compatibility_mode == 'rerun'
run: |
set -euo pipefail
make compatibility-source-artifacts-check compatibility-artifacts-check \
check-links check-seo 2>&1 | \
tee ../ci-controller/.tmp/components-quality/compatibility-output.log
- name: Record quality-job evidence with its actual environment
if: always() && needs.classification.result == 'success'
working-directory: .tmp/ci-controller
env:
JOB_STATUS: ${{ job.status }}
COMPATIBILITY_MODE: ${{ needs.classification.outputs.compatibility_mode }}
CONTENT_INVARIANTS_MODE: ${{ needs.classification.outputs.content_invariants_mode }}
run: |
set -euo pipefail
mkdir -p .tmp/components-quality
for component in quality compatibility content_invariants evidence_validation; do
mode="rerun"
if [[ "$component" == "compatibility" ]]; then mode="$COMPATIBILITY_MODE"; fi
if [[ "$component" == "content_invariants" ]]; then mode="$CONTENT_INVARIANTS_MODE"; fi
if [[ "$mode" != "rerun" ]]; then continue; fi
command="$(jq -er --arg component "$component" \
'.components[$component].command' .tmp/verification-input/verification-plan.json)"
artifact_args=()
machine_output=".tmp/components-quality/$component-output.log"
if [[ "$component" == "evidence_validation" ]]; then
machine_output=.tmp/components-quality/evidence-validation-output.log
fi
if [[ "$component" == "content_invariants" ]]; then
uv run --frozen python -m ci.content_invariants \
--repository ../release-source \
--plan .tmp/verification-input/verification-plan.json \
--output .tmp/components-quality/content-invariants.json
artifact_args=(--artifact .tmp/components-quality/content-invariants.json)
machine_output=.tmp/components-quality/content-invariants.json
fi
environment=.tmp/components-quality/$component-environment.json
uv run --frozen python -m ci.verification environment \
--plan .tmp/verification-input/verification-plan.json \
--component "$component" --output "$environment" \
--allow-hosted-runner-drift
uv run --frozen python -m ci.verification record \
--plan .tmp/verification-input/verification-plan.json \
--component "$component" --result "$JOB_STATUS" --command "$command" \
--origin-kind github_actions --repository-id "$GITHUB_REPOSITORY" \
--workflow .github/workflows/ci.yml --ref "$GITHUB_REF" \
--run-id "$GITHUB_RUN_ID" --run-attempt "$GITHUB_RUN_ATTEMPT" \
--job-id quality \
--artifact-id "verification-component-quality-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--artifact-root .tmp/components-quality \
--execution-environment "$environment" \
--allow-hosted-runner-drift \
--machine-output "$machine_output" "${artifact_args[@]}" \
--output ".tmp/components-quality/$component-evidence.json"
done
- name: Preserve quality evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: verification-component-quality-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/components-quality
if-no-files-found: warn
retention-days: 30
django:
if: github.event_name != 'workflow_dispatch' || inputs.operation != 'probe'
needs: [resolve-release, classification]
runs-on: ubuntu-latest
# Recent complete and focused runs fit well inside this budget, including
# database setup and terminal evidence recording.
timeout-minutes: 30
env:
DJANGO_SETTINGS_MODULE: website.settings.test
defaults:
run:
working-directory: .tmp/release-source
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.resolve-release.outputs.release_sha }}
path: .tmp/release-source
fetch-depth: 0
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
path: .tmp/ci-controller
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- name: Restore the reviewed verification plan
uses: actions/download-artifact@v4
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/verification-input
- run: uv sync --locked
if: needs.classification.outputs.django_mode == 'rerun'
- run: uv lock --check
if: needs.classification.outputs.django_mode == 'rerun'
- name: Restore the reviewed CI selection
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/release-source/.tmp/ci-selection/current
- name: Restore attempt-one selection only for a reused classifier
if: github.run_attempt > 1 && needs.classification.outputs.created_attempt == '1'
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: ci-selection-${{ github.run_id }}-attempt-1
path: .tmp/release-source/.tmp/ci-selection/attempt-1
- name: Isolate classifier payloads for provenance resolution
working-directory: .tmp/ci-controller
run: |
set -euo pipefail
isolate_payload() {
source_directory="$1"
destination_directory="$2"
rm -rf "$destination_directory"
mkdir -p "$destination_directory"
for filename in ci-selection.json ci-selection-provenance.json; do
if [[ -f "$source_directory/$filename" ]]; then
cp "$source_directory/$filename" "$destination_directory/$filename"
fi
done
}
isolate_payload \
../release-source/.tmp/ci-selection/current \
../release-source/.tmp/ci-selection/current-payload
isolate_payload \
../release-source/.tmp/ci-selection/attempt-1 \
../release-source/.tmp/ci-selection/attempt-1-payload
- name: Resolve same-run classifier evidence
working-directory: .tmp/ci-controller
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_AFTER: ${{ github.event.after }}
RELEASE_SHA: ${{ needs.resolve-release.outputs.release_sha }}
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
CLASSIFIER_ATTEMPT: ${{ needs.classification.outputs.created_attempt }}
PROFILE: ${{ needs.classification.outputs.profile }}
REASON: ${{ needs.classification.outputs.reason }}
SELECTION_SHA256: ${{ needs.classification.outputs.selection_sha256 }}
run: >-
uv run --frozen python -m ci.provenance resolve
--current-directory ../release-source/.tmp/ci-selection/current-payload
--fallback-directory ../release-source/.tmp/ci-selection/attempt-1-payload
--run-id "$RUN_ID"
--current-attempt "$RUN_ATTEMPT"
--classifier-created-attempt "$CLASSIFIER_ATTEMPT"
--controller-sha "$GITHUB_SHA"
--release-sha "$RELEASE_SHA"
--event "$EVENT_NAME"
--source-after-sha "$EVENT_AFTER"
--source-before-sha "$EVENT_BEFORE"
--expected-profile "$PROFILE"
--expected-reason "$REASON"
--expected-selection-sha256 "$SELECTION_SHA256"
--output-directory ../release-source/.tmp/ci-selection/resolved
--rejection-output ../release-source/.tmp/ci-selection/resolved/ci-selection-resolution.json
- name: Validate the code-owned test selection
working-directory: .tmp/ci-controller
run: >-
uv run --frozen python -m ci.classifier validate
--input ../release-source/.tmp/ci-selection/resolved/ci-selection.json
- name: Run the selected or complete Django suite
if: needs.classification.outputs.django_mode == 'rerun'
env:
CI_SELECTION_PATH: .tmp/ci-selection/resolved/ci-selection.json
SELECTED_PROFILE: ${{ needs.classification.outputs.profile }}
run: |
set -euo pipefail
mkdir -p ../ci-controller/.tmp/components-django
exec > >(tee ../ci-controller/.tmp/components-django/django-output.log) 2>&1
case "$SELECTED_PROFILE" in
focused)
make test-ci-focused
;;
full)
make test-factories
make test-migrations
make test-django-full
;;
*)
echo "Classifier emitted an unsupported profile" >&2
exit 1
;;
esac
- name: Record Django evidence with the job's actual environment
if: >-
always() &&
needs.classification.result == 'success' &&
needs.classification.outputs.django_mode == 'rerun'
working-directory: .tmp/ci-controller
env:
JOB_STATUS: ${{ job.status }}
run: |
set -euo pipefail
mkdir -p .tmp/components-django
uv run --frozen python -m ci.verification environment \
--plan .tmp/verification-input/verification-plan.json \
--component django \
--allow-hosted-runner-drift \
--output .tmp/components-django/django-environment.json
uv run --frozen python -m ci.verification record \
--plan .tmp/verification-input/verification-plan.json \
--component django --result "$JOB_STATUS" \
--command "$(jq -er '.components.django.command' .tmp/verification-input/verification-plan.json)" \
--origin-kind github_actions --repository-id "$GITHUB_REPOSITORY" \
--workflow .github/workflows/ci.yml --ref "$GITHUB_REF" \
--run-id "$GITHUB_RUN_ID" --run-attempt "$GITHUB_RUN_ATTEMPT" \
--job-id django \
--artifact-id "verification-component-django-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--artifact-root .tmp/components-django \
--execution-environment .tmp/components-django/django-environment.json \
--allow-hosted-runner-drift \
--machine-output .tmp/components-django/django-output.log \
--output .tmp/components-django/django-evidence.json
- name: Preserve Django evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: verification-component-django-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/components-django
if-no-files-found: warn
retention-days: 30
playwright:
if: github.event_name != 'workflow_dispatch' || inputs.operation != 'probe'
needs: [resolve-release, classification]
runs-on: ubuntu-latest
# The verified full-profile suite currently takes 48m51s on the hosted
# runner (issue #206). Keep a bounded reserve above that measurement so a
# healthy release reaches ci-gate, while a wedged test still cannot hold
# the serialized release group for GitHub's 360-minute default (issue #193).
timeout-minutes: 60
env:
DJANGO_ALLOW_ASYNC_UNSAFE: "true"
DJANGO_SETTINGS_MODULE: website.settings.test
defaults:
run:
working-directory: .tmp/release-source
steps:
- uses: actions/checkout@v4
if: needs.classification.outputs.playwright_mode == 'rerun'
with:
ref: ${{ needs.resolve-release.outputs.release_sha }}
path: .tmp/release-source
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
path: .tmp/ci-controller
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- name: Restore the reviewed verification plan
uses: actions/download-artifact@v4
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/verification-input
- run: uv sync --locked
if: needs.classification.outputs.playwright_mode == 'rerun'
- run: uv lock --check
if: needs.classification.outputs.playwright_mode == 'rerun'
- run: uv run playwright install --with-deps chromium
if: needs.classification.outputs.playwright_mode == 'rerun'
- name: Run the selected browser profile
if: needs.classification.outputs.playwright_mode == 'rerun'
env:
BROWSER_PROFILE: ${{ needs.classification.outputs.browser_profile }}
run: |
set -euo pipefail
mkdir -p ../ci-controller/.tmp/components-playwright
case "$BROWSER_PROFILE" in
full) make test-playwright 2>&1 | \
tee ../ci-controller/.tmp/components-playwright/playwright-output.log ;;
core) make test-playwright-core 2>&1 | \
tee ../ci-controller/.tmp/components-playwright/playwright-output.log ;;
smoke) make test-playwright-smoke 2>&1 | \
tee ../ci-controller/.tmp/components-playwright/playwright-output.log ;;
*) echo "Unsupported browser profile: $BROWSER_PROFILE" >&2; exit 2 ;;
esac
- name: Record Playwright evidence with the job's actual environment
if: >-
always() &&
needs.classification.result == 'success' &&
needs.classification.outputs.playwright_mode == 'rerun'
working-directory: .tmp/ci-controller
env:
JOB_STATUS: ${{ job.status }}
run: |
set -euo pipefail
mkdir -p .tmp/components-playwright
uv run --frozen python -m ci.verification environment \
--plan .tmp/verification-input/verification-plan.json \
--component playwright \
--allow-hosted-runner-drift \
--output .tmp/components-playwright/playwright-environment.json
uv run --frozen python -m ci.verification record \
--plan .tmp/verification-input/verification-plan.json \
--component playwright --result "$JOB_STATUS" \
--command "$(jq -er '.components.playwright.command' .tmp/verification-input/verification-plan.json)" \
--origin-kind github_actions --repository-id "$GITHUB_REPOSITORY" \
--workflow .github/workflows/ci.yml --ref "$GITHUB_REF" \
--run-id "$GITHUB_RUN_ID" --run-attempt "$GITHUB_RUN_ATTEMPT" \
--job-id playwright \
--artifact-id "verification-component-playwright-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--artifact-root .tmp/components-playwright \
--execution-environment .tmp/components-playwright/playwright-environment.json \
--allow-hosted-runner-drift \
--machine-output .tmp/components-playwright/playwright-output.log \
--output .tmp/components-playwright/playwright-evidence.json
- name: Preserve Playwright evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: verification-component-playwright-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/components-playwright
if-no-files-found: warn
retention-days: 30
screenshots:
if: github.event_name != 'workflow_dispatch' || inputs.operation != 'probe'
needs: [resolve-release, classification]
runs-on: ubuntu-latest
# Same wedge guard as the playwright job: the capture runtime drives the same
# browser stack and shares the serialized release concurrency group (issue #193).
timeout-minutes: 30
env:
DJANGO_ALLOW_ASYNC_UNSAFE: "true"
DJANGO_SETTINGS_MODULE: website.settings.test
defaults:
run:
working-directory: .tmp/release-source
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.resolve-release.outputs.release_sha }}
path: .tmp/release-source
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
path: .tmp/ci-controller
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- name: Restore the reviewed verification plan
uses: actions/download-artifact@v4
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/verification-input
- name: Establish the release application environment
if: needs.classification.outputs.screenshots_mode == 'rerun'
run: uv sync --locked
- name: Establish the screenshot controller environment
if: needs.classification.outputs.screenshots_mode == 'rerun'
working-directory: .tmp/ci-controller
run: uv sync --locked
- name: Verify the release and controller lockfiles
if: needs.classification.outputs.screenshots_mode == 'rerun'
run: |
uv lock --check
(cd ../ci-controller && uv lock --check)
- name: Install the pinned Chromium browser
if: needs.classification.outputs.screenshots_mode == 'rerun'
working-directory: .tmp/ci-controller
run: uv run --frozen playwright install --with-deps chromium
- name: Migrate and capture with one owned SQLite runtime
if: needs.classification.outputs.screenshots_mode == 'rerun'
run: |
set -euo pipefail
mkdir -p ../ci-controller/.tmp/components-screenshots
uv run --frozen python -m ci.screenshot_runtime \
--repository . \
--controller-repository ../ci-controller \
--plan ../ci-controller/.tmp/verification-input/verification-plan.json \
--base-url http://127.0.0.1:8000 \
--output ../ci-controller/.tmp/components-screenshots \
--server-log ../ci-controller/.tmp/components-screenshots/server.log
- name: Record screenshot evidence with the job's actual environment
if: >-
always() &&
needs.classification.result == 'success' &&
needs.classification.outputs.screenshots_mode == 'rerun'
working-directory: .tmp/ci-controller
env:
JOB_STATUS: ${{ job.status }}
run: |
set -euo pipefail
mkdir -p .tmp/components-screenshots
uv run --frozen python -m ci.verification environment \
--plan .tmp/verification-input/verification-plan.json \
--component screenshots \
--allow-hosted-runner-drift \
--output .tmp/components-screenshots/screenshots-environment.json
artifact_args=()
for image in .tmp/components-screenshots/screenshots/*.png; do
artifact_args+=(--artifact "$image")
done
uv run --frozen python -m ci.verification record \
--plan .tmp/verification-input/verification-plan.json \
--component screenshots --result "$JOB_STATUS" \
--command "$(jq -er '.components.screenshots.command' .tmp/verification-input/verification-plan.json)" \
--origin-kind github_actions --repository-id "$GITHUB_REPOSITORY" \
--workflow .github/workflows/ci.yml --ref "$GITHUB_REF" \
--run-id "$GITHUB_RUN_ID" --run-attempt "$GITHUB_RUN_ATTEMPT" \
--job-id screenshots \
--artifact-id "verification-component-screenshots-$GITHUB_RUN_ID-attempt-$GITHUB_RUN_ATTEMPT" \
--artifact-root .tmp/components-screenshots \
--execution-environment .tmp/components-screenshots/screenshots-environment.json \
--allow-hosted-runner-drift \
--machine-output .tmp/components-screenshots/screenshots.json \
--screenshot .tmp/components-screenshots/screenshots.json \
"${artifact_args[@]}" \
--output .tmp/components-screenshots/screenshots-evidence.json
- name: Keep screenshot component successful when render inputs are unchanged
if: needs.classification.outputs.screenshots_mode != 'rerun'
run: echo "No render-impact changes; screenshot evidence is not applicable."
- name: Preserve screenshot evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: verification-component-screenshots-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/components-screenshots
if-no-files-found: warn
retention-days: 30
container:
if: github.event_name != 'workflow_dispatch' || inputs.operation != 'probe'
needs: [resolve-release, classification]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
path: .tmp/ci-controller
- uses: astral-sh/setup-uv@v6
with:
version: "0.10.11"
enable-cache: true
- name: Establish the locked controller environment
working-directory: .tmp/ci-controller
run: uv sync --locked
- name: Verify the controller lockfile
working-directory: .tmp/ci-controller
run: uv lock --check
- name: Restore the reviewed verification plan
uses: actions/download-artifact@v4
with:
name: ci-selection-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: .tmp/ci-controller/.tmp/verification-input
- id: image-cache
name: Restore the immutable tested-image cache for an automatic rerun
if: github.event_name == 'push' || inputs.reuse_existing_image == false
uses: actions/cache@v4
with:
path: .tmp/release-image.tar
key: tested-release-image-${{ needs.resolve-release.outputs.identity_schema }}-${{ needs.resolve-release.outputs.release_sha }}-${{ needs.resolve-release.outputs.version }}-${{ needs.resolve-release.outputs.constructed_at }}
- name: Reject a rerun when its immutable image cache is missing
if: >-
github.run_attempt > 1 &&
(github.event_name == 'push' || inputs.reuse_existing_image == false) &&
steps.image-cache.outputs.cache-hit != 'true'
run: |
echo "Automatic reruns may only restore and reverify the first attempt's tested image." >&2
exit 1
- name: Complete the container gate without Docker for immutable-image reuse
if: github.event_name == 'workflow_dispatch' && inputs.reuse_existing_image == true
env:
PUBLISHED_IMAGE_RECORD: ${{ inputs.published_image_record }}
run: |
set -euo pipefail
test -n "$PUBLISHED_IMAGE_RECORD"
mkdir -p .tmp/ci-controller/.tmp/components-container
printf '%s\n' published_image_record_supplied immutable_image_reuse_selected >> \
.tmp/ci-controller/.tmp/components-container/container-assertions.txt
- uses: actions/checkout@v4
if: >-
(github.event_name != 'workflow_dispatch' || inputs.reuse_existing_image == false) &&
steps.image-cache.outputs.cache-hit != 'true'