generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 56
1190 lines (1077 loc) · 41.8 KB
/
ci_common.yml
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
#
# This workflow contains the core logic to build, test and release the GitHub Action and Azure DevOps Task
# It is called via workflow_call from the pr-bot
#
name: "build-test"
on:
workflow_call:
inputs:
prNumber:
description: The PR number (if building for a PR)
type: string
required: false
prRef:
description: The git ref to checkout (e.g. the merge commit for a PR)
type: string
required: false
prHeadSha:
description: >-
For PR builds (where GITHUB_REF would usually be set to the PR but isn't due to the pr-bot
running on a comment trigger), pass the PR's head SHA commit here
type: string
required: false
runFullTests:
description: true to run the full tests, false to run tests without credentials
default: true
type: boolean
required: false
release:
type: boolean
description: indicates whether to make a release
default: false
required: false
AZDO_ORG:
description: The AzDO org for AzDO task verification
type: string
required: false
default: https://dev.azure.com/monacotools
AZDO_PROJECT:
description: The AzDO project for AzDO task verification
type: string
required: false
default: Monaco
AZDO_BUILD:
description: The AzDO build to trigger for AzDO task verification
type: string
required: false
default: devcontainers.ci
secrets:
AZDO_TOKEN:
description: ""
required: true
permissions:
contents: write
packages: write
pull-requests: write
checks: write
jobs:
build: # run build using the github action!
runs-on: ubuntu-latest
name: build, test, package
outputs:
version: ${{ steps.build.outputs.version }}
version_short: ${{ steps.build.outputs.version_short }}
version_major: ${{ steps.build.outputs.version_major }}
image_tag: ${{ steps.set_image_tag.outputs.image_tag }}
image_push_option: ${{ steps.set_image_push_option.outputs.image_push_option }}
build_number: ${{ steps.build_number.outputs.build_number }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- id: set_image_push_option
name: Set image push option
uses: actions/github-script@v6
with:
script: |
// if running full tests then use the filter option, for the dev container action
// else, set to never to avoid pushing (as we're likely running without secrets)
const pushOption = ${{ inputs.runFullTests }} ? 'filter' : 'never';
console.log(`Setting image_push_option=${pushOption}`);
core.setOutput("image_push_option", pushOption);
- name: Login to GitHub Container Registry
if: ${{ steps.set_image_push_option.outputs.image_push_option == 'filter' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Previously, run_id was used as the patch number (BUILD_NUMBER)
# but this got outside the limit for AzDO extensions (0 to 2147483647)
- name: Generate build number
id: build_number
# only run this if we are going to run the AzDO publishing
if: ${{ steps.set_image_push_option.outputs.image_push_option == 'filter' }}
uses: onyxmueller/build-tag-number@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- id: set_image_tag
name: Set image_tag...
uses: actions/github-script@v6
env:
PR_NUMBER: ${{ inputs.prNumber }}
with:
script: |
const {PR_NUMBER} = process.env
if (PR_NUMBER) {
const prTag = `pr-${PR_NUMBER}`;
console.log(`Setting image_tag=${prTag} for pull_request`);
core.setOutput("image_tag", prTag);
return;
}
if ((context.eventName === "push" || context.eventName === "workflow_dispatch") && context.ref === "refs/heads/main") {
console.log("Setting image_tag=latest for push to main");
core.setOutput("image_tag", "latest");
return;
}
core.error('Failed to set image_tag');
console.log(context);
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
node --version
npm --version
echo "** Installing and building common..."
(cd common && npm install && npm run build)
(cd common && npm run tsc_version)
echo "** Installing and building github-action..."
(cd github-action/ && npm install && npm run build && npm run package)
- name: Build in dev container
uses: ./
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_NUMBER: ${{ steps.build_number.outputs.build_number }}
IS_PR: ${{ github.head_ref }}
BRANCH: ${{ github.ref }}
with:
imageName: ghcr.io/devcontainers/ci-devcontainer
imageTag: ${{ steps.set_image_tag.outputs.image_tag }}
runCmd: |
echo "Starting"
./scripts/build-test-package.sh
push: ${{ steps.set_image_push_option.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
env: |
BUILD_NUMBER
IS_CI=1
IS_PR
BRANCH
- name: Show version info
env:
VERSION: ${{ steps.build.outputs.version }}
VERSION_SHORT: ${{ steps.build.outputs.version_short }}
VERSION_MAJOR: ${{ steps.build.outputs.version_major }}
run: |
echo "VERSION=${VERSION}"
echo "VERSION_SHORT=${VERSION_SHORT}"
echo "VERSION_MAJOR=${VERSION_MAJOR}"
- uses: actions/upload-artifact@v3
name: Create dev AzDO VSIX artifact
with:
name: azdo-task-dev
path: ./output/devcontainers-dev.ci-${{ steps.build.outputs.version }}.vsix
if-no-files-found: error
- uses: actions/upload-artifact@v3
name: Create release AzDO VSIX artifact
with:
name: azdo-task
path: ./output/devcontainers.ci-${{ steps.build.outputs.version }}.vsix
if-no-files-found: error
checks-succeeded:
# simple no-op job to use as step for check status
name: All succeeded
needs: # TODO - check what jobs need adding here
- build
- test-azdo
- test-gh-run-args
- test-gh-build-args
- test-gh-dockerfile-context
- test-gh-feature-docker-from-docker
- test-gh-docker-from-docker-non-root
- test-gh-docker-from-docker-root
- test-gh-skip-user-update
- test-compose-features
- test-config-file
- test-simple
- test-no-run
- test-platform-with-runcmd
- test-env-vars-on-post-create
- test-multiple-tags-job2
- test-github-output
runs-on: ubuntu-latest
steps:
- name: Simple step
run: |
echo Done!
pr-checks:
name: Mark PR checks as complete
needs: # TODO - check what jobs need adding here
- checks-succeeded
runs-on: ubuntu-latest
if: ${{ inputs.prHeadSha }}
steps:
# For PR builds triggered from comment builds, the GITHUB_REF is set to main
# so the checks aren't automatically associated with the PR
# If prHeadSha is specified then explicity mark the checks for that SHA
- name: Report check status
if: ${{ inputs.prHeadSha }}
uses: LouisBrunner/checks-action@v1.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
# the name must be identical to the one received by the real job
sha: ${{ inputs.prHeadSha }}
name: "Build, test, publish / All succeeded"
status: "completed"
conclusion: "success"
release:
name: Create release
runs-on: ubuntu-latest
needs:
- build
- checks-succeeded
if: ${{ inputs.release == true }}
env:
VERSION: ${{ needs.build.outputs.version }}
VERSION_SHORT: ${{ needs.build.outputs.version_short }}
VERSION_MAJOR: ${{ needs.build.outputs.version_major }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Show version info
run: |
echo "VERSION=${VERSION}"
echo "VERSION_SHORT=${VERSION_SHORT}"
echo "VERSION_MAJOR=${VERSION_MAJOR}"
- name: Download release VSIX
uses: actions/download-artifact@v3
with:
name: azdo-task
path: output
- name: Show version
run: |
echo "VERSION: $VERSION"
echo "VERSION_SHORT: $VERSION_SHORT"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main' # only need this for push (on `main`)
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Publish AzDO Task
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZDO_PROJECT: ${{ inputs.AZDO_PROJECT }}
AZDO_BUILD: ${{ inputs.AZDO_BUILD }}
AZDO_ORG: ${{ inputs.AZDO_ORG }}
AZDO_TOKEN: ${{ secrets.AZDO_TOKEN }}
AZURE_DEVOPS_EXT_PAT: ${{ secrets.AZDO_TOKEN }}
BUILD_NUMBER: ${{ github.run_id }}
IS_PR: ${{ github.head_ref }}
BRANCH: ${{ github.ref }}
with:
imageName: ghcr.io/devcontainers/ci-devcontainer
runCmd: |
echo "Starting"
./scripts/publish-azdo-task.sh
env: |
BUILD_NUMBER
IS_CI=1
IS_PR
BRANCH
AZDO_TOKEN
AZURE_DEVOPS_EXT_PAT
AZDO_ORG
AZDO_PROJECT
AZDO_BUILD
- name: Create GitHub Action Release
env:
TAG_NAME: v${{ needs.build.outputs.version_short }}
RELEASE_NAME: v${{ needs.build.outputs.version }}
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "CI build"
git config user.email automated-build@example.com
./scripts/gh-release.sh
#
# Jobs to test
#
# When adding a new test:
# - add to the 'needs' section for the 'checks-succeeded' job
# - add any new images to the image_names in clean_tags.sh
# - review the Azure DevOps pipeline and consider adding there for verification
#
test-azdo:
name: Run AzDO test
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Show version
env:
VERSION: ${{ needs.build.outputs.version }}
VERSION_SHORT: ${{ needs.build.outputs.version_short }}
run: |
echo "VERSION: $VERSION"
echo "VERSION_SHORT: $VERSION_SHORT"
- name: Download workflow artifacts
uses: actions/download-artifact@v3
with:
path: output
- name: Download release VSIX
uses: actions/download-artifact@v3
with:
name: azdo-task-dev
path: output
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main' # only need this for push (on `main`)
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run AzDO test pipeline
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZDO_PROJECT: ${{ inputs.AZDO_PROJECT }}
AZDO_BUILD: ${{ inputs.AZDO_BUILD }}
AZDO_ORG: ${{ inputs.AZDO_ORG }}
AZDO_TOKEN: ${{ secrets.AZDO_TOKEN }}
AZURE_DEVOPS_EXT_PAT: ${{ secrets.AZDO_TOKEN }}
BUILD_NUMBER: ${{ github.run_id }}
IS_PR: ${{ github.head_ref }}
BRANCH: ${{ github.ref }}
IMAGE_TAG: ${{ needs.build.outputs.image_tag }}
with:
imageName: ghcr.io/devcontainers/ci-devcontainer
runCmd: |
echo "Starting"
./scripts/test-azdo.sh
env: |
BUILD_NUMBER
IMAGE_TAG
IS_CI=1
IS_PR
BRANCH
AZDO_TOKEN
AZURE_DEVOPS_EXT_PAT
AZDO_ORG
AZDO_PROJECT
AZDO_BUILD
test-simple:
name: Run simple test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
id: simpletest
with:
subFolder: github-tests/Dockerfile/run-args
runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]]
- name: Validate runCmdOutput output
run: |
echo "'runCmdOutput' value: $runCmdOutput"
if [["$runCmdOutput" = *my-host*]]; then
echo "'runCmdOutput' output of simpletest step doesn't contain expected value 'my-host'"
exit 1
fi
env:
runCmdOutput: ${{ steps.simpletest.outputs.runCmdOutput }}
test-config-file:
name: Run test with config file
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
id: configfiletest
with:
subFolder: github-tests/Dockerfile/config-file
configFile: github-tests/Dockerfile/config-file/.devcontainer/subfolder/devcontainer.json
runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]]
- name: Validate runCmdOutput output
run: |
echo "'runCmdOutput' value: $runCmdOutput"
if [["$runCmdOutput" = *my-host*]]; then
echo "'runCmdOutput' output of configfiletest step doesn't contain expected value 'my-host'"
exit 1
fi
env:
runCmdOutput: ${{ steps.configfiletest.outputs.runCmdOutput }}
test-gh-run-args:
name: Run GitHub run-args test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/run-args
imageName: ghcr.io/devcontainers/ci/tests/run-args
runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]]
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-env-vars-on-post-create:
name: Run GitHub env-vars-on-post-create test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
env: # TEST_ENV_VALUE1 is set via devcontainer.json using a localEnv reference
TEST_ENV_VALUE1: SetViaDevcontainerJsonLocalEnv
with:
subFolder: github-tests/Dockerfile/env-vars-on-post-create
imageName: ghcr.io/devcontainers/ci/tests/env-vars-on-post-create
env:
| # TEST_ENV_VALUE2 is an additional env var to pass to the container
TEST_ENV_VALUE2=AdditionalEnvVar
runCmd: |
cat marker.txt
cat marker.txt | grep 'post-create: TEST_ENV_VALUE1=SetViaDevcontainerJsonLocalEnv'
cat marker.txt | grep 'post-create: TEST_ENV_VALUE2=AdditionalEnvVar'
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-gh-build-args:
name: Run GitHub build-args test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/build-args
imageName: ghcr.io/devcontainers/ci/tests/build-args
runCmd: echo $BUILD_ARG_TEST && [[ $BUILD_ARG_TEST == "Hello build-args!" ]]
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-gh-dockerfile-context:
name: Run GitHub dockerfile-context test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/dockerfile-context
imageName: ghcr.io/devcontainers/ci/tests/dockerfile-context
runCmd: /tmp/dummy.sh
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-gh-feature-docker-from-docker:
name: Run GitHub feature-docker-from-docker test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/feature-docker-from-docker
imageName: ghcr.io/devcontainers/ci/tests/feature-docker-from-docker
runCmd: make docker-build
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-gh-docker-from-docker-non-root:
name: Run GitHub docker-from-docker-non-root test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/docker-from-docker-non-root
imageName: ghcr.io/devcontainers/ci/tests/docker-from-docker-non-root
runCmd: make docker-build
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-gh-docker-from-docker-root:
name: Run GitHub docker-from-docker-root test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/docker-from-docker-root
imageName: ghcr.io/devcontainers/ci/tests/docker-from-docker-root
runCmd: make docker-build
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-gh-skip-user-update:
name: Run GitHub skipContainerUserIdUpdate test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/skip-user-update
imageName: ghcr.io/devcontainers/ci/tests/skip-user-update
skipContainerUserIdUpdate: true
runCmd: |
echo "Get user/group info ..."
user_id=$(id -u $(whoami))
echo "User ID: $user_id"
group_id=$(id -g $(whoami))
echo "Group ID: $group_id"
[[ $user_id == 1000 ]] && [[ $group_id == 1000 ]]
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-compose-features:
name: Run GitHub docker-compose with features test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/docker-compose/features
imageName: ghcr.io/devcontainers/ci/tests/compose-features
runCmd: go version
imageTag: ${{ needs.build.outputs.image_tag }}
push: ${{ needs.build.outputs.image_push_option }}
eventFilterForPush: |
push
pull_request
test-no-run:
name: Run test without runCmd
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
with:
subFolder: github-tests/Dockerfile/build-only
test-platform-with-runcmd:
name: Run GitHub platform and runCmd test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# if the following value is missing (i.e. not triggered via comment workflow)
# then the default checkout will apply
ref: ${{ inputs.prRef }}
- name: Set up QEMU for multi-architecture builds
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# This can be omitted once runner images have a version of Skopeo > 1.4.1
# See https://github.com/containers/skopeo/issues/1874 (and https://github.com/devcontainers/ci/issues/191#issuecomment-1416384710)
- name: Update skopeo
run: |
sudo apt purge buildah golang-github-containers-common podman skopeo
sudo apt autoremove --purge
REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable"
source /etc/os-release
sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list"
sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key
sudo apt-key add Release.key
sudo apt-get update
sudo apt-get install skopeo
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ needs.build.outputs.image_push_option == 'filter' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Published action contains compiled JS, but we need to compile it here
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Compile GH action
run: |
(cd common && npm install && npm run build)
(cd github-action/ && npm install && npm run build && npm run package)
- name: Run test
uses: ./
id: platform-with-runcmd