Repository navigation
1205 lines (1156 loc) · 46.9 KB
/
Copy pathci.yml
File metadata and controls
1205 lines (1156 loc) · 46.9 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]
pull_request:
branches: [main]
workflow_dispatch: {}
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
markup-lint:
name: Markup
uses: ./.github/workflows/reusable-markup-lint.yml
static-checks:
name: "Test / Static checks of the actions and workflows"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run actionlint, shellcheck and the conventions of this repository
run: test/run_static_checks.sh
test-terraform-setup:
name: "Test / Terraform setup action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install terraform
uses: ./actions/terraform/setup
- name: Verify terraform is installed
run: |
terraform version
command -v terraform
test-tflint-setup:
name: "Test / TFLint setup action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup TFLint
uses: ./actions/tflint/setup
- name: Verify tflint is installed
run: |
tflint --version
command -v tflint
test-setup-versions:
name: "Test / Setup actions install the version asked for"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install terraform
uses: ./actions/terraform/setup
with:
terraform-version: 1.9.8
- name: Setup TFLint
uses: ./actions/tflint/setup
with:
tflint-version: v0.53.0
- name: Setup Helm
uses: ./actions/helm/setup
with:
helm-version: v3.16.4
- name: Setup Task
uses: ./actions/task/setup
with:
task-version: v3.52.0
- name: Setup kubeconform
uses: ./actions/kubeconform/setup
with:
kubeconform-version: v0.7.0
- name: Setup kind
uses: ./actions/kind/setup
with:
kind-version: v0.32.0
kubectl-version: v1.36.4
- name: Verify the versions
run: |
# Compared once captured, since a reader closing the pipe early fails the step with SIGPIPE under pipefail.
[[ "$(terraform version)" == "Terraform v1.9.8"* ]]
[[ "$(tflint --version)" == *"version 0.53.0"* ]]
[[ "$(helm version --short)" == v3.16.4+* ]]
[[ "$(task --version)" == *3.52.0* ]]
[[ "$(kubeconform -v)" == v0.7.0 ]]
[[ "$(kind version)" == "kind v0.32.0 "* ]]
[[ "$(kubectl version --client)" == *"v1.36.4"* ]]
# A setup action that cannot verify what it downloaded stops the job rather than running it.
test-setup-fails-closed:
name: "Test / Setup actions fail on a missing release or a wrong checksum"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install a terraform release that does not exist
id: terraform-missing-release
continue-on-error: true
uses: ./actions/terraform/setup
with:
terraform-version: 0.0.0
- name: Install a Trivy release that does not exist
id: trivy-missing-release
continue-on-error: true
uses: ./actions/trivy/scan
with:
trivy-version: 0.0.0
scan-type: config
target: test/fixtures/terraform
- name: Install a Cosign release that does not exist
id: cosign-missing-release
continue-on-error: true
uses: ./actions/cosign/sign
with:
cosign-version: v0.0.0
image-name: busybox
image-path: docker.io/library
image-tag: "1.37"
readonly: "true"
- name: Install a Task release that does not exist
id: task-missing-release
continue-on-error: true
uses: ./actions/task/setup
with:
task-version: v0.0.0
- name: Install kube-linter with a checksum that does not match
id: kube-linter-wrong-checksum
continue-on-error: true
uses: ./actions/kube-linter/setup
with:
kube-linter-sha256: "0000000000000000000000000000000000000000000000000000000000000000"
- name: Install Opengrep with a checksum that does not match
id: opengrep-wrong-checksum
continue-on-error: true
uses: ./actions/opengrep/setup
with:
opengrep-sha256: "0000000000000000000000000000000000000000000000000000000000000000"
- name: Install chart-releaser with a checksum that does not match
id: chart-releaser-wrong-checksum
continue-on-error: true
uses: ./actions/chart-releaser/setup
with:
chart-releaser-sha256: "0000000000000000000000000000000000000000000000000000000000000000"
- name: Install helm-repo-html with a checksum that does not match
id: helm-repo-html-wrong-checksum
continue-on-error: true
uses: ./actions/helm-repo-html/setup
with:
helm-repo-html-sha256: "0000000000000000000000000000000000000000000000000000000000000000"
- name: Install a kind release that does not exist
id: kind-missing-release
continue-on-error: true
uses: ./actions/kind/setup
with:
kind-version: v0.0.0
- name: Start MongoDB with a mongosh archive whose checksum does not match
id: mongodb-wrong-checksum
continue-on-error: true
uses: ./actions/mongodb/start
with:
mongosh-sha256: "0000000000000000000000000000000000000000000000000000000000000000"
- name: Verify every step failed
env:
STEPS: ${{ toJSON(steps) }}
run: |
passed=$(jq -r 'to_entries[] | select(.value.outcome != "failure") | .key' <<< "$STEPS")
if [ -n "$passed" ]; then
echo "Steps that did not fail: $passed" >&2
exit 1
fi
test-helm-setup:
name: "Test / Helm setup action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Helm
uses: ./actions/helm/setup
- name: Verify helm is installed
run: |
helm version
command -v helm
test-kubernetes-tools-setup:
name: "Test / kube-linter, kubeconform, helm-unittest, kind, chart-releaser and helm-repo-html setup actions"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Helm
uses: ./actions/helm/setup
- name: Setup kube-linter
uses: ./actions/kube-linter/setup
- name: Setup kubeconform
uses: ./actions/kubeconform/setup
- name: Setup helm-unittest
uses: ./actions/helm-unittest/setup
- name: Setup kind
uses: ./actions/kind/setup
- name: Setup chart-releaser
uses: ./actions/chart-releaser/setup
- name: Setup helm-repo-html
uses: ./actions/helm-repo-html/setup
- name: Verify the tools run on a chart
run: |
helm create "${RUNNER_TEMP}/demo" >/dev/null
helm template demo "${RUNNER_TEMP}/demo" | kubeconform -strict -summary
kube-linter lint "${RUNNER_TEMP}/demo" --format json > "${RUNNER_TEMP}/kube-linter.json" || true
jq -e '.Reports != null' "${RUNNER_TEMP}/kube-linter.json"
mkdir -p "${RUNNER_TEMP}/demo/tests"
printf '%s\n' 'suite: deployment' 'templates: [templates/deployment.yaml]' 'tests:' ' - it: renders a deployment' ' asserts:' ' - isKind:' ' of: Deployment' > "${RUNNER_TEMP}/demo/tests/deployment_test.yaml"
untt "${RUNNER_TEMP}/demo"
kind version
kubectl version --client
cr package "${RUNNER_TEMP}/demo" --package-path "${RUNNER_TEMP}/packages"
helm repo index "${RUNNER_TEMP}/packages"
# A Go template, whose variables the shell must leave alone.
# shellcheck disable=SC2016
echo '{{ range $name, $versions := .Entries }}{{ $name }}{{ end }}' > "${RUNNER_TEMP}/packages/index.tpl"
helm-repo-html --input "${RUNNER_TEMP}/packages/index.yaml" --template "${RUNNER_TEMP}/packages/index.tpl" --output "${RUNNER_TEMP}/packages/index.html"
grep -qx demo "${RUNNER_TEMP}/packages/index.html"
test-scanner-setup:
name: "Test / Opengrep, Trivy and CodeQL setup actions"
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Opengrep
uses: ./actions/opengrep/setup
- name: Setup Trivy
uses: ./actions/trivy/setup
- name: Setup CodeQL
uses: ./actions/codeql/setup
- name: Verify each scanner runs
run: |
mkdir -p "${RUNNER_TEMP}/opengrep-fixture"
printf '%s\n' 'const input = process.argv[2];' 'eval(input);' > "${RUNNER_TEMP}/opengrep-fixture/app.js"
# $X is a metavariable of the Opengrep pattern, which the shell must leave as it is.
# shellcheck disable=SC2016
[ "$(opengrep scan --quiet --json -e 'eval($X)' --lang js "${RUNNER_TEMP}/opengrep-fixture" | jq '.results | length')" = 1 ]
trivy fs --quiet --scanners vuln --exit-code 0 test/fixtures/node
[[ "$(trivy --version)" == *"Version: "* ]]
codeql resolve languages --format=json | jq -e 'has("javascript") and has("python")'
test-chart-testing-setup:
name: "Test / chart-testing setup action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Helm
uses: ./actions/helm/setup
- name: Setup chart-testing
uses: ./actions/chart-testing/setup
- name: Verify chart-testing is installed
run: |
ct version
command -v ct yamllint yamale
test-goreleaser-setup:
name: "Test / GoReleaser setup action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup GoReleaser
uses: ./actions/goreleaser/setup
- name: Verify goreleaser is installed
run: |
goreleaser --version
command -v goreleaser
test-go-lint-govulncheck-scan:
name: "Test / Go lint and govulncheck scan actions"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: test/fixtures/go/module/go.mod
cache: false
- name: Lint a module that passes every check
uses: ./actions/go/lint
with:
working-directory: test/fixtures/go/module
- name: Scan the module with govulncheck
uses: ./actions/govulncheck/scan
with:
working-directory: test/fixtures/go/module
- name: Lint a module gofmt did not format, failing on it
id: unformatted
continue-on-error: true
uses: ./actions/go/lint
with:
working-directory: test/fixtures/go/unformatted
- name: Lint a module whose go.mod requires what it never imports, failing on it
id: untidy
continue-on-error: true
uses: ./actions/go/lint
with:
working-directory: test/fixtures/go/untidy
- name: Verify both failed and govulncheck is on the path
env:
UNFORMATTED: ${{ steps.unformatted.outcome }}
UNTIDY: ${{ steps.untidy.outcome }}
run: |
[ "$UNFORMATTED" = failure ]
[ "$UNTIDY" = failure ]
govulncheck -version
test-indexnow-submit:
name: "Test / IndexNow submit action, against a local API"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The server outlives this step, which the next ones reach, and goes with the job.
- name: Serve a sitemap index and an IndexNow API that records the submission
run: |
nohup node test/fixtures/indexnow/server.js "${RUNNER_TEMP}/indexnow.json" 18089 > "${RUNNER_TEMP}/indexnow.log" 2>&1 &
for _ in $(seq 1 20); do
curl -fs -o /dev/null http://127.0.0.1:18089/sitemap.xml && exit 0
sleep 0.5
done
cat "${RUNNER_TEMP}/indexnow.log"
exit 1
- name: Submit the pages of the sitemap index
uses: ./actions/indexnow/submit
with:
api-url: http://127.0.0.1:18089/indexnow
key: fixture-key
sitemap-url: http://127.0.0.1:18089/sitemap.xml
- name: Submit to an API refusing the submission, failing on it
id: refused
continue-on-error: true
uses: ./actions/indexnow/submit
with:
api-url: http://127.0.0.1:18089/refuse
key: fixture-key
sitemap-url: http://127.0.0.1:18089/sitemap.xml
- name: Verify the submission and the refusal
env:
REFUSED: ${{ steps.refused.outcome }}
run: |
jq -e '
.host == "127.0.0.1:18089"
and .key == "fixture-key"
and .keyLocation == "http://127.0.0.1:18089/fixture-key.txt"
and .urlList == ["http://127.0.0.1:18089/a?x=1&y=2", "http://127.0.0.1:18089/b", "http://127.0.0.1:18089/c"]
' "${RUNNER_TEMP}/indexnow.json"
[ "$REFUSED" = failure ]
test-task-setup:
name: "Test / Task setup action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Task
uses: ./actions/task/setup
- name: Verify task is installed
run: |
task --version
command -v task
test-cosign-sign:
name: "Test / Cosign sign action, without signing"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Signing needs an OIDC token and a registry to push to, so the run stops short of it.
- name: Install Cosign and read the digest of a public image
id: cosign
uses: ./actions/cosign/sign
with:
image-name: busybox
image-path: docker.io/library
image-tag: "1.37"
readonly: "true"
- name: Read the digest of an image that does not exist
id: missing-image
continue-on-error: true
uses: ./actions/cosign/sign
with:
image-name: busybox
image-path: docker.io/library
image-tag: tag-that-does-not-exist
readonly: "true"
- name: Verify the digest and the failure
env:
DIGEST: ${{ steps.cosign.outputs.digest }}
MISSING_IMAGE_OUTCOME: ${{ steps.missing-image.outcome }}
run: |
command -v cosign
[[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]
[ "$MISSING_IMAGE_OUTCOME" = failure ]
test-dotnet-pack-push:
name: "Test / .NET pack-push action, without pushing"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Package the library fixture
uses: ./actions/dotnet/pack-push
with:
registry-token: unused
working-directory: test/fixtures/dotnet-library
- name: Verify the package was created
run: test -s test/fixtures/dotnet-library/output/Fixture.Library.1.0.0.nupkg
test-qemu-setup:
name: "Test / QEMU setup action runs an arm64 image"
runs-on: ubuntu-latest
timeout-minutes: 20
services:
registry:
image: registry:3.1.2
ports:
- 5000:5000
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup QEMU
uses: ./actions/qemu/setup
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Verify an arm64 image runs
run: |
[ "$(docker run --rm --platform linux/arm64 busybox:1.38 uname -m)" = aarch64 ]
- name: Build an image for two platforms, one emulated
id: emulated
uses: ./actions/container/build-push
with:
image-definition: test/fixtures/container/base/Dockerfile
image-repository: localhost:5000/emulated-test
image-tag: ${{ github.run_id }}
platforms: linux/amd64,linux/arm64
- name: Verify the tag names a manifest list holding both platforms, each also under a tag of its own
env:
DIGEST: ${{ steps.emulated.outputs.digest }}
run: |
image="localhost:5000/emulated-test:${GITHUB_RUN_ID}"
[ "$(docker buildx imagetools inspect "$image" --format '{{json .Manifest}}' | jq -r .digest)" = "$DIGEST" ]
platforms=$(docker buildx imagetools inspect "$image" --raw | jq -r '[.manifests[].platform | select(.os == "linux") | .architecture] | sort | join(",")')
[ "$platforms" = amd64,arm64 ]
for platform in linux-amd64 linux-arm64; do
docker buildx imagetools inspect "${image}-${platform}" >/dev/null
done
test-container-build-push:
name: "Test / Container build-push action, a base and an image built on it"
runs-on: ubuntu-latest
timeout-minutes: 20
services:
registry:
image: registry:3.1.2
ports:
- 5000:5000
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build and push the base image under a tag
id: base
uses: ./actions/container/build-push
with:
image-definition: test/fixtures/container/base/Dockerfile
image-repository: localhost:5000/build-test-base
image-tag: ${{ github.run_id }}
# The derived image fails to build unless the build argument names the base pushed above.
- name: Build and push the derived image
id: derived
uses: ./actions/container/build-push
with:
image-definition: test/fixtures/container/derived/Dockerfile
image-repository: localhost:5000/build-test-derived
image-tag: ${{ github.run_id }}
build-arguments: |
BASE_IMAGE=localhost:5000/build-test-base:${{ github.run_id }}
- name: Verify both images are in the registry under their digest, and not left in the daemon
env:
BASE_DIGEST: ${{ steps.base.outputs.digest }}
DERIVED_DIGEST: ${{ steps.derived.outputs.digest }}
run: |
for image in "build-test-base:${GITHUB_RUN_ID}=${BASE_DIGEST}" "build-test-derived:${GITHUB_RUN_ID}=${DERIVED_DIGEST}"; do
ref="localhost:5000/${image%%=*}"
[ "$(docker buildx imagetools inspect "$ref" --format '{{json .Manifest}}' | jq -r .digest)" = "${image#*=}" ]
if docker image inspect "$ref" >/dev/null 2>&1; then
echo "ERROR: ${ref} is left in the daemon" >&2
exit 1
fi
done
# A Windows image is built on the Windows runner alone, and a CI run pushes nothing.
test-windows-container-publication:
name: "Test / Container publication reusable workflow, a Windows image without push"
uses: ./.github/workflows/reusable-container-publication.yml
with:
push: false
scan: true
scan-path: C:\Windows\System32\drivers\etc
image-definition: test/fixtures/container/windows/Dockerfile
image-path: localhost
image-name: windows-test
image-tag: ${{ github.run_id }}
image-platform: ""
windows-runner: windows-2025
test-container-build-push-arm64:
name: "Test / Container build-push action on an arm64 runner"
runs-on: ubuntu-24.04-arm
timeout-minutes: 20
services:
registry:
image: registry:3.1.2
ports:
- 5000:5000
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build and push the base image natively
id: native
uses: ./actions/container/build-push
with:
image-definition: test/fixtures/container/base/Dockerfile
image-repository: localhost:5000/native-test
image-tag: ${{ github.run_id }}
platforms: linux/arm64
- name: Verify the image is for arm64
env:
DIGEST: ${{ steps.native.outputs.digest }}
run: |
image="localhost:5000/native-test@${DIGEST}"
architectures=$(docker buildx imagetools inspect "$image" --raw | jq -r '[.manifests[]?.platform | select(.os == "linux") | .architecture] | join(",")')
# A single platform pushed without attestations is a manifest rather than a list, and names its architecture in its configuration.
if [ -z "$architectures" ]; then
architectures=$(docker buildx imagetools inspect "$image" --format '{{json .Image}}' | jq -r .architecture)
fi
[ "$architectures" = arm64 ]
# Each tool runs once installed, which a binary built for another processor does not.
test-setup-arm64:
name: "Test / Setup actions install arm64 binaries on an arm64 runner"
runs-on: ubuntu-24.04-arm
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Terraform
uses: ./actions/terraform/setup
- name: Setup TFLint
uses: ./actions/tflint/setup
- name: Setup Helm
uses: ./actions/helm/setup
- name: Setup chart-testing
uses: ./actions/chart-testing/setup
- name: Setup GoReleaser
uses: ./actions/goreleaser/setup
- name: Setup Task
uses: ./actions/task/setup
- name: Setup kube-linter
uses: ./actions/kube-linter/setup
- name: Setup kubeconform
uses: ./actions/kubeconform/setup
- name: Setup helm-unittest
uses: ./actions/helm-unittest/setup
- name: Setup kind
uses: ./actions/kind/setup
- name: Setup Opengrep
uses: ./actions/opengrep/setup
- name: Setup CodeQL
uses: ./actions/codeql/setup
- name: Start MongoDB
uses: ./actions/mongodb/start
- name: Generate SBOM with Syft
uses: ./actions/syft/generate-sbom
with:
target-path: test/fixtures/container
upload-artifact: "false"
- name: Scan with Trivy
uses: ./actions/trivy/scan
with:
scan-type: config
target: test/fixtures/container
- name: Verify the binaries are for arm64
run: |
for tool in terraform tflint helm ct goreleaser task kube-linter kubeconform untt kind kubectl opengrep mongod mongosh syft trivy; do
# The ELF machine field, 0xb7 being aarch64, read without the file command a runner image may lack.
[ "$(od -An -tx1 -j18 -N1 "$(command -v "$tool")" | tr -d ' ')" = b7 ]
done
# The codeql command is a launcher script, run here so that its arm64 Java and extractors answer.
codeql version --format=terse
test-mongodb-start:
name: "Test / MongoDB start action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Start MongoDB
uses: ./actions/mongodb/start
- name: Verify MongoDB answers, on the latest release by default
run: |
mongosh --quiet --eval 'db.runCommand({ ping: 1 }).ok' mongodb://127.0.0.1:27017 | grep -qx 1
mongosh --quiet --eval 'db.version()' mongodb://127.0.0.1:27017 | grep -q '^9\.0\.'
test-mongodb-start-version:
name: "Test / MongoDB start action, an earlier version"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Start MongoDB 8.0
uses: ./actions/mongodb/start
with:
mongodb-version: 8.0.34
- name: Verify the server is the version asked for
run: |
[ "$(mongosh --quiet --eval 'db.version()' mongodb://127.0.0.1:27017)" = 8.0.34 ]
test-mongodb-start-replica-set:
name: "Test / MongoDB start action, replica set"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Start MongoDB
uses: ./actions/mongodb/start
with:
port: "27117"
replica-set: rs0
- name: Verify MongoDB is the primary of the replica set
run: |
mongosh --quiet --eval 'db.hello().isWritablePrimary' "mongodb://127.0.0.1:27117/?directConnection=true" | grep -qx true
test-syft-generate-sbom:
name: "Test / Syft generate-sbom action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Generate SBOM for this repository
uses: ./actions/syft/generate-sbom
with:
target-path: actions
output-file: sbom-test.spdx.json
upload-artifact: "false"
- name: Generate SBOM for a directory, one folder left out
uses: ./actions/syft/generate-sbom
with:
exclude-paths: node
target-path: test/fixtures
output-file: sbom-exclude-test.spdx.json
upload-artifact: "false"
- name: Generate SBOM for a public image
uses: ./actions/syft/generate-sbom
with:
target-image: busybox:1.38
output-format: cyclonedx-json
output-file: sbom-image-test.cdx.json
upload-artifact: "false"
- name: Verify SBOM was generated
run: |
test -s sbom-test.spdx.json
grep -q '"spdxVersion"' sbom-test.spdx.json
jq -e '.bomFormat == "CycloneDX" and (.components | length > 0)' sbom-image-test.cdx.json
jq -e '[.packages[].name] | index("playwright-fixture") and (index("node-fixture") | not)' sbom-exclude-test.spdx.json
test-syft-generate-sbom-windows:
name: "Test / Syft generate-sbom action on Windows"
runs-on: windows-2025
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Generate SBOM for a directory, one folder left out
uses: ./actions/syft/generate-sbom
with:
exclude-paths: node
target-path: test/fixtures
output-file: sbom-exclude-test.spdx.json
upload-artifact: "false"
# PowerShell reads the JSON, as a Windows runner image may lack jq.
- name: Verify SBOM was generated
shell: pwsh
run: |
syft version
if ($LASTEXITCODE -ne 0) { exit 1 }
$names = (Get-Content -Raw sbom-exclude-test.spdx.json | ConvertFrom-Json).packages.name
if (-not ($names -contains 'playwright-fixture') -or ($names -contains 'node-fixture')) { exit 1 }
test-trivy-scan:
name: "Test / Trivy scan action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Scan a real image with Trivy
uses: ./actions/trivy/scan
with:
scan-type: image
target: devprofr/terraform-backend-mongodb:latest
severity: CRITICAL,HIGH
exit-code: "0"
- name: Scan a directory with Trivy
uses: ./actions/trivy/scan
with:
scan-type: config
target: test/fixtures/terraform
format: sarif
output-file: trivy-test.sarif
severity: HIGH,CRITICAL
# The base fixture runs as root, which Trivy reports as a HIGH misconfiguration.
- name: Scan a directory with a finding, failing on it
id: trivy-finding
continue-on-error: true
uses: ./actions/trivy/scan
with:
scan-type: config
target: test/fixtures/container/base
severity: HIGH,CRITICAL
exit-code: "1"
- name: Scan a directory with a finding the ignore file leaves out
uses: ./actions/trivy/scan
with:
scan-type: config
target: test/fixtures/container/base
severity: HIGH,CRITICAL
exit-code: "1"
ignore-file: test/fixtures/trivy/ignore-current.yaml
- name: Scan a directory with a finding whose ignore entry expired, failing on it
id: trivy-expired
continue-on-error: true
uses: ./actions/trivy/scan
with:
scan-type: config
target: test/fixtures/container/base
severity: HIGH,CRITICAL
exit-code: "1"
ignore-file: test/fixtures/trivy/ignore-expired.yaml
- name: Scan with an ignore file that does not exist, failing on it
id: trivy-missing-ignore-file
continue-on-error: true
uses: ./actions/trivy/scan
with:
scan-type: config
target: test/fixtures/terraform
ignore-file: test/fixtures/trivy/missing.yaml
# The metadata of an installed Python package, a version with known vulnerabilities, stands for the binaries and packages of a directory.
- name: Scan the installed packages of a directory with Trivy
uses: ./actions/trivy/scan
with:
scan-type: rootfs
target: test/fixtures/trivy/rootfs
format: json
output-file: trivy-rootfs.json
severity: HIGH,CRITICAL
- name: Verify the reports were generated and the findings failed the scans
env:
EXPIRED_OUTCOME: ${{ steps.trivy-expired.outcome }}
FINDING_OUTCOME: ${{ steps.trivy-finding.outcome }}
MISSING_IGNORE_FILE_OUTCOME: ${{ steps.trivy-missing-ignore-file.outcome }}
run: |
jq -e '.version == "2.1.0"' trivy-test.sarif
jq -e '[.Results[] | select(.Type == "python-pkg") | .Vulnerabilities[].VulnerabilityID] | any(. == "CVE-2019-11324")' trivy-rootfs.json
[ "$FINDING_OUTCOME" = failure ]
[ "$EXPIRED_OUTCOME" = failure ]
[ "$MISSING_IGNORE_FILE_OUTCOME" = failure ]
# The fixture locks the latest release of hashicorp/local, so a "Vulnerable provider" warning on it comes from the Go version and modules HashiCorp built it with.
# It is expected, shows the provider scan works, and goes away with a new release of the provider once the lock files are updated with terraform init -upgrade.
test-terraform-quality:
name: "Test / Terraform quality reusable workflow"
uses: ./.github/workflows/reusable-terraform-quality.yml
with:
working-directory: test/fixtures/terraform
test-dotnet-quality:
name: "Test / .NET quality reusable workflow"
uses: ./.github/workflows/reusable-dotnet-quality.yml
with:
working-directory: test/fixtures/dotnet
# Each line runs as written, quotes included, or the commands fail.
custom-commands: |
words=("two words" three)
[ "${#words[@]}" = 2 ]
[ "$(dotnet --version | cut -d . -f 1)" -ge 10 ]
# The fixture holds a test that fails, which only the filter keeps the job from running, its quotes being read as shell quotes rather than passed on.
dotnet-test-args: --report-xunit-trx --coverage --coverage-output-format cobertura --filter-not-namespace 'Fixture.Tests.LeftOut*'
# Runs where a Sonar server is set in SONAR_HOST_URL, as IstarCI provides a SonarQube locally, and is skipped otherwise.
test-dotnet-quality-sonar:
name: "Test / .NET quality reusable workflow with Sonar"
if: vars.SONAR_HOST_URL != ''
uses: ./.github/workflows/reusable-dotnet-quality.yml
with:
working-directory: test/fixtures/dotnet
dotnet-test-args: --report-xunit-trx --coverage --coverage-output-format cobertura --filter-not-namespace 'Fixture.Tests.LeftOut*'
sonar-enabled: true
sonar-host-url: ${{ vars.SONAR_HOST_URL }}
sonar-organization: ${{ vars.SONAR_ORGANIZATION }}
sonar-project-key: github-workflow-parts-dotnet-fixture
sonar-project-name: GitHub workflow parts .NET fixture
sonar-settings-file: SonarQube.Analysis.xml
secrets:
sonar-token: ${{ secrets.SONAR_TOKEN }}
# The fixture mixes a project of the old format restored from packages.config and an SDK one, as .NET Framework code being migrated does.
test-windows-dotnet-framework-quality:
name: "Test / .NET Framework quality reusable workflow"
uses: ./.github/workflows/reusable-dotnet-framework-quality.yml
with:
solution: Fixture.Framework.sln
working-directory: test/fixtures/dotnet-framework
test-dotnet-build-test:
name: "Test / .NET build-test action writes results, coverage and reports"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install .NET & lint
uses: ./actions/dotnet/install-lint-restore
with:
working-directory: test/fixtures/dotnet
- name: Build & test
uses: ./actions/dotnet/build-test
with:
dotnet-test-args: --report-xunit-trx --coverage --coverage-output-format cobertura --filter-not-namespace 'Fixture.Tests.LeftOut*'
working-directory: test/fixtures/dotnet
# The paths are those the .NET quality workflow uploads as its artifact.
- name: Verify the results, the coverage and the reports
working-directory: test/fixtures/dotnet/report
run: |
compgen -G "TestResults/*.trx" >/dev/null
compgen -G "TestResults/*.cobertura.xml" >/dev/null
test -s Summary.txt
test -s index.html
grep -q 'Line coverage' Summary.txt
test-container-scan-on-base:
name: "Test / Container scan reusable workflow on a base built in the run"
uses: ./.github/workflows/reusable-container-scan.yml
with:
base-image-definition: test/fixtures/container/base/Dockerfile
image-definition: test/fixtures/container/derived/Dockerfile
image-name: scan-test
image-path: local
image-tag: ${{ github.run_id }}
severity: CRITICAL,HIGH,MEDIUM
trivy-ignore-file: test/fixtures/trivy/ignore-current.yaml
test-git-check-changes:
name: "Test / Git check-changes action"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The empty tree of git stands for a base holding nothing, which needs no history in the clone.
- name: Compare a path with the empty tree
id: added
uses: ./actions/git/check-changes
with:
paths: README.md actions
base: 4b825dc642cb6eb9a060e54bf8d69288fbee4904
- name: Compare a path that does not exist with the empty tree
id: absent
uses: ./actions/git/check-changes
with:
paths: path-that-does-not-exist
base: 4b825dc642cb6eb9a060e54bf8d69288fbee4904
- name: Compare a path with the commit itself
id: unchanged
uses: ./actions/git/check-changes
with:
paths: README.md
base: HEAD
- name: Compare a path with a commit the clone does not have
id: unreadable
uses: ./actions/git/check-changes
with:
paths: README.md
base: "0000000000000000000000000000000000000000"
- name: Verify the comparisons
env:
ADDED: ${{ steps.added.outputs.changed }}
ABSENT: ${{ steps.absent.outputs.changed }}
UNCHANGED: ${{ steps.unchanged.outputs.changed }}
UNREADABLE: ${{ steps.unreadable.outputs.changed }}
run: |
[ "$ADDED" = true ]
[ "$ABSENT" = false ]
[ "$UNCHANGED" = false ]
[ "$UNREADABLE" = true ]
# A local run reads the outputs of a called workflow under the id of the job inside it, which the caller shares.
git-check:
name: "Test / Git check reusable workflow"
uses: ./.github/workflows/reusable-git-check.yml
with:
paths: test/fixtures
version-file: test/fixtures/version/Directory.Build.props
test-git-check-outputs:
name: "Test / Git check reusable workflow outputs"
needs: git-check
runs-on: ubuntu-latest
timeout-minutes: 5
steps: