Repository navigation
796 lines (708 loc) · 29.9 KB
/
Copy pathtest.yml
File metadata and controls
796 lines (708 loc) · 29.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
name: Test
on:
push:
branches: [main]
# Every pull request, not only those targeting main: a stacked pull
# request opened against its parent branch is exactly the one that
# most needs checking, and it was getting none.
pull_request:
schedule:
- cron: '23 5 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.event_name == 'pull_request' && format('test-pr-{0}', github.event.pull_request.number) || format('test-run-{0}', github.run_id) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions: {}
jobs:
changes:
name: Classify changes
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
go: ${{ steps.decide.outputs.go }}
tests: ${{ steps.decide.outputs.tests }}
steps:
- name: Classify the changed files
id: filter
if: github.event_name == 'pull_request'
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
predicate-quantifier: every
filters: |
go:
- '**'
- '!*.md'
- '!.github/*.md'
- '!skills/**/*.md'
- '!skill-evals/**'
tests:
- '**'
- '!*.md'
- '!.github/*.md'
- name: Decide what runs
id: decide
env:
EVENT: ${{ github.event_name }}
GO: ${{ steps.filter.outputs.go }}
TESTS: ${{ steps.filter.outputs.tests }}
run: |
if [ "$EVENT" != "pull_request" ]; then
echo "go=true" >> "$GITHUB_OUTPUT"
echo "tests=true" >> "$GITHUB_OUTPUT"
echo "Full run: $EVENT events are never narrowed." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
for answer in "$GO" "$TESTS"; do
case "$answer" in
true|false) ;;
*)
echo "::error::the paths filter did not answer (go='$GO', tests='$TESTS'), so nothing can be skipped"
exit 1
;;
esac
done
echo "go=$GO" >> "$GITHUB_OUTPUT"
echo "tests=$TESTS" >> "$GITHUB_OUTPUT"
if [ "$GO" = "true" ]; then
echo "Full run: this pull request changes files outside the docs and skill lists." >> "$GITHUB_STEP_SUMMARY"
elif [ "$TESTS" = "true" ]; then
echo "Skill or eval files only: Tests and Integration Tests run; Lint, Security, CLI Surface Check and the race shards skip." >> "$GITHUB_STEP_SUMMARY"
else
echo "Prose only: Tests runs the naming check; the Go jobs skip." >> "$GITHUB_STEP_SUMMARY"
fi
test:
name: Tests
runs-on: ubuntu-latest
needs: changes
if: ${{ !cancelled() }}
permissions:
contents: read
env:
BASECAMP_NO_KEYRING: "1"
RUN_GO: ${{ needs.changes.outputs.tests != 'false' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
if: env.RUN_GO == 'true'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Check SDK provenance
if: env.RUN_GO == 'true'
run: make provenance-check
- name: Check module tidiness
if: env.RUN_GO == 'true'
run: make tidy-check
- name: Check naming (no stale legacy references)
run: make check-naming
- name: Run unit tests
if: env.RUN_GO == 'true'
run: go test -tags dev -v ./...
- name: Build binary
if: env.RUN_GO == 'true'
run: go build -tags dev -o bin/basecamp ./cmd/basecamp
- name: Smoke test
if: env.RUN_GO == 'true'
run: |
./bin/basecamp --version
./bin/basecamp --help | head -5
- name: Validate release build (no dev tag)
if: env.RUN_GO == 'true'
run: |
go build -o bin/basecamp-release ./cmd/basecamp
go test -v ./internal/commands/ -run TestStub
- name: Say what did not run
if: env.RUN_GO != 'true'
run: |
echo "Prose-only change: the naming check ran; the Go tests, build and smoke test did not." >> "$GITHUB_STEP_SUMMARY"
lint:
name: Lint
runs-on: ubuntu-latest
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.go != 'false' }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
# Runs before the linter: if the pins have drifted, say so plainly rather
# than letting the odd job out fail later on a version-specific finding.
- name: Check golangci-lint pins are in lockstep
run: make check-lint-lockstep
- name: Run golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.11.1
args: --build-tags dev
lint-actions:
name: GitHub Actions audit
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run actionlint
uses: rhysd/actionlint@914e7df21a07ef503a81201c76d2b11c789d3fca # v1.7.12
- name: Run zizmor
uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
with:
# The action resolves `version` (default "latest") through the digest
# map checked in at its pinned SHA, so this stays stable either way —
# the explicit pin keeps the release from shifting when the action SHA
# is bumped, and matches the .mise.toml zizmor pin for local parity.
version: "1.30.0"
advanced-security: false
security:
name: Security
runs-on: ubuntu-latest
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.go != 'false' }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Run govulncheck
# @latest intentional — pinning delays scanning improvements and
# new Go version support for no meaningful reproducibility gain.
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck -tags dev ./...
# The shards, and then Race Detection over them. The required status check
# is the aggregate, so its name never changes and the ruleset never has to
# be edited when the shard count does.
race-shard:
name: Race Detection (shard ${{ matrix.shard }} of 4)
runs-on: ubuntu-latest
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.go != 'false' }}
permissions:
contents: read
strategy:
# Every shard runs: stopping the others on the first failure would
# leave the aggregate unable to tell a real gap from a cancelled job.
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
env:
BASECAMP_NO_KEYRING: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
# 20 minutes, not Go's default 10 per package. internal/connector runs
# real sockets, real processes and the recovery harness; under -race it
# takes about five minutes on a fast box and roughly twice that on a
# runner. The default was not a hung test, it was the budget.
- name: Run this shard under the race detector
run: scripts/race-shard.sh "${{ matrix.shard }}" 4 "shard-records/shard-${{ matrix.shard }}"
# Uploaded even when the shard failed: the aggregate has to be able to
# tell "this shard ran its tests and one of them failed" from "this
# shard never got as far as knowing what it was meant to run".
- name: Record what this shard was assigned
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
# The name is the directory the aggregate reads: download-artifact
# extracts each one to <path>/<name>/, so this has to be the
# shard-N the union check looks for, not a name of its own.
name: shard-${{ matrix.shard }}
path: |
shard-records/shard-${{ matrix.shard }}/all.txt
shard-records/shard-${{ matrix.shard }}/shard.${{ matrix.shard }}.txt
retention-days: 3
if-no-files-found: error
race-check:
name: Race Detection
runs-on: ubuntu-latest
needs: [changes, race-shard]
# always(), or a failed shard would skip this job — and a skipped required
# check is not a failed one.
if: ${{ always() && needs.changes.outputs.go != 'false' }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download what each shard recorded
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: shard-*
path: shard-records
# Naming what came back before judging it: a check that runs over
# nothing is the failure this whole arrangement exists to prevent.
- name: Show the records
run: find shard-records -type f | sort
- name: Every shard passed
env:
SHARDS: ${{ needs.race-shard.result }}
run: |
echo "shards: $SHARDS"
[ "$SHARDS" = success ] || {
echo "a race-detection shard did not pass" >&2
exit 1
}
- name: The shards between them ran every test, once
run: scripts/race-shard-union.sh shard-records 4
integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.tests != 'false' }}
permissions:
contents: read
env:
BASECAMP_NO_KEYRING: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Cache BATS
id: cache-bats
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
# zizmor: ignore[cache-poisoning] -- cache is branch-isolated; fork PRs cannot write to the cache used by tag-push workflows
with:
path: ~/.local
key: bats-1.11.0-home
- name: Install BATS
if: steps.cache-bats.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch v1.11.0 https://github.com/bats-core/bats-core.git /tmp/bats-core
/tmp/bats-core/install.sh ~/.local
- name: Add BATS to PATH
run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Run BATS integration tests
run: make test-e2e
- name: Test the skills sync
run: make test-sync-skills
- name: Test the skill drift check
run: make test-skill-drift
# Same Ruby the eval runner gets, because the point of the check is the
# engine: these patterns are Onigmo, and Go's RE2 guard cannot see them.
- name: Set up Ruby
uses: ruby/setup-ruby@e81a8fa391b11a595c1b7ed84177cc0fe02faf83 # v1.328.0
with:
ruby-version: '3.4'
- name: Compile the skill-eval patterns
run: make check-eval-patterns
cli-surface:
name: CLI Surface Check
runs-on: ubuntu-latest
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.go != 'false' }}
permissions:
contents: read
env:
BASECAMP_NO_KEYRING: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Build and snapshot PR surface
run: |
make build
scripts/check-cli-surface.sh ./bin/basecamp /tmp/current-surface.txt
- name: Build and snapshot baseline surface
run: |
SCRIPT_DIR="$(pwd)/scripts"
git worktree add /tmp/baseline-tree origin/main
cd /tmp/baseline-tree
make build
"$SCRIPT_DIR/check-cli-surface.sh" ./bin/basecamp /tmp/baseline-surface.txt
- name: Compare surfaces
run: scripts/check-cli-surface-diff.sh /tmp/baseline-surface.txt /tmp/current-surface.txt
- name: Cleanup worktree
if: always()
run: git worktree remove /tmp/baseline-tree --force 2>/dev/null || true
# Whether the evals can run at all, answered before the job that would run
# them. Split out because a job cannot skip itself: a step-level `if` leaves
# the job green, and "Skill Evals: success" with no case run is the reading
# this repository actually had. A `needs` + job-level `if` reports Skipped,
# which is what happened.
skill-eval-gate:
name: Skill Evals (preflight)
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read # dorny/paths-filter enumerates PR files via the REST API
if: github.event_name == 'pull_request'
outputs:
run: ${{ steps.decide.outputs.run }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check for skill or eval changes
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
# test.yml is in its own filter so the job proves itself on the PR
# that introduces or edits it.
filters: |
skill:
- 'skills/basecamp/SKILL.md'
- 'skills/basecamp-connect/SKILL.md'
- 'skill-evals/**'
- '.github/workflows/test.yml'
- name: Decide whether the evals can run
id: decide
env:
CHANGED: ${{ steps.filter.outputs.skill }}
# Presence only, never the value. Fork PRs receive no secrets, so this
# is false there by construction and the skip below is the honest
# answer for them too.
HAS_KEY: ${{ secrets.ANTHROPIC_API_KEY != '' }} # zizmor: ignore[secrets-outside-env] -- a presence test, not the key; adding an environment would block PR-triggered runs
run: |
# A preflight that cannot tell must not be allowed to say no. The
# filter answers true or false; anything else means it did not answer,
# and treating that as "nothing to run" would rebuild the defect this
# job exists to remove, one level up (Copilot on #768).
case "$CHANGED" in
true|false) ;;
*)
echo "::error::the paths filter did not answer (skill='$CHANGED'), so this preflight cannot say whether the evals are needed"
exit 1
;;
esac
if [ "$CHANGED" != "true" ]; then
echo "run=false" >> "$GITHUB_OUTPUT"
echo "No skill or eval changes on this pull request." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
cases=$(find skill-evals/cases -name '*.yml' | wc -l | tr -d ' ')
if [ "$HAS_KEY" != "true" ]; then
echo "run=false" >> "$GITHUB_OUTPUT"
echo "::warning title=Skill Evals did not run::ANTHROPIC_API_KEY is not configured for this repository, so none of the $cases eval cases were run on a pull request that changes them. The Skill Evals job below reports Skipped, not success."
{
echo "### Skill Evals: NOT RUN"
echo
echo "This pull request changes a skill or its evals, and **$cases eval cases were not run**."
echo "\`ANTHROPIC_API_KEY\` is not configured for this repository, and fork pull requests never receive secrets."
echo
echo "What still covers these files:"
echo "- \`make check-eval-patterns\` compiles every pattern in every case under Onigmo, the engine the runner uses."
echo "- \`TestConnectSkillEvalRejectsHoldTheServeValueRule\` holds the \`--serve\` value rule in the connector cases."
echo
echo "Neither runs a case. If these evals must gate this repository, configure the secret; until then this job is Skipped rather than green."
} >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
echo "run=true" >> "$GITHUB_OUTPUT"
skill-eval:
name: Skill Evals
runs-on: ubuntu-latest
permissions:
contents: read
needs: skill-eval-gate
if: needs.skill-eval-gate.outputs.run == 'true'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Ruby
uses: ruby/setup-ruby@e81a8fa391b11a595c1b7ed84177cc0fe02faf83 # v1.328.0
with:
ruby-version: '3.4'
- name: Run skill evals
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} # zizmor: ignore[secrets-outside-env] -- fork PRs don't receive secrets so untrusted code never sees the key; adding an environment would block PR-triggered runs
run: |
# The gate decided the key is there. If it is not, the gate is broken,
# and that is a failure rather than a quiet exit 0 — the whole point
# of this job is that it never reports success without running a case.
if [ -z "$ANTHROPIC_API_KEY" ]; then
echo "::error::the preflight said the evals could run, but ANTHROPIC_API_KEY is empty here"
exit 1
fi
make skill-eval
installer-bash32:
name: Installer (bash 3.2)
runs-on: macos-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: read # dorny/paths-filter enumerates PR files via the REST API
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check for installer changes
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
# test.yml is in its own filter so the job proves itself on the PR
# that introduces or edits it.
filters: |
installer:
- 'scripts/install.sh'
- 'e2e/installer.bats'
- '.github/workflows/test.yml'
- name: Assert /bin/bash is Bash 3.2
if: steps.filter.outputs.installer == 'true'
run: |
# Same guard as the installer-smoke canary: honest 3.2 coverage
# instead of silently degrading if a future runner image changes
# /bin/bash. The e2e bats suite cannot provide this — bats 1.11.0
# execs `env bash` at every layer, so the interpreter is not
# pinnable through it.
/bin/bash -c '[[ "${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}" == "3.2" ]]' \
|| { echo "/bin/bash is not Bash 3.2:" >&2; /bin/bash --version >&2; exit 1; }
- name: Syntax-check installer under Bash 3.2
if: steps.filter.outputs.installer == 'true'
run: /bin/bash -n scripts/install.sh
- name: Piped execution under Bash 3.2
if: steps.filter.outputs.installer == 'true'
run: |
# PATH=/nonexistent forces the curl guard: the run must fail with
# the guard's own message, never with an unbound-variable error
# (the #558 regression class). A bare out=$(...) assignment of the
# failing pipeline would exit this step immediately under the
# runner's `bash -e -o pipefail`, so capture via if-else.
status=0
if out=$(cat scripts/install.sh | PATH=/nonexistent /bin/bash 2>&1); then
status=0
else
status=$?
fi
printf '%s\n' "$out"
if [ "$status" -eq 0 ]; then
echo "expected the curl guard to fail without curl on PATH" >&2
exit 1
fi
printf '%s\n' "$out" | grep -q 'curl is required but not installed'
if printf '%s\n' "$out" | grep -q 'unbound variable'; then
echo "installer emitted an unbound variable error under Bash 3.2" >&2
exit 1
fi
- name: Offline full install under Bash 3.2
if: steps.filter.outputs.installer == 'true'
run: |
# The curl-guard step above never gets past the prerequisite check,
# and `bash -n` only checks grammar — neither catches Bash-4-only
# constructs (declare -A, mapfile, 4.x expansions) in the download,
# checksum, extract, or post-install code. Run one complete install
# under real 3.2: a fixture curl serves a local release from disk,
# and a pinned BASECAMP_VERSION skips version resolution. PATH is
# restricted to fixture + system dirs so Homebrew tools (bash 4+,
# cosign) cannot leak in.
fixture_root=$(mktemp -d)
mkdir -p "$fixture_root/bin" "$fixture_root/release" "$fixture_root/home" "$fixture_root/install"
cat > "$fixture_root/release/basecamp" <<'STUB'
#!/bin/bash
if [ "$1" = "--version" ]; then echo "basecamp version 9.9.9"; fi
exit 0
STUB
chmod +x "$fixture_root/release/basecamp"
for arch in arm64 amd64; do
tar -czf "$fixture_root/release/basecamp_9.9.9_darwin_${arch}.tar.gz" -C "$fixture_root/release" basecamp
done
(cd "$fixture_root/release" && shasum -a 256 ./*.tar.gz | sed 's|\./||' > checksums.txt)
cat > "$fixture_root/bin/curl" <<'STUB'
#!/bin/bash
# Fixture curl: serves the local release dir. Handles the two shapes
# install.sh uses: `--version` and `[-flags] <url> -o <dest>`.
out=""; url=""
while [ $# -gt 0 ]; do
case "$1" in
--version) echo "curl 8.0.0 (fixture)"; exit 0 ;;
-o) out="$2"; shift ;;
http://*|https://*) url="$1" ;;
esac
shift
done
name="${url##*/}"
if [ -n "$out" ] && [ -f "$FIXTURE_RELEASE_DIR/$name" ]; then
cp "$FIXTURE_RELEASE_DIR/$name" "$out"
exit 0
fi
echo "fixture curl: no fixture for: $url" >&2
exit 22
STUB
chmod +x "$fixture_root/bin/curl"
status=0
if out=$(cat scripts/install.sh | \
HOME="$fixture_root/home" \
FIXTURE_RELEASE_DIR="$fixture_root/release" \
BASECAMP_BIN_DIR="$fixture_root/install" \
BASECAMP_VERSION=9.9.9 \
BASECAMP_SKIP_SETUP=1 \
BASECAMP_SETUP_AGENT=none \
PATH="$fixture_root/bin:/usr/bin:/bin" \
/bin/bash 2>&1); then
status=0
else
status=$?
fi
printf '%s\n' "$out"
if [ "$status" -ne 0 ]; then
echo "offline install failed under Bash 3.2 (exit $status)" >&2
exit 1
fi
printf '%s\n' "$out" | grep -q 'Installed basecamp to'
printf '%s\n' "$out" | grep -q 'version 9.9.9 installed'
if printf '%s\n' "$out" | grep -q 'unbound variable'; then
echo "installer emitted an unbound variable error under Bash 3.2" >&2
exit 1
fi
"$fixture_root/install/basecamp" --version
benchmarks:
name: Benchmarks
runs-on: ubuntu-latest
permissions:
contents: read
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
continue-on-error: true
env:
BASECAMP_NO_KEYRING: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
- name: Check for benchmark-relevant changes
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
filters: |
bench:
- 'internal/api/**'
- 'internal/names/**'
- 'internal/dateparse/**'
- 'internal/output/**'
- 'go.mod'
- 'go.sum'
- name: Set up Go
if: steps.filter.outputs.bench == 'true'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Run benchmarks
if: steps.filter.outputs.bench == 'true'
run: go test -tags dev -bench=. -benchmem -count=3 -run='^$' ./internal/... | tee benchmarks.txt
- name: Download previous benchmark baseline
if: steps.filter.outputs.bench == 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: benchmarks-baseline.txt
key: benchmarks-baseline-${{ github.sha }}
restore-keys: |
benchmarks-baseline-
- name: Install benchstat
if: steps.filter.outputs.bench == 'true'
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Compare benchmarks
if: steps.filter.outputs.bench == 'true' && hashFiles('benchmarks-baseline.txt') != ''
run: |
echo "## Benchmark Comparison" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
benchstat benchmarks-baseline.txt benchmarks.txt >> "$GITHUB_STEP_SUMMARY" 2>&1 || true
echo '```' >> "$GITHUB_STEP_SUMMARY"
- name: Check for significant regression
if: steps.filter.outputs.bench == 'true' && hashFiles('benchmarks-baseline.txt') != ''
run: |
benchstat benchmarks-baseline.txt benchmarks.txt > comparison.txt 2>&1 || true
if grep -E '\+[2-9][0-9]\.[0-9]+%|\+[1-9][0-9][0-9]+' comparison.txt; then
echo "::error::Performance regression detected (>20% slower). See benchmark comparison in step summary."
exit 1
fi
- name: Save benchmark baseline
if: steps.filter.outputs.bench == 'true'
run: cp benchmarks.txt benchmarks-baseline.txt
- name: Cache benchmark baseline
if: steps.filter.outputs.bench == 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: benchmarks-baseline.txt
key: benchmarks-baseline-${{ github.sha }}
- name: Upload benchmark results
if: steps.filter.outputs.bench == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: benchmarks
path: benchmarks.txt
retention-days: 30
# The flake broke on 2026-07-13 when #533 raised go.mod to 1.26.5 while
# flake.lock still pinned a nixpkgs carrying 1.26.4, and nothing noticed for
# three weeks: nix-verify only runs on tags, and the release-time hash check
# was reporting success on a failed build. Catch the drift where it is
# introduced instead — a Go bump that outpaces the lock now fails its own PR.
#
# This job is *meant* to fail on a dependency bump: any go.mod or go.sum
# change invalidates vendorHash, and dependabot does not update it, so every
# weekly `gomod` PR lands here red. That is the check working. nix-build-check.sh
# exists so it lands red with the correct hash and `make update-nix-hash`
# attached, instead of a raw nix dump.
#
# The filter includes this file: a PR that changes only the job would
# otherwise skip the job it changed.
nix-build:
name: Nix flake builds
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read # dorny/paths-filter enumerates PR files via the REST API
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
- name: Check for flake-relevant changes
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
filters: |
nix:
- 'go.mod'
- 'go.sum'
- 'flake.nix'
- 'flake.lock'
- 'nix/**'
- 'scripts/nix-build-check.sh'
- 'scripts/extract-nix-vendor-hash.sh'
- '.github/workflows/test.yml'
- name: Install Nix
if: steps.filter.outputs.nix == 'true'
uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31.11.1
- name: Build the flake
if: steps.filter.outputs.nix == 'true'
run: scripts/nix-build-check.sh
# `nix build` builds packages.default, so nothing here ever looked at the
# dev shell's package list — a misspelled attribute in it would land green
# and break `nix develop` for whoever followed CONTRIBUTING. Evaluating the
# derivation resolves every attribute without building any of them, which
# costs seconds and is the difference between a list that is checked and a
# list that is merely written down.
- name: Check the dev shell's package list resolves
if: steps.filter.outputs.nix == 'true'
run: nix eval --raw .#devShells.x86_64-linux.default.drvPath