-
Notifications
You must be signed in to change notification settings - Fork 1
3281 lines (2924 loc) · 146 KB
/
Copy pathrelease.yml
File metadata and controls
3281 lines (2924 loc) · 146 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: Build and Release Docker Image
on:
push:
branches:
- main
paths:
- 'Dockerfile'
- 'scripts/**'
- 'ubuntu/**'
- '.github/workflows/release.yml'
- '.changeset/**'
- 'VERSION'
pull_request:
types: [opened, synchronize, reopened]
# Manual release support - allows instant version bump and release, or building current version
workflow_dispatch:
inputs:
release_mode:
description: 'Release mode: build-only (no push/release), bump-and-release (bump version then build+release), release-only (build+release current VERSION without bumping)'
required: true
type: choice
default: 'build-only'
options:
- build-only
- bump-and-release
- release-only
bump_type:
description: 'Version bump type (only for bump-and-release mode)'
required: false
type: choice
default: 'patch'
options:
- patch
- minor
- major
description:
description: 'Release description (optional, for bump-and-release mode)'
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# GitHub Container Registry
GHCR_REGISTRY: ghcr.io
GHCR_IMAGE_NAME: ${{ github.repository }}
# Docker Hub
DOCKERHUB_REGISTRY: docker.io
DOCKERHUB_IMAGE_NAME: konard/box
jobs:
# === VERSION CHECK (PRs only) ===
# Prohibit manual version changes in VERSION file - versions should only be changed by CI/CD
version-check:
name: Check for Manual Version Changes
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for version changes in VERSION file
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_BASE_REF: ${{ github.base_ref }}
run: |
chmod +x scripts/release/check-version.sh
./scripts/release/check-version.sh
# === CHANGESET CHECK (PRs only) ===
# Ensure PRs with code changes include a changeset
changeset-check:
name: Check for Changesets
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for changesets
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_BASE_REF: ${{ github.base_ref }}
run: |
# Skip for branches that don't need changesets
if [[ "$GITHUB_HEAD_REF" == changeset-release/* ]] || [[ "$GITHUB_HEAD_REF" == changeset-manual-release-* ]]; then
echo "Skipping changeset check for release PR"
exit 0
fi
# Check if there are code changes (Dockerfile, scripts, etc.)
git fetch origin "$GITHUB_BASE_REF" 2>/dev/null || true
CODE_CHANGES=$(git diff --name-only "origin/${GITHUB_BASE_REF}...HEAD" | grep -E '^(Dockerfile|scripts/|ubuntu/|\.github/workflows/)' || true)
if [ -z "$CODE_CHANGES" ]; then
echo "No code changes detected, changeset not required"
exit 0
fi
echo "Code changes detected:"
echo "$CODE_CHANGES"
echo ""
chmod +x scripts/release/validate-changeset.sh
./scripts/release/validate-changeset.sh
# === AUTOMATIC VERSION BUMP (push to main with changesets) ===
apply-changesets:
name: Apply Changesets
runs-on: ubuntu-24.04
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
outputs:
version_bumped: ${{ steps.apply.outputs.version_bumped }}
new_version: ${{ steps.apply.outputs.new_version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for changesets
id: check
run: |
chmod +x scripts/release/check-changesets.sh
./scripts/release/check-changesets.sh
- name: Apply changesets
id: apply
if: steps.check.outputs.has_changesets == 'true'
run: |
chmod +x scripts/release/apply-changesets.sh
./scripts/release/apply-changesets.sh
# === MANUAL VERSION BUMP (workflow_dispatch with bump-and-release) ===
version-bump:
runs-on: ubuntu-24.04
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'bump-and-release'
permissions:
contents: write
outputs:
version: ${{ steps.bump.outputs.new_version }}
version_bumped: ${{ steps.bump.outputs.bumped }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
id: bump
run: |
# Read current version
CURRENT_VERSION=$(cat VERSION | tr -d '[:space:]')
echo "Current version: $CURRENT_VERSION"
# Parse version components
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
# Bump based on type
case "${{ github.event.inputs.bump_type }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "New version: $NEW_VERSION"
# Update VERSION file
echo "$NEW_VERSION" > VERSION
# Commit and push
git add VERSION
DESCRIPTION="${{ github.event.inputs.description }}"
if [ -n "$DESCRIPTION" ]; then
git commit -m "$NEW_VERSION: $DESCRIPTION"
else
git commit -m "$NEW_VERSION"
fi
git push origin main
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "bumped=true" >> $GITHUB_OUTPUT
# === DETECT CHANGES (per-image granularity) ===
detect-changes:
runs-on: ubuntu-24.04
needs: [apply-changesets, version-bump]
# Always run, but wait for version jobs if they're running
if: always() && (needs.apply-changesets.result == 'success' || needs.apply-changesets.result == 'skipped') && (needs.version-bump.result == 'success' || needs.version-bump.result == 'skipped')
outputs:
# Legacy change detection
docker-changed: ${{ steps.changes.outputs.docker }}
scripts-changed: ${{ steps.changes.outputs.scripts }}
ubuntu-changed: ${{ steps.changes.outputs.ubuntu }}
workflow-changed: ${{ steps.changes.outputs.workflow }}
version-changed: ${{ steps.changes.outputs.version }}
should-build: ${{ steps.should-build.outputs.result }}
version: ${{ steps.version.outputs.version }}
# Per-image change detection
js-changed: ${{ steps.image-changes.outputs.js }}
essentials-changed: ${{ steps.image-changes.outputs.essentials }}
full-changed: ${{ steps.image-changes.outputs.full }}
common-changed: ${{ steps.image-changes.outputs.common }}
# Per-language change detection
python-changed: ${{ steps.language-changes.outputs.python }}
go-changed: ${{ steps.language-changes.outputs.go }}
rust-changed: ${{ steps.language-changes.outputs.rust }}
java-changed: ${{ steps.language-changes.outputs.java }}
kotlin-changed: ${{ steps.language-changes.outputs.kotlin }}
ruby-changed: ${{ steps.language-changes.outputs.ruby }}
php-changed: ${{ steps.language-changes.outputs.php }}
perl-changed: ${{ steps.language-changes.outputs.perl }}
swift-changed: ${{ steps.language-changes.outputs.swift }}
lean-changed: ${{ steps.language-changes.outputs.lean }}
rocq-changed: ${{ steps.language-changes.outputs.rocq }}
cpp-changed: ${{ steps.language-changes.outputs.cpp }}
assembly-changed: ${{ steps.language-changes.outputs.assembly }}
# dind-box change detection (issue #80)
dind-changed: ${{ steps.image-changes.outputs.dind }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
ref: ${{ github.ref }}
# Re-fetch if version was bumped to get latest commit
- name: Fetch latest changes
if: needs.version-bump.outputs.version_bumped == 'true' || needs.apply-changesets.outputs.version_bumped == 'true'
run: |
git fetch origin main
git checkout main
git pull origin main
- name: Get version from VERSION file
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
- name: Detect changes
id: changes
run: |
# For push events, compare with previous commit
# For PR events, compare with base branch
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi
# Get changed files
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" HEAD 2>/dev/null || git diff --name-only HEAD~1 HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
# Check for Docker-related changes
if echo "$CHANGED_FILES" | grep -qE '^Dockerfile$'; then
echo "docker=true" >> $GITHUB_OUTPUT
else
echo "docker=false" >> $GITHUB_OUTPUT
fi
# Check for scripts changes
if echo "$CHANGED_FILES" | grep -qE '^scripts/'; then
echo "scripts=true" >> $GITHUB_OUTPUT
else
echo "scripts=false" >> $GITHUB_OUTPUT
fi
# Check for ubuntu/ modular scripts changes
if echo "$CHANGED_FILES" | grep -qE '^ubuntu/'; then
echo "ubuntu=true" >> $GITHUB_OUTPUT
else
echo "ubuntu=false" >> $GITHUB_OUTPUT
fi
# Check for workflow changes
if echo "$CHANGED_FILES" | grep -qE '^\.github/workflows/'; then
echo "workflow=true" >> $GITHUB_OUTPUT
else
echo "workflow=false" >> $GITHUB_OUTPUT
fi
# Check for VERSION file changes
if echo "$CHANGED_FILES" | grep -qE '^VERSION$'; then
echo "version=true" >> $GITHUB_OUTPUT
else
echo "version=false" >> $GITHUB_OUTPUT
fi
# Save changed files for per-image detection
echo "$CHANGED_FILES" > /tmp/changed-files.txt
- name: Detect per-image changes
id: image-changes
run: |
CHANGED_FILES=$(cat /tmp/changed-files.txt)
# JS box changes
if echo "$CHANGED_FILES" | grep -qE '^ubuntu/24\.04/js/'; then
echo "js=true" >> $GITHUB_OUTPUT
else
echo "js=false" >> $GITHUB_OUTPUT
fi
# Essentials box changes
if echo "$CHANGED_FILES" | grep -qE '^ubuntu/24\.04/essentials-box/'; then
echo "essentials=true" >> $GITHUB_OUTPUT
else
echo "essentials=false" >> $GITHUB_OUTPUT
fi
# Full box changes (full-box dir, root Dockerfile, or scripts)
if echo "$CHANGED_FILES" | grep -qE '^(ubuntu/24\.04/full-box/|Dockerfile$|scripts/)'; then
echo "full=true" >> $GITHUB_OUTPUT
else
echo "full=false" >> $GITHUB_OUTPUT
fi
# Common.sh changes (affects all images)
if echo "$CHANGED_FILES" | grep -qE '^ubuntu/24\.04/common\.sh$'; then
echo "common=true" >> $GITHUB_OUTPUT
else
echo "common=false" >> $GITHUB_OUTPUT
fi
# dind-box changes (issue #80)
if echo "$CHANGED_FILES" | grep -qE '^(ubuntu/24\.04/dind/|docs/dind/|tests/dind/)'; then
echo "dind=true" >> $GITHUB_OUTPUT
else
echo "dind=false" >> $GITHUB_OUTPUT
fi
- name: Detect per-language changes
id: language-changes
run: |
CHANGED_FILES=$(cat /tmp/changed-files.txt)
for lang in python go rust java kotlin ruby php perl swift lean rocq cpp assembly; do
if echo "$CHANGED_FILES" | grep -qE "^ubuntu/24\.04/${lang}/"; then
echo "${lang}=true" >> $GITHUB_OUTPUT
else
echo "${lang}=false" >> $GITHUB_OUTPUT
fi
done
- name: Determine if build is needed
id: should-build
run: |
# For workflow_dispatch, always build (regardless of mode)
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: manual dispatch (mode: ${{ github.event.inputs.release_mode }})"
exit 0
fi
# Trigger build on any relevant changes
if [ "${{ steps.changes.outputs.docker }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: Dockerfile changes"
elif [ "${{ steps.changes.outputs.scripts }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: scripts changes"
elif [ "${{ steps.changes.outputs.ubuntu }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: ubuntu modular scripts changes"
elif [ "${{ steps.changes.outputs.workflow }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: workflow changes"
elif [ "${{ steps.changes.outputs.version }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: VERSION file changes"
elif [ "${{ steps.image-changes.outputs.dind }}" = "true" ]; then
echo "result=true" >> $GITHUB_OUTPUT
echo "Build triggered by: dind docs/tests changes"
else
echo "result=false" >> $GITHUB_OUTPUT
echo "No build needed: no relevant changes detected"
fi
# === BUILD AND TEST DOCKER IMAGES (PR) — issue #82 ===
#
# On every pull request we exercise *all* image configurations in parallel,
# each on its own clean GitHub-hosted VM with maximum free disk space. The
# parallel layout mirrors the production release matrix:
#
# pr-test-js (1 job) - JS base box
# pr-test-essentials (1 job) - essentials box on JS
# pr-test-language (matrix: 11) - one job per language box
# pr-test-full (1 job) - full-box (all languages)
# pr-test-dind (matrix: 14) - one job per dind variant
# (js, essentials, 11 languages, full)
# docker-build-test (1 job) - aggregator for branch protection
#
# Each job rebuilds its required base chain locally with plain `docker build`
# against the host Docker daemon. We deliberately do NOT use buildx with the
# docker-container driver here because subsequent `FROM box-js` /
# `FROM box-essentials` resolution in that driver would attempt a registry
# pull (which fails on PR forks and on Docker Hub outages). The trade-off is
# that each VM rebuilds JS and essentials from source — fine because every VM
# has 30 GB freed up front and the parallel matrix means wall-clock is bound
# by the slowest single image, not by the depth of the chain.
#
# Every build job runs `jlumbroso/free-disk-space@main` first to reclaim
# ~30 GB before building, fixing the "no space left on device" regression
# captured in run 25075335426 (see docs/case-studies/issue-82/).
#
# See: docs/case-studies/issue-82/CASE-STUDY.md
# --- Tier 1: JS box ---
pr-test-js:
name: pr-test / js
runs-on: ubuntu-24.04
timeout-minutes: 30
needs: [detect-changes, version-check, changeset-check]
if: |
always() &&
needs.detect-changes.result == 'success' &&
(needs.version-check.result == 'success' || needs.version-check.result == 'skipped') &&
(needs.changeset-check.result == 'success' || needs.changeset-check.result == 'skipped') &&
github.event_name == 'pull_request' &&
needs.detect-changes.outputs.should-build == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Build JS box (amd64)
run: |
set -e
echo "=== Building JS box ==="
docker build -f ubuntu/24.04/js/Dockerfile -t box-js .
- name: Test JS box
run: |
set -e
echo "=== Testing JS box ==="
docker run --rm box-js bash -c '. $HOME/.nvm/nvm.sh && node --version'
docker run --rm box-js bash -c 'export PATH=$HOME/.bun/bin:$PATH && bun --version'
docker run --rm box-js bash -c 'export PATH=$HOME/.deno/bin:$PATH && deno --version'
echo "=== JS box tests passed ==="
# --- Tier 2: essentials box ---
pr-test-essentials:
name: pr-test / essentials
runs-on: ubuntu-24.04
timeout-minutes: 30
needs: [detect-changes, version-check, changeset-check, pr-test-js]
if: |
always() &&
needs.pr-test-js.result == 'success' &&
github.event_name == 'pull_request' &&
needs.detect-changes.outputs.should-build == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Build JS + essentials chain
run: |
set -e
echo "=== Building JS box ==="
docker build -f ubuntu/24.04/js/Dockerfile -t box-js .
echo ""
echo "=== Building essentials box (on JS) ==="
docker build -f ubuntu/24.04/essentials-box/Dockerfile \
--build-arg JS_IMAGE=box-js -t box-essentials .
- name: Test essentials box
run: |
set -e
echo "=== Testing essentials box ==="
docker run --rm box-essentials gh --version
docker run --rm box-essentials glab --version
docker run --rm box-essentials gh-setup-git-identity --version
docker run --rm box-essentials glab-setup-git-identity --version
echo "=== Essentials box tests passed ==="
# --- Tier 3: per-language boxes (parallel matrix, one VM each) ---
pr-test-language:
name: pr-test / ${{ matrix.language }}
runs-on: ubuntu-24.04
timeout-minutes: 45
needs: [detect-changes, version-check, changeset-check, pr-test-essentials]
if: |
always() &&
needs.pr-test-essentials.result == 'success' &&
github.event_name == 'pull_request' &&
needs.detect-changes.outputs.should-build == 'true'
strategy:
fail-fast: false
matrix:
language: [python, go, rust, java, kotlin, ruby, php, perl, swift, lean, rocq]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Build JS + essentials + ${{ matrix.language }} chain
run: |
set -e
echo "=== Building JS box ==="
docker build -f ubuntu/24.04/js/Dockerfile -t box-js .
echo ""
echo "=== Building essentials box (on JS) ==="
docker build -f ubuntu/24.04/essentials-box/Dockerfile \
--build-arg JS_IMAGE=box-js -t box-essentials .
echo ""
echo "=== Building ${{ matrix.language }} box (on essentials) ==="
docker build -f "ubuntu/24.04/${{ matrix.language }}/Dockerfile" \
--build-arg ESSENTIALS_IMAGE=box-essentials \
-t "box-${{ matrix.language }}" .
- name: Test ${{ matrix.language }} box
run: |
set -e
LANG="${{ matrix.language }}"
IMG="box-${LANG}"
echo "=== Testing ${LANG} box (${IMG}) ==="
case "$LANG" in
python)
docker run --rm "$IMG" python3 --version
docker run --rm "$IMG" pip3 --version
;;
go)
docker run --rm "$IMG" go version
;;
rust)
docker run --rm "$IMG" rustc --version
docker run --rm "$IMG" cargo --version
docker run --rm "$IMG" rustup --version
;;
java)
docker run --rm "$IMG" java -version
;;
kotlin)
docker run --rm "$IMG" kotlin -version
;;
ruby)
docker run --rm "$IMG" ruby --version
docker run --rm "$IMG" gem --version
;;
php)
docker run --rm "$IMG" php --version
echo "=== PHP install method ==="
docker run --rm "$IMG" cat /home/box/.php-install-method
;;
perl)
docker run --rm "$IMG" perl --version
;;
swift)
docker run --rm "$IMG" swift --version
;;
lean)
docker run --rm "$IMG" lean --version
;;
rocq)
# rocq is invoked via "rocq --version" but historically coqc; check both
docker run --rm "$IMG" bash -c 'rocq --version 2>/dev/null || coqc --version'
;;
esac
echo "=== ${LANG} box tests passed ==="
# --- Tier 4: full box (integration smoke test, all languages on one VM) ---
pr-test-full:
name: pr-test / full
runs-on: ubuntu-24.04
timeout-minutes: 90
needs: [detect-changes, version-check, changeset-check, pr-test-language]
if: |
always() &&
needs.pr-test-language.result == 'success' &&
github.event_name == 'pull_request' &&
needs.detect-changes.outputs.should-build == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Set up Docker Buildx
uses: ./.github/actions/setup-buildx-resilient
- name: Build full chain (JS -> essentials -> languages -> full)
run: |
set -e
echo "=== Building JS box ==="
docker build -f ubuntu/24.04/js/Dockerfile -t box-js .
echo ""
echo "=== Building essentials box (on JS) ==="
docker build -f ubuntu/24.04/essentials-box/Dockerfile \
--build-arg JS_IMAGE=box-js -t box-essentials .
echo ""
echo "=== Building language images (on essentials) ==="
for lang in python go rust java kotlin ruby php perl swift lean rocq; do
echo ""
echo "--- Building ${lang} box ---"
docker build -f "ubuntu/24.04/${lang}/Dockerfile" \
--build-arg ESSENTIALS_IMAGE=box-essentials \
-t "box-${lang}" .
done
echo ""
echo "=== Building full box (multi-stage from all language images) ==="
docker build -f ubuntu/24.04/full-box/Dockerfile \
--build-arg ESSENTIALS_IMAGE=box-essentials \
--build-arg PYTHON_IMAGE=box-python \
--build-arg GO_IMAGE=box-go \
--build-arg RUST_IMAGE=box-rust \
--build-arg JAVA_IMAGE=box-java \
--build-arg KOTLIN_IMAGE=box-kotlin \
--build-arg RUBY_IMAGE=box-ruby \
--build-arg PHP_IMAGE=box-php \
--build-arg PERL_IMAGE=box-perl \
--build-arg SWIFT_IMAGE=box-swift \
--build-arg LEAN_IMAGE=box-lean \
--build-arg ROCQ_IMAGE=box-rocq \
-t box-test .
- name: Test full box
run: |
set -e
echo "=== Testing full box ==="
echo "Note: Using entrypoint script which initializes all environments"
# JavaScript/TypeScript runtimes
docker run --rm box-test node --version
docker run --rm box-test bun --version
docker run --rm box-test deno --version
# Python (pyenv)
docker run --rm box-test python3 --version
docker run --rm box-test pip3 --version
# Go
docker run --rm box-test go version
# Rust (rustup + cargo + rustc)
docker run --rm box-test rustc --version
docker run --rm box-test cargo --version
docker run --rm box-test rustup --version
# Java/JVM (SDKMAN)
docker run --rm box-test java -version
docker run --rm box-test kotlin -version
# Ruby (rbenv)
docker run --rm box-test ruby --version
docker run --rm box-test gem --version
# PHP
docker run --rm box-test php --version
# Perl (perlbrew)
docker run --rm box-test perl --version
# Swift
docker run --rm box-test swift --version
# Lean/Mathlib (elan)
docker run --rm box-test lean --version
# Dotnet
docker run --rm box-test dotnet --version
# R language
docker run --rm box-test Rscript --version
# CLI tools
docker run --rm box-test gh --version
docker run --rm box-test glab --version
docker run --rm box-test gh-setup-git-identity --version
docker run --rm box-test glab-setup-git-identity --version
# expect (interactive automation tool, issue #64)
docker run --rm box-test expect -v
echo ""
echo "=== PHP install method check ==="
docker run --rm box-php cat /home/box/.php-install-method
docker run --rm box-test cat /home/box/.php-install-method
echo ""
echo "=== All full box tests passed ==="
# --- Tier 5: dind-box variants (parallel matrix: 14 variants, one VM each) — issue #80 ---
# Each dind variant rebuilds its base chain (JS + essentials + optional lang/full)
# locally and then layers dind on top, so this matrix only depends on
# pr-test-essentials having validated the base layer; it can run in parallel
# with the per-language and full-box jobs to minimise wall-clock time.
pr-test-dind:
name: pr-test / dind-${{ matrix.variant }}
runs-on: ubuntu-24.04
timeout-minutes: 60
needs: [detect-changes, version-check, changeset-check, pr-test-essentials]
if: |
always() &&
needs.pr-test-essentials.result == 'success' &&
github.event_name == 'pull_request' &&
needs.detect-changes.outputs.should-build == 'true'
strategy:
fail-fast: false
matrix:
# variant -> base box flavour. Special value "full" rebuilds the entire chain;
# everything else needs only JS+essentials+<lang>.
variant: [js, essentials, python, go, rust, java, kotlin, ruby, php, perl, swift, lean, rocq, full]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Set up Docker Buildx
uses: ./.github/actions/setup-buildx-resilient
- name: Build base box for dind variant
run: |
set -e
VARIANT="${{ matrix.variant }}"
echo "=== Building JS box (base layer) ==="
docker build -f ubuntu/24.04/js/Dockerfile -t box-js .
if [ "$VARIANT" = "js" ]; then
BASE_IMAGE="box-js"
else
echo ""
echo "=== Building essentials box ==="
docker build -f ubuntu/24.04/essentials-box/Dockerfile \
--build-arg JS_IMAGE=box-js -t box-essentials .
if [ "$VARIANT" = "essentials" ]; then
BASE_IMAGE="box-essentials"
elif [ "$VARIANT" = "full" ]; then
echo ""
echo "=== Building all language images (full-box prerequisites) ==="
for lang in python go rust java kotlin ruby php perl swift lean rocq; do
echo "--- Building ${lang} box ---"
docker build -f "ubuntu/24.04/${lang}/Dockerfile" \
--build-arg ESSENTIALS_IMAGE=box-essentials \
-t "box-${lang}" .
done
echo ""
echo "=== Building full box ==="
docker build -f ubuntu/24.04/full-box/Dockerfile \
--build-arg ESSENTIALS_IMAGE=box-essentials \
--build-arg PYTHON_IMAGE=box-python \
--build-arg GO_IMAGE=box-go \
--build-arg RUST_IMAGE=box-rust \
--build-arg JAVA_IMAGE=box-java \
--build-arg KOTLIN_IMAGE=box-kotlin \
--build-arg RUBY_IMAGE=box-ruby \
--build-arg PHP_IMAGE=box-php \
--build-arg PERL_IMAGE=box-perl \
--build-arg SWIFT_IMAGE=box-swift \
--build-arg LEAN_IMAGE=box-lean \
--build-arg ROCQ_IMAGE=box-rocq \
-t box-full .
BASE_IMAGE="box-full"
else
echo ""
echo "=== Building ${VARIANT} box ==="
docker build -f "ubuntu/24.04/${VARIANT}/Dockerfile" \
--build-arg ESSENTIALS_IMAGE=box-essentials \
-t "box-${VARIANT}" .
BASE_IMAGE="box-${VARIANT}"
fi
fi
echo "BASE_IMAGE=${BASE_IMAGE}" >> "$GITHUB_ENV"
- name: Build dind-box variant
run: |
set -e
echo "=== Building dind-${{ matrix.variant }} on ${BASE_IMAGE} ==="
docker build -f ubuntu/24.04/dind/Dockerfile \
--build-arg BASE_IMAGE="${BASE_IMAGE}" \
-t "box-dind-${{ matrix.variant }}" .
- name: Test dind-box variant
run: |
set -e
IMG="box-dind-${{ matrix.variant }}"
echo "=== Testing ${IMG} (no privileged mode in PR CI) ==="
# Regression check for issue #88: docker exec and entrypoint-bypassed
# shells use the image's configured USER, so dind variants must keep
# Config.User aligned with the regular box images.
CONFIG_USER=$(docker inspect --format '{{.Config.User}}' "$IMG")
if [ "$CONFIG_USER" != "box" ]; then
echo "Expected ${IMG} Config.User to be box, got '${CONFIG_USER:-<empty>}'"
exit 1
fi
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'test "$(whoami)" = box'
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'test "$HOME" = /home/box'
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'sudo -n /usr/bin/dockerd --version'
# Verify Docker CLI, dockerd binary, buildx and compose plugins are present.
# We do NOT start dockerd here because GitHub-hosted runners disallow --privileged.
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'docker --version'
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'dockerd --version'
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'docker buildx version'
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'docker compose version'
docker run --rm --entrypoint=/bin/bash "$IMG" -c 'cat /etc/box/variant'
echo "=== ${IMG} smoke tests passed ==="
- name: Test documented dind examples
if: matrix.variant == 'js'
env:
DIND_IMAGE: box-dind-js
DIND_WAIT_SECONDS: "60"
run: |
set -e
echo "=== Testing documented dind examples against ${DIND_IMAGE} ==="
tests/dind/example-basic-docker-ps.sh
tests/dind/example-commit-cycle.sh
tests/dind/example-sudoers-extension.sh
tests/dind/example-storage-driver-vfs.sh
tests/dind/example-preload-images.sh
echo "=== Documented dind examples passed ==="
# --- Aggregator: single status check for branch protection ---
# GitHub branch protection rules can require this one job to pass instead of
# listing every parallel pr-test-* job individually.
docker-build-test:
name: docker-build-test
runs-on: ubuntu-24.04
needs: [detect-changes, version-check, changeset-check, pr-test-js, pr-test-essentials, pr-test-language, pr-test-full, pr-test-dind]
if: |
always() &&
github.event_name == 'pull_request' &&
needs.detect-changes.outputs.should-build == 'true'
steps:
- name: Aggregate pr-test results
run: |
set -e
echo "pr-test-js: ${{ needs.pr-test-js.result }}"
echo "pr-test-essentials: ${{ needs.pr-test-essentials.result }}"
echo "pr-test-language: ${{ needs.pr-test-language.result }}"
echo "pr-test-full: ${{ needs.pr-test-full.result }}"
echo "pr-test-dind: ${{ needs.pr-test-dind.result }}"
fail=0
for r in \
"${{ needs.pr-test-js.result }}" \
"${{ needs.pr-test-essentials.result }}" \
"${{ needs.pr-test-language.result }}" \
"${{ needs.pr-test-full.result }}" \
"${{ needs.pr-test-dind.result }}"; do
case "$r" in
success|skipped) ;;
*) fail=1 ;;
esac
done
if [ "$fail" -ne 0 ]; then
echo "::error::One or more pr-test jobs did not succeed."
exit 1
fi
echo "All pr-test jobs succeeded."
# === BUILD JS BOX (amd64) ===
# JS box is the base layer - built first, other images depend on it
build-js-amd64:
runs-on: ubuntu-24.04
needs: [detect-changes]
if: |
always() &&
needs.detect-changes.result == 'success' &&
(
(github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.should-build == 'true') ||
(github.event_name == 'workflow_dispatch')
) &&
(
needs.detect-changes.outputs.js-changed == 'true' ||
needs.detect-changes.outputs.common-changed == 'true' ||
needs.detect-changes.outputs.version-changed == 'true' ||
github.event_name == 'workflow_dispatch'
)
permissions:
contents: read
packages: write
outputs:
built: ${{ steps.result.outputs.built }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
# Issue #82: free disk space on every build job's runner before pulling
# base images / running buildx so that COPY --from=*-stage and large
# apt installs never hit "no space left on device" mid-build.
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Get latest version
id: version
run: |
git pull origin main || true
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: ./.github/actions/setup-buildx-resilient
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Issue #82: tolerate Docker Hub login failure (e.g. expired DOCKERHUB_TOKEN)
# so that pushes to GHCR still proceed instead of taking down every build job.
- name: Log in to Docker Hub