Repository navigation
1281 lines (1184 loc) · 63 KB
/
Copy pathdeploy.yml
File metadata and controls
1281 lines (1184 loc) · 63 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/CD Pipeline
# Documentation-only changes still trigger this workflow, on purpose. Skipping
# it at the trigger level leaves every required check in a pending state that
# can never arrive, and the pull request can then never merge. GitHub documents
# exactly this: a workflow skipped by path filtering keeps its checks pending
# and blocks the merge, while a JOB skipped by an if: conditional reports
# Success and does not. So the filtering lives on the jobs below, not here.
#
# The scope check only applies to pull requests. A push to master always runs
# the full pipeline, which keeps :edge built for every master commit. That
# matters: release-fast-path.yml re-tags :edge to :vX.Y.Z only when the :edge
# revision label matches the tagged commit, so a master commit without an image
# breaks tagging.
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
inputs:
images_published:
description: 'Release fast path already published the tag images'
type: boolean
default: false
permissions:
contents: read
packages: write
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
STAGING_COMPOSE_FILE: docker-compose.staging.yml
STAGING_SERVICE: staging-go
STAGING_CONTAINER: corescope-staging-go
# Pipeline. The test jobs and the image build run side by side; only the GHCR
# push waits for all of them:
# changes ─┬─ go-test ─────────────────────────┐
# ├─ race-test (ingestor changes only) ─┤
# ├─ e2e-shard ×3 ── e2e-test (gate) ───┼─ build-and-publish → deploy, publish
# └─ image-check (two-arch build) ──────┘
# PRs stop after build-and-publish (no GHCR push). Master continues to deploy + badges.
jobs:
# ───────────────────────────────────────────────────────────────
# 0. Change scope — decides whether the expensive jobs below run.
# ───────────────────────────────────────────────────────────────
changes:
name: "🔎 Change scope"
runs-on: ubuntu-latest
outputs:
code: ${{ steps.scope.outputs.code }}
ingestor: ${{ steps.scope.outputs.ingestor }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Decide whether anything but documentation changed
id: scope
run: |
set -euo pipefail
# Only pull requests are scoped. Pushes and dispatches always count as
# code, so master keeps producing an :edge image and tag builds are
# never skipped.
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
echo "ingestor=true" >> "$GITHUB_OUTPUT"
echo "event=${{ github.event_name }} -> full pipeline"
exit 0
fi
CHANGED=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}")
# Empty diff means something is off; run everything rather than guess.
if [ -z "$CHANGED" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
echo "ingestor=true" >> "$GITHUB_OUTPUT"
echo "empty diff -> full pipeline"
exit 0
fi
echo "Changed files:"
echo "$CHANGED" | sed 's/^/ /'
if echo "$CHANGED" | grep -qvE '(^docs/|[.]md$|^LICENSE$)'; then
echo "code=true" >> "$GITHUB_OUTPUT"
echo "-> non-documentation files changed, full pipeline"
else
echo "code=false" >> "$GITHUB_OUTPUT"
echo "-> documentation only, heavy jobs skip (and report Success)"
fi
# The race detector is its own job, and it only earns its ten minutes
# when the code it inspects changed. A frontend or docs PR cannot
# introduce a data race in the ingestor.
if echo "$CHANGED" | grep -qE '^cmd/ingestor/.*[.]go$'; then
echo "ingestor=true" >> "$GITHUB_OUTPUT"
echo "-> ingestor Go files changed, race detector runs"
else
echo "ingestor=false" >> "$GITHUB_OUTPUT"
echo "-> no ingestor Go changes, race detector skips"
fi
# ───────────────────────────────────────────────────────────────
# 1a. Race detector (ingestor) — its own job on purpose
# ───────────────────────────────────────────────────────────────
# Runs beside "Go Build & Test" rather than inside it, so its ten-odd
# minutes overlap the E2E job instead of extending the critical path, and
# only when ingestor Go files changed. A frontend or documentation PR cannot
# introduce a data race here, and paying for the check on every PR is what
# gets a check switched off again.
#
# The server has -race in its own step already; this closes the same gap for
# the ingestor, which carries an atomic.Pointer snapshot (the region key
# set) whose safety is an argument until something checks it.
race-test:
name: "🏁 Race detector (ingestor)"
runs-on: ubuntu-latest
needs: [changes]
if: needs.changes.outputs.ingestor == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go 1.27
uses: actions/setup-go@v6
with:
go-version: '1.27'
# All modules: a -race build of a cgo package is the slowest thing in
# this pipeline, and setup-go caches ~/.cache/go-build as well as the
# module cache, so a key that misses on an unrelated module hurts most
# here. Same reasoning as go-test below.
cache-dependency-path: "**/go.sum"
- name: go test -race
run: |
set -e -o pipefail
cd cmd/ingestor
go test -timeout 30m -race ./...
# ───────────────────────────────────────────────────────────────
# 1. Go Build & Test
# ───────────────────────────────────────────────────────────────
go-test:
name: "✅ Go Build & Test"
runs-on: ubuntu-latest
needs: [changes]
if: needs.changes.outputs.code == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Clean Go module cache
run: rm -rf ~/go/pkg/mod 2>/dev/null || true
- name: Set up Go 1.27
uses: actions/setup-go@v6
with:
go-version: '1.27'
# All modules, not just two: the cgo SQLite build is expensive to
# redo, and setup-go caches ~/.cache/go-build as well as the module
# cache, so a key that misses on an unrelated module hurts.
cache-dependency-path: "**/go.sum"
- name: Enforce gofmt + go vet (issue #1859)
run: |
set -e
# gofmt: every tracked *.go file except the misnamed Dockerfile.go,
# which is a Dockerfile (FROM ...) that gofmt cannot parse.
unformatted=$(gofmt -l $(git ls-files '*.go' | grep -vi 'Dockerfile.go'))
if [ -n "$unformatted" ]; then
echo "::error::gofmt required on these files:"
echo "$unformatted"
exit 1
fi
echo "gofmt: clean"
# go vet: multi-module repo, so vet each module in turn.
for mod in $(git ls-files '*go.mod' | sed 's#/go.mod##'); do
echo "== go vet $mod =="
( cd "$mod" && go vet ./... )
done
- name: Build and test Go server (with coverage)
run: |
set -e -o pipefail
cd cmd/server
go build .
# -race gates PR #1208's atomic.Pointer migration: the race-detector
# is what makes path_inspect_atomic_race_test.go actually assert.
go test -timeout 20m -race -coverprofile=server-coverage.out ./... 2>&1 | tee server-test.log
# The e2etest build (fake mailer + /__e2e/last-mail) has its own tests.
go test -tags e2etest -count=1 -run 'E2E' .
echo "--- Go Server Coverage ---"
go tool cover -func=server-coverage.out | tail -1
- name: Build and test Go ingestor (with coverage)
run: |
set -e -o pipefail
cd cmd/ingestor
go build .
go test -timeout 20m -coverprofile=ingestor-coverage.out ./... 2>&1 | tee ingestor-test.log
echo "--- Go Ingestor Coverage ---"
go tool cover -func=ingestor-coverage.out | tail -1
- name: Build and test channel library + decrypt CLI
run: |
set -e -o pipefail
cd internal/channel
go test ./...
echo "--- Channel library tests passed ---"
cd ../../cmd/decrypt
go build -ldflags="-s -w" -o corescope-decrypt .
go test ./...
echo "--- Decrypt CLI tests passed ---"
- name: Test user-management modules (users, mailer)
run: |
set -e -o pipefail
cd internal/users && go test -race ./...
cd ../mailer && go test -race ./...
echo "--- users + mailer tests passed ---"
- name: Test migrate CLI + dbschema
run: |
set -e -o pipefail
# Neither module had CI test execution before the mattn/go-sqlite3
# migration; both open the database, and dbschema owns the migrations.
cd internal/dbschema
go test ./...
cd ../../cmd/migrate
go build -o /dev/null .
go test ./...
echo "--- migrate + dbschema tests passed ---"
- name: Verify Dockerfile COPY invariants (issue #1316)
run: bash scripts/check-dockerfile-internal-pkgs.sh
- name: Staging disk-monitor unit tests (issue #1684)
run: bash scripts/staging/test-disk-monitor.sh
- name: QA SQL parameter-binding unit tests (issue #1977)
run: bash qa/scripts/test-blacklist-sql.sh
- name: Lint CSS variables (issue #1128)
run: |
set -e
node scripts/check-css-vars.js
node scripts/test-check-css-vars.js
- name: Run JS unit tests
run: sh test-all.sh
- name: 🛡️ Preflight XSS gate — actual --diff check (PR only)
# The fixture self-test above (test-preflight-xss-gate.js) only
# asserts the script's behavior against fixtures. It does NOT scan
# the PR's own changes. This step closes that gap by running the
# gate against added lines in public/**/*.{js,html} on the PR.
# Gate is PR-scoped only (per djb finding: merge commits would
# slip an opt-out otherwise). Master pushes skip this step.
if: github.event_name == 'pull_request'
env:
PR_BODY: ${{ github.event.pull_request.body }}
PREFLIGHT_PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ' ') }}
run: |
set -e
git fetch origin master --depth=50 2>&1 | tail -3 || true
# Materialize PR body to a file for the opt-out parser.
printf '%s' "$PR_BODY" > /tmp/pr-body.md
PREFLIGHT_PR_BODY=/tmp/pr-body.md bash scripts/check-xss-sinks.sh --diff origin/master
- name: 🧹 Frontend lint (eslint no-undef) — issue #1342
run: |
set -e
# Use eslint@8 (legacy .eslintrc.json). Don't migrate to flat-config / eslint@9.
# --no-save: avoid touching package.json / no committed node_modules.
npm install --no-save --no-audit --no-fund eslint@8
npx eslint public/*.js
- name: Verify proto syntax
run: |
set -e
sudo apt-get update -qq
sudo apt-get install -y protobuf-compiler
for proto in proto/*.proto; do
echo " ✓ $(basename "$proto")"
protoc --proto_path=proto --descriptor_set_out=/dev/null "$proto"
done
echo "✅ All .proto files are syntactically valid"
- name: Generate Go coverage badges
if: success()
run: |
mkdir -p .badges
SERVER_COV="0"
if [ -f cmd/server/server-coverage.out ]; then
SERVER_COV=$(cd cmd/server && go tool cover -func=server-coverage.out | tail -1 | grep -oP '[\d.]+(?=%)')
fi
SERVER_COLOR="red"
if [ "$(echo "$SERVER_COV >= 80" | bc -l 2>/dev/null)" = "1" ]; then SERVER_COLOR="green"
elif [ "$(echo "$SERVER_COV >= 60" | bc -l 2>/dev/null)" = "1" ]; then SERVER_COLOR="yellow"; fi
echo "{\"schemaVersion\":1,\"label\":\"go server coverage\",\"message\":\"${SERVER_COV}%\",\"color\":\"${SERVER_COLOR}\"}" > .badges/go-server-coverage.json
INGESTOR_COV="0"
if [ -f cmd/ingestor/ingestor-coverage.out ]; then
INGESTOR_COV=$(cd cmd/ingestor && go tool cover -func=ingestor-coverage.out | tail -1 | grep -oP '[\d.]+(?=%)')
fi
INGESTOR_COLOR="red"
if [ "$(echo "$INGESTOR_COV >= 80" | bc -l 2>/dev/null)" = "1" ]; then INGESTOR_COLOR="green"
elif [ "$(echo "$INGESTOR_COV >= 60" | bc -l 2>/dev/null)" = "1" ]; then INGESTOR_COLOR="yellow"; fi
echo "{\"schemaVersion\":1,\"label\":\"go ingestor coverage\",\"message\":\"${INGESTOR_COV}%\",\"color\":\"${INGESTOR_COLOR}\"}" > .badges/go-ingestor-coverage.json
echo "## Go Coverage" >> $GITHUB_STEP_SUMMARY
echo "| Module | Coverage |" >> $GITHUB_STEP_SUMMARY
echo "|--------|----------|" >> $GITHUB_STEP_SUMMARY
echo "| Server | ${SERVER_COV}% |" >> $GITHUB_STEP_SUMMARY
echo "| Ingestor | ${INGESTOR_COV}% |" >> $GITHUB_STEP_SUMMARY
- name: Upload Go coverage badges
if: success()
uses: actions/upload-artifact@v6
with:
name: go-badges
path: .badges/go-*.json
retention-days: 1
if-no-files-found: ignore
include-hidden-files: true
# ───────────────────────────────────────────────────────────────
# 2. Playwright E2E Tests (against Go server with fixture DB)
# ───────────────────────────────────────────────────────────────
# Three shards on three runners, each with its own server and fixture copy,
# so no shard shares a browser, a CPU or server state with another. One
# runner per shard rather than parallel suites on one runner: the gesture and
# animation suites are timing-sensitive and would flake under CPU contention.
#
# It needs only `changes`, not go-test: this job builds its own binaries and
# uses nothing go-test produces. build-and-publish still needs both, so
# nothing reaches GHCR unless every test job passed.
e2e-shard:
name: "🎭 Playwright E2E shard ${{ matrix.shard }}/3"
needs: [changes]
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1, 2, 3]
env:
SHARD: ${{ matrix.shard }}
E2E_SHARDS: 3
defaults:
run:
shell: bash
if: needs.changes.outputs.code == 'true' && !(startsWith(github.ref, 'refs/tags/v') && inputs.images_published)
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Node.js 22
uses: actions/setup-node@v5
with:
node-version: '22'
- name: Clean Go module cache
run: rm -rf ~/go/pkg/mod 2>/dev/null || true
- name: Set up Go 1.27
uses: actions/setup-go@v6
with:
go-version: '1.27'
cache-dependency-path: "**/go.sum"
- name: Build Go server
run: |
cd cmd/server
go build -o ../../corescope-server .
echo "Go server built successfully"
# Only test-user-management-e2e.js uses the e2etest build and its server,
# and it runs on shard 3. Moving that suite means moving these two too;
# it fails loudly (nothing on port 13582) rather than skipping.
- name: Build Go server (e2etest tag, user management)
if: matrix.shard == 3
run: |
cd cmd/server
go build -tags e2etest -o ../../corescope-server-e2e .
- name: Build Go migrate tool
run: |
cd cmd/migrate
go build -o ../../corescope-migrate .
echo "Go migrate tool built successfully"
- name: Install npm dependencies
run: npm ci --production=false
- name: Install Playwright browser
run: |
npx playwright install chromium 2>/dev/null || true
npx playwright install-deps chromium 2>/dev/null || true
- name: Instrument frontend JS for coverage
run: sh scripts/instrument-frontend.sh
- name: Freshen fixture timestamps
run: bash tools/freshen-fixture.sh test-fixtures/e2e-fixture.db
- name: Seed grouped-packet row for #1486 collapse test
# The committed fixture has 499 packets, each with exactly ONE
# observation, so the packets-page renders only flat
# (select-hash) rows. The #1486 repro needs at least one grouped
# (toggle-select) row. Insert a NEW transmission with 3
# observations.
#
# The server's async hash-migrate (cmd/server/hash_migrate.go)
# recomputes `transmissions.hash` from `raw_hex` via
# ComputeContentHash(), so the inserted hash MUST equal that
# function's output for the chosen raw_hex — otherwise the row
# gets relabelled and the E2E can't find it.
#
# raw_hex 15000102030405060708090a0b0c0d0e0f
# → header=0x15 (route_type=1, payload_type=5)
# → ComputeContentHash(...) = fae0c9e6d357a814
#
# Fixed old timestamps keep the row behind the freshly shifted
# fixture observations and outside the default 15-min UI window.
# The #1486 and #2104 tests reach it via an explicit hash +
# ?timeWindow=0 deep-link.
run: |
sqlite3 test-fixtures/e2e-fixture.db <<'SQL'
-- Sort the seeded row LAST in BOTH default packets views:
-- • flat view sorts by transmissions.id DESC → id=0 puts it last
-- • grouped view (#default for the packets page) sorts by
-- MAX(observations.timestamp) DESC → we must keep our obs
-- timestamps OLDER than every other fixture observation.
-- freshen-fixture.sh shifts fixture observations forward.
-- Keep this row at 2026-05-15 so it sorts LAST in the grouped
-- view too; the #1486 and #2104 tests use the explicit deep-link.
INSERT INTO transmissions(id,raw_hex,hash,first_seen,route_type,payload_type,payload_version,decoded_json,channel_hash,from_pubkey)
VALUES (0,'15000102030405060708090a0b0c0d0e0f','fae0c9e6d357a814','2026-05-15T00:00:00Z',1,5,0,'{"type":"CHAN","channel":"#test","text":"#1486 fixture"}',NULL,NULL);
INSERT INTO observations(transmission_id,observer_idx,direction,snr,rssi,score,path_json,timestamp,resolved_path) VALUES
(0,1,'rx',5.0,-95,0,'["AA"]',CAST(strftime('%s','2026-05-15T00:00:00Z') AS INTEGER),'["aa00000000000000000000000000000000000000000000000000000000000000"]'),
(0,2,'rx',5.5,-92,0,'["BB"]',CAST(strftime('%s','2026-05-15T00:00:00Z') AS INTEGER),'["bb00000000000000000000000000000000000000000000000000000000000000"]'),
(0,3,'rx',6.0,-90,0,'["CC"]',CAST(strftime('%s','2026-05-15T00:00:00Z') AS INTEGER),'["cc00000000000000000000000000000000000000000000000000000000000000"]');
-- #1791 fixture: a single GRP_DATA (payload_type=6) packet so the
-- E2E "Group Data filter" test has at least one row to filter on.
-- Use an obs timestamp within the default UI window so the row
-- appears with no time-window override.
--
-- raw_hex header byte 0x19 = bits 5-2 (payload)=0110=6 (GRP_DATA),
-- bits 1-0 (route)=01=1 (FLOOD).
-- path_len byte 0x00 = hash_size=1, hash_count=0 (zero-hop on-wire,
-- typical GRP_DATA going FLOOD). path_json/resolved_path are kept
-- EMPTY so the rendered hop-row count matches the hex-path byte
-- count (a prior fixture used path_json=["AA"] but raw_hex
-- path_len=0, which broke the "hex strip Path range matches hop
-- row count" E2E).
--
-- Note: id=-1000000 is a deliberately out-of-band sentinel id so
-- this synthetic fixture row cannot collide with real ingested
-- transmissions (real ids are positive autoincrement values).
INSERT INTO transmissions(id,raw_hex,hash,first_seen,route_type,payload_type,payload_version,decoded_json,channel_hash,from_pubkey)
VALUES (-1000000,'19000102030405060708090a0b0c0d0e0f','17910000deadbeef',strftime('%Y-%m-%dT%H:%M:%SZ','now'),1,6,0,'{"type":"GRP_DATA","channel":"#test","raw":"deadbeef"}',NULL,NULL);
INSERT INTO observations(transmission_id,observer_idx,direction,snr,rssi,score,path_json,timestamp,resolved_path) VALUES
(-1000000,1,'rx',7.0,-88,0,'[]',CAST(strftime('%s','now') AS INTEGER),'[]');
SQL
- name: Migrate fixture DB to current schema (#1287)
# Server now ASSERTs schema is migrated and refuses to start
# otherwise (cmd/server/main.go: dbschema.AssertReady). In prod
# the ingestor owns dbschema.Apply, but CI starts only the
# server against the committed e2e fixture — so we run the
# standalone migrate tool here to bring the fixture up to the
# required shape before the server boots.
run: ./corescope-migrate -db test-fixtures/e2e-fixture.db
- name: 'Seed distinct observation bytes for #2104'
# raw_hex exists only after migration. Keep the #1486 payload/hash
# while encoding each observation's existing one-hop path.
run: |
sqlite3 test-fixtures/e2e-fixture.db <<'SQL'
UPDATE observations SET raw_hex = CASE observer_idx
WHEN 1 THEN '1501aa0102030405060708090a0b0c0d0e0f'
WHEN 2 THEN '1501bb0102030405060708090a0b0c0d0e0f'
WHEN 3 THEN '1501cc0102030405060708090a0b0c0d0e0f'
END WHERE transmission_id = 0 AND observer_idx IN (1,2,3);
SQL
- name: Seed deterministic Path Inspector routes (#2060)
run: sqlite3 test-fixtures/e2e-fixture.db < test-fixtures/path-inspector.sql
- name: Start Go server with fixture DB
run: |
fuser -k 13581/tcp 2>/dev/null || true
sleep 1
./corescope-server -port 13581 -db test-fixtures/e2e-fixture.db -public public-instrumented &
echo $! > .server.pid
for i in $(seq 1 30); do
if curl -sf http://localhost:13581/api/healthz > /dev/null 2>&1; then
echo "Server ready after ${i}s"
break
fi
if [ "$i" -eq 30 ]; then
echo "Server failed to start within 30s"
exit 1
fi
sleep 1
done
- name: Start user-management E2E server (fake mailer)
if: matrix.shard == 3
run: |
fuser -k 13582/tcp 2>/dev/null || true
rm -rf /tmp/cs-um
mkdir -p /tmp/cs-um
# Own copy of the (already migrated and seeded) fixture; fresh users.db every run.
cp test-fixtures/e2e-fixture.db /tmp/cs-um/on.db
cat > /tmp/cs-um/config.json <<'JSON'
{
"port": 13582,
"userManagement": {
"enabled": true,
"dbPath": "/tmp/cs-um/users.db",
"adminEmails": ["admin@e2e.test"],
"publicBaseUrl": "http://localhost:13582",
"mail": { "provider": "fake", "fromEmail": "noreply@e2e.test" },
"channelProposals": { "enabled": true },
"notifications": { "enabled": true }
}
}
JSON
./corescope-server-e2e -config-dir /tmp/cs-um -port 13582 -db /tmp/cs-um/on.db -public public-instrumented &
echo $! > .server-um.pid
for i in $(seq 1 30); do
if curl -sf http://localhost:13582/api/healthz > /dev/null 2>&1; then echo "UM server ready after ${i}s"; break; fi
if [ "$i" -eq 30 ]; then echo "UM server failed to start within 30s"; exit 1; fi
sleep 1
done
- name: Run Playwright E2E tests (fail-fast)
run: |
# suite <shard> <file> [VAR=value ...]: runs tests/e2e/<file> with
# exactly those variables, but only on its own shard. The shard numbers
# balance the measured suite times; give a new suite the shard whose
# total is lowest. Anything but a number in 1..E2E_SHARDS (a missing
# number, 01, 4) fails the step, so a typo cannot silently drop a suite.
B=http://localhost:13581
suite() {
local shard=$1 file=$2
shift 2
if ! [[ "$shard" =~ ^[1-9][0-9]*$ ]] || [ "$shard" -gt "$E2E_SHARDS" ]; then
echo "::error::$file is assigned to shard $shard, outside 1..$E2E_SHARDS"
exit 1
fi
[ "$shard" -eq "$SHARD" ] || return 0
echo "=== E2E SUITE: $file ===" | tee -a e2e-output.txt
env "$@" node "tests/e2e/$file" 2>&1 | tee -a e2e-output.txt
}
suite 2 test-e2e-playwright.js BASE_URL=$B
# M5+M6 of #1668 — axe-core CI gate.
# M5: color-contrast on desktop dark+light.
# M6: expanded ruleset (image-alt, label, aria-required-attr,
# aria-valid-attr, aria-valid-attr-value, landmark-one-main,
# region, button-name, link-name, document-title, html-has-lang,
# duplicate-id) AND adds 375x812 mobile viewport (with
# color-contrast on mobile too).
# Allowlist: tests/a11y-allowlist.yaml (0 entries — hard pass policy).
# Per-viewport summary printed at the end; any net>0 fails the build.
suite 1 test-a11y-axe-1668.js BASE_URL=$B AXE_SCREENSHOT_DIR=/tmp/axe-1668
suite 2 test-filter-ux-e2e.js BASE_URL=$B
suite 1 test-channel-issue-1087-e2e.js BASE_URL=$B
suite 1 test-channel-issue-1111-e2e.js BASE_URL=$B
suite 2 test-map-modal-fluid-e2e.js BASE_URL=$B
suite 2 test-map-nodes-pagination-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-observer-iata-1188-e2e.js BASE_URL=$B
suite 2 test-issue-1639-observers-sort-e2e.js BASE_URL=$B
suite 2 test-issue-1758-ng-filter-rerenders-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-nav-fluid-1055-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-nav-priority-1102-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-nav-priority-1311-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-nav-priority-1391-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1413-nav-overlap-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1400-nav-vertical-clip.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-nav-more-floor-1139-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-bottom-nav-1061-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-gestures-1062-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-gestures-1185-scroll-discriminator-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-gesture-hints-1065-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-touch-gestures-coverage-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-channel-fluid-e2e.js BASE_URL=$B
suite 2 test-table-fluid-e2e.js BASE_URL=$B
suite 3 test-charts-fluid-1058-e2e.js BASE_URL=$B
suite 3 test-slideover-1056-e2e.js BASE_URL=$B
suite 3 test-issue-1692-packets-init-parallel-e2e.js BASE_URL=$B
suite 2 test-slideover-1168-munger-e2e.js BASE_URL=$B
suite 3 test-logo-pulse-1173-e2e.js BASE_URL=$B
suite 2 test-issue-1122-packets-filter-ux-e2e.js BASE_URL=$B
suite 3 test-issue-1128-packets-layout-e2e.js BASE_URL=$B
suite 3 test-issue-1128-multi-viewport-e2e.js BASE_URL=$B
suite 2 test-issue-1136-live-region-e2e.js BASE_URL=$B
suite 1 test-live-multibyte-only-e2e.js BASE_URL=$B
suite 3 test-issue-1150-404-state-e2e.js BASE_URL=$B
suite 2 test-issue-1146-path-link-contrast-e2e.js BASE_URL=$B
suite 1 test-issue-1705-subpath-contrast-e2e.js CHROMIUM_REQUIRE=1
suite 2 test-issue-1147-section-order-e2e.js BASE_URL=$B
suite 3 test-issue-1151-orphan-separators-e2e.js BASE_URL=$B
suite 3 test-issue-1486-collapse-reopens-detail-e2e.js BASE_URL=$B
suite 1 test-logo-rebrand-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-logo-theme-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-logo-default-sage-teal-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1109-hamburger-dropdown-visible-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-live-layout-1178-1179-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1205-live-controls-anchor-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-live-mql-leak-1180-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1204-live-panel-structure-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1234-live-chrome-pass2-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1206-vcr-overlap-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1833-legend-toggle-clickable-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1244-live-vcr-row-hints-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1510-live-nav-pin-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-live-fullscreen-1572-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1599-replay-freeze-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1648-m1-icons-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1648-m2-icons-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1648-m3-icons-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1648-m4-icons-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1657-analytics-channels-group-sprites-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1224-channels-mobile-ux-e2e.js BASE_URL=$B
suite 3 test-issue-1367-channels-chat-app-e2e.js BASE_URL=$B
suite 3 test-issue-1236-map-mobile-e2e.js BASE_URL=$B
suite 3 test-issue-1329-map-controls-accordion-e2e.js BASE_URL=$B
suite 1 test-issue-1273-qr-overlay-height-e2e.js BASE_URL=$B
suite 3 test-issue-1281-location-row-e2e.js BASE_URL=$B
suite 1 test-issue-1279-legend-p2-e2e.js BASE_URL=$B
suite 2 test-issue-1799-label-vocab-e2e.js BASE_URL=$B
suite 2 test-home-coverage-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-path-inspector-coverage-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1206-resize-observer-leak-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-nav-drawer-1064-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-audio-live-1297-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-audio-lab-1297-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-channel-decrypt-e2e.js BASE_URL=$B
suite 2 test-channel-qr-e2e.js BASE_URL=$B
suite 3 test-channel-color-picker-e2e.js BASE_URL=$B
suite 1 test-customize-theme-e2e.js BASE_URL=$B
suite 3 test-customize-branding-e2e.js BASE_URL=$B
suite 2 test-customize-display-e2e.js BASE_URL=$B
suite 3 test-customize-export-e2e.js BASE_URL=$B
suite 2 test-drag-manager-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1567-corner-clears-drag-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1306-collisions-terminology-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1374-route-map-a11y-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-channels-list-render-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-channels-selection-flow-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-channels-add-modal-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-channels-share-color-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-channels-ws-batch-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-channels-ws-race-1498-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1487-byop-modal-layout-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1630-reach-mobile-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-node-reach-coverage-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-issue-1640-compare-discovery-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-neighbor-map-btn-clip-e2e.js CHROMIUM_REQUIRE=1
suite 3 test-rx-coverage-viewport-e2e.js BASE_URL=$B
suite 1 test-rx-coverage-noise-e2e.js BASE_URL=$B
# Issue #2037: these eight sat in tests/e2e/ with no runner at all.
# Measured on upstream master in CI run 35340835178: all eight pass,
# 45 seconds together. test-rx-coverage-mobile-nav-e2e.js is the
# ninth that passed and is deliberately NOT here: it exits 0 with
# "SKIP (clientRxCoverage disabled on this deployment)", which is the
# default, so wiring it in would add a vacuous pass rather than a guard.
suite 2 test-1110-live-filter.js BASE_URL=$B
suite 3 test-analytics-fluid-charts.js BASE_URL=$B
suite 3 test-e2e-1267-mobile-vcr.js BASE_URL=$B
suite 2 test-issue-1274-legend-coverage-e2e.js BASE_URL=$B
suite 3 test-issue-1648-m5-icons-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-issue-1997-distance-building-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-channel-modal-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-issue-1522-trace-url-sync-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-marker-outline-weight.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 2 test-node-reach-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-packets-compact-columns-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-packets-scope-column.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-path-inspector-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-pr-1490-live-map-gpu-animations-e2e.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 1 test-region-quick-picks.js
suite 3 test-table-sort.js
suite 1 test-touch-targets.js CHROMIUM_REQUIRE=1 BASE_URL=$B
suite 3 test-live-dedup.js BASE_URL=$B
suite 1 test-nodes-export-e2e.js BASE_URL=$B
suite 2 test-show-neighbors.js BASE_URL=$B
suite 3 test-user-management-e2e.js BASE_URL=http://localhost:13582 BASE_URL_OFF=$B
# #1616: slide-over focus-restore flake-gate. Runs the slide-over
# E2E 3 more times against the SAME backend instance (it already
# ran once in the list above) so the Chromium-headless focus race
# documented in #1172/#1616 gets repeated shots at firing. Any
# single non-zero exit aborts. This is the architectural-fix gate:
# if it ever turns red post-merge, the focused-but-hidden state has
# crept back in.
#
# PERMANENT step, on shard 3 (the shard that runs the slide-over
# suite). Adds ~70s to that shard in exchange for closing out a
# flake family that was blocking ~8 unrelated PRs at a time. If
# profiling pressures the budget later, drop repeat count first;
# do not delete.
- name: Slide-over E2E flake-gate (#1616, --repeat-each=3)
if: matrix.shard == 3
run: |
set -e
for i in $(seq 1 3); do
echo "--- slide-over E2E run $i/3 ---"
echo "=== E2E SUITE: test-slideover-1056-e2e.js ==="
BASE_URL=http://localhost:13581 node tests/e2e/test-slideover-1056-e2e.js 2>&1 | tee -a slideover-repeat-output.txt
done
echo "3 passed"
# Shard 2 runs test-e2e-playwright.js, the one suite that writes
# .nyc_output, so the coverage collection and its badge live there too.
- name: Collect frontend coverage (parallel)
if: success() && github.event_name == 'push' && matrix.shard == 2
run: |
BASE_URL=http://localhost:13581 node scripts/collect-frontend-coverage.js 2>&1 | tee fe-coverage-output.txt || true
- name: Generate frontend coverage badge
if: success()
run: |
mkdir -p .badges
if [ -f .nyc_output/frontend-coverage.json ] || [ -f .nyc_output/e2e-coverage.json ]; then
npx nyc report --reporter=text-summary --reporter=text 2>&1 | tee fe-report.txt
FE_COVERAGE=$(grep 'Statements' fe-report.txt | head -1 | grep -oP '[\d.]+(?=%)' || echo "0")
FE_COVERAGE=${FE_COVERAGE:-0}
FE_COLOR="red"
[ "$(echo "$FE_COVERAGE > 50" | bc -l 2>/dev/null)" = "1" ] && FE_COLOR="yellow"
[ "$(echo "$FE_COVERAGE > 80" | bc -l 2>/dev/null)" = "1" ] && FE_COLOR="brightgreen"
echo "{\"schemaVersion\":1,\"label\":\"frontend coverage\",\"message\":\"${FE_COVERAGE}%\",\"color\":\"${FE_COLOR}\"}" > .badges/frontend-coverage.json
echo "## Frontend: ${FE_COVERAGE}% coverage" >> $GITHUB_STEP_SUMMARY
fi
- name: Stop test server
if: always()
run: |
if [ -f .server.pid ]; then
kill $(cat .server.pid) 2>/dev/null || true
rm -f .server.pid
fi
if [ -f .server-um.pid ]; then
kill $(cat .server-um.pid) 2>/dev/null || true
rm -f .server-um.pid
fi
- name: Upload shard results
if: success()
uses: actions/upload-artifact@v6
with:
name: e2e-shard-${{ matrix.shard }}
path: |
e2e-output.txt
.badges/
retention-days: 1
if-no-files-found: ignore
include-hidden-files: true
# The gate the rest of the pipeline (and branch protection) sees under the
# old single-job name. It folds the shard outputs into the same e2e-badges
# artifact the publish job reads.
#
# !cancelled() is what makes it a gate. Without it a failed shard would SKIP
# this job, and branch protection counts a skipped required check as
# passing. With it, the job runs and fails on its first step instead.
e2e-test:
name: "🎭 Playwright E2E Tests"
needs: [e2e-shard, changes]
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.changes.outputs.code == 'true' && !(startsWith(github.ref, 'refs/tags/v') && inputs.images_published) }}
steps:
- name: Require every shard to have passed
run: |
result="${{ needs['e2e-shard'].result }}"
echo "e2e-shard: $result"
[ "$result" = success ] || { echo "::error::E2E shards did not all pass (result: $result)"; exit 1; }
- name: Checkout code
uses: actions/checkout@v5
- name: Download shard results
uses: actions/download-artifact@v6
with:
pattern: e2e-shard-*
path: shards/
- name: Generate E2E badges
run: |
set -e
ls shards
[ "$(ls -d shards/e2e-shard-* | wc -l)" -eq 3 ] || { echo "::error::expected results from 3 shards"; exit 1; }
cat shards/e2e-shard-*/e2e-output.txt > e2e-output.txt
mkdir -p .badges
cp shards/e2e-shard-*/.badges/*.json .badges/ 2>/dev/null || true
# Aggregate per-suite PASS/FAIL across every test-*-e2e.js summary.
# The previous regex (grep -oP '[0-9]+(?=/)' | tail -1) caught a
# stray digits-before-slash like the '2' in '2/3 tests passed' from
# some sub-output and stamped the badge as '2 passed'. See #1296.
eval "$(bash scripts/aggregate-e2e-pass.sh e2e-output.txt)"
E2E_PASS=${PASS:-0}
E2E_FAIL=${FAIL:-0}
if [ "${E2E_FAIL:-0}" -gt 0 ]; then
E2E_MSG="${E2E_PASS:-0} passed, ${E2E_FAIL} failed"
E2E_COLOR="red"
else
E2E_MSG="${E2E_PASS:-0} passed"
E2E_COLOR="brightgreen"
fi
echo "{\"schemaVersion\":1,\"label\":\"e2e tests\",\"message\":\"${E2E_MSG}\",\"color\":\"${E2E_COLOR}\"}" > .badges/e2e-tests.json
echo "E2E: ${E2E_MSG} ($(grep -c '^=== E2E SUITE' e2e-output.txt) suite runs)" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Upload E2E badges
uses: actions/upload-artifact@v6
with:
name: e2e-badges
path: .badges/
retention-days: 1
if-no-files-found: ignore
include-hidden-files: true
# ───────────────────────────────────────────────────────────────
# 3a. Two-arch image build — beside the tests, never publishes
# ───────────────────────────────────────────────────────────────
# Since the SQLite driver became cgo, the container build depends on a zig
# cross-toolchain and static musl linking. Builds both architectures and
# actually runs the arm64 binaries under QEMU, on every event: for a PR it is
# the only image check (the GHCR push below is push/tag-only, so without it
# the first signal would arrive on master); for a push it fills the layer
# cache that the push then reuses.
#
# It needs only `changes`, so its minutes overlap the test jobs instead of
# following them. It cannot publish anything, so running it before the tests
# pass is safe. The build metadata is computed here once and handed to
# build-and-publish: BUILD_TIME is a build arg of the Go layers, so a second
# timestamp would miss the cache and rebuild everything.
image-check:
name: "🧱 Two-arch image build"
needs: [changes]
runs-on: ubuntu-latest
if: needs.changes.outputs.code == 'true' && !(startsWith(github.ref, 'refs/tags/v') && inputs.images_published)
outputs:
build_time: ${{ steps.meta.outputs.build_time }}
git_commit: ${{ steps.meta.outputs.git_commit }}
app_version: ${{ steps.meta.outputs.app_version }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Compute build metadata
id: meta
run: |
BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT="${GITHUB_SHA::7}"
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
APP_VERSION="${GITHUB_REF#refs/tags/}"
else
APP_VERSION="edge"
fi
echo "build_time=$BUILD_TIME" >> "$GITHUB_OUTPUT"
echo "git_commit=$GIT_COMMIT" >> "$GITHUB_OUTPUT"
echo "app_version=$APP_VERSION" >> "$GITHUB_OUTPUT"
echo "Build: version=$APP_VERSION commit=$GIT_COMMIT time=$BUILD_TIME"
# The staging compose file used to be built here as well. That image was
# never used: the runner is discarded, and the deploy job pulls :edge from
# GHCR on its own runner. It rebuilt the same Dockerfile as the step
# below for two minutes. Validating the compose file is what is left.
- name: Validate staging compose file
run: docker compose -f "$STAGING_COMPOSE_FILE" -p corescope-staging config --quiet
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU (arm64 runtime stage + arm64 smoke)
uses: docker/setup-qemu-action@v3
- name: Two-arch build (no publish)
uses: docker/build-push-action@v6
with:
context: .
push: false
platforms: linux/amd64,linux/arm64
tags: corescope:check-${{ github.run_id }}
build-args: |
APP_VERSION=${{ steps.meta.outputs.app_version }}
GIT_COMMIT=${{ steps.meta.outputs.git_commit }}
BUILD_TIME=${{ steps.meta.outputs.build_time }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke the arm64 binaries under QEMU
run: |
set -e
# Export the arm64 binaries so the runner's own `file` can confirm
# they are static, then execute one under QEMU. Cheap: the build above
# already populated the layer cache.
docker buildx build . --platform linux/arm64 \
--build-arg APP_VERSION=smoke --cache-from type=gha \
--output type=local,dest=./arm64-image
for b in corescope-server corescope-ingestor corescope-decrypt; do
file "./arm64-image/app/$b" | tee /dev/stderr | grep -q 'statically linked' \
|| { echo "::error::$b is not statically linked"; exit 1; }
file "./arm64-image/app/$b" | grep -q 'ARM aarch64' \
|| { echo "::error::$b is not an arm64 binary"; exit 1; }
done
docker run --rm --platform linux/arm64 \
-v "$PWD/arm64-image/app:/bin-under-test:ro" alpine:3.20 \
/bin-under-test/corescope-decrypt --version
rm -rf ./arm64-image
echo "arm64 static binaries run under QEMU ✅"
# ───────────────────────────────────────────────────────────────
# 3b. Publish Docker Image — only after every test job passed
# ───────────────────────────────────────────────────────────────
# The GHCR steps below publish on a push to master (the :edge image) and
# on a tag ref. The tag half is not decoration: release-fast-path.yml re-tags
# :edge to :vX.Y.Z when the :edge revision label matches the tagged commit,
# and dispatches THIS workflow when it does not. That fallback previously
# produced no image at all, because a workflow_dispatch is not a push and
# every publishing step was gated on github.event_name == 'push'. It built
# locally, reported success, and pushed nothing.
#
# That went unnoticed until v3.10.0, where the tagged commit was
# documentation-only. At that time a trigger-level paths-ignore skipped this
# workflow for such commits, so no :edge image was ever built for it, the label
# comparison failed, and the fallback ran for the first time. That filter is
# gone: the `changes` job now forces code=true for anything that is not a pull
# request, so every master commit gets an image and a documentation commit is
# safe to tag. See the comment on the `on:` block.
#
# On a pull request only the first step runs; the job stays so that its
# check still means "tests and image build all passed".
#
# !cancelled() plus the first step make that true for failures too: without
# them a failed needed job would SKIP this job, and branch protection counts
# a skipped required check as passing. race-test is skipped when no ingestor
# Go file changed, so for it skipped is accepted; a master push always runs it.
build-and-publish:
name: "🏗️ Build & Publish Docker Image"
needs: [go-test, race-test, e2e-test, image-check, changes]
runs-on: ubuntu-latest
if: ${{ !cancelled() && needs.changes.outputs.code == 'true' && !(startsWith(github.ref, 'refs/tags/v') && inputs.images_published) }}
steps:
- name: Require every test job and the image check to have passed
run: |
fail=0
require() {
echo "$1: $2"
case " $3 " in
*" $2 "*) ;;
*) echo "::error::$1 result is $2"; fail=1 ;;
esac
}
require go-test "${{ needs['go-test'].result }}" "success"
require race-test "${{ needs['race-test'].result }}" "success skipped"
require e2e-test "${{ needs['e2e-test'].result }}" "success"
require image-check "${{ needs['image-check'].result }}" "success"
exit $fail
- name: Checkout code
if: ${{ github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') }}
uses: actions/checkout@v5
- name: Set up Docker Buildx
if: ${{ github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/setup-buildx-action@v3
- name: Set up QEMU (arm64 runtime stage)
if: ${{ github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/setup-qemu-action@v3
- name: Log in to GHCR
if: ${{ github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
if: ${{ github.event_name == 'push' || startsWith(github.ref, 'refs/tags/v') }}
id: docker-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/kpa-clawbot/corescope
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}