beads/.github/workflows/main.yml
Julian Knutsen a4509deb2d
ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18) (#7341)
* ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18)

Lint and vet now run as nogo inside the Bazel build, so they gate wherever
the Bazel lanes execute (rbe-west), and the golangci-lint and go vet jobs
leave pr.yml and main.yml.

- //tools/nogo (own go.mod, joined to beads' for go_deps only through
  gazelle.go.work): go test's vet checks (cmd/go's defaultVetFlags, the set
  scripts/ci/go-test-vet.sh ran) plus the eight linters .golangci.yml
  enables, each a wrapper over the library version golangci-lint v2.10.1
  uses (depguard, errcheck, forbidigo, gosec, misspell, sloglint, unconvert,
  unparam).
- .golangci.yml stays the single lint policy: Bazel embeds it and
  tools/nogo/internal/golangci applies it as golangci-lint does (enabled
  set, settings, run.tests: false as library-unit-only analysis, lax
  generated-file detection, path/path-except/text exclusion rules), with
  strict decoding so an unimplemented key fails the build.
- gascity's rules_go //nolint-range patch and x/tools ctrlflow patch,
  byte-identical.
- Windows/darwin: cross-configured, not a golangci leg. The pure lane's
  release cross-compile (//tools/bazel:release_cross, every library and
  binary for all eight release platforms, cgo off) runs nogo on every
  compile, a superset of golangci-lint's windows and darwin legs.
  scripts/pr-lint (make ci-pr-lint, bd preflight) runs `bazel build
  --config=nogo //...` plus release_cross for windows_amd64,darwin_arm64.
  release_cross skips tools/nogo, a separate Go module `go build ./...`
  never compiled.
- pr.yml: scripts-go-checks (vet) and pr-lint-wrapper (x3) are gone, with
  their ci-gate entries; main.yml: pr-lint-wrapper (x6) and go-vet-cache.
  scripts/ci/go-test-vet.sh and install-golangci-lint.sh are deleted.
- pre-commit hook and .pre-commit-config.yaml run `make lint-changed
  LINT_CHANGED_SCOPE=staged` (nogo over the staged packages); Makefile adds
  lint, vet and lint-changed. pr-lint.sh no longer runs gofmt
  (//scripts/repochecks:fmt_test owns it; ga-96smfk.41).
- internal/testutil/integration: five gosec findings in integration-tagged
  library files golangci-lint never built, now linted by the integration
  lanes, carry reasoned //nolint directives.

Parity: with the exclusion rules removed, golangci-lint and nogo report the
same 3,916 findings natively and 3,859 each for windows and darwin (file,
line, linter, text); with .golangci.yml as committed both report none.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): equivalence.py leaves nested Go modules' tests out of go test's set

tools/nogo is its own Go module, so `go test ./...` in the root never runs
its tests; Bazel's unit lane does. Its packages are neither expected nor
extra.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 05:17:22 +00:00

1020 lines
48 KiB
YAML

name: Main
on:
push:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
jobs:
# Same guard as pr.yml's check-migration-hygiene: direct pushes to main
# (and PR merges whose base moved) must not bypass the migration lints.
# BASE_SHA is the pre-push tip; on force pushes or history rewrites the
# script warns and skips the frozen-migrations diff but still runs the
# duplicate-version and nondeterministic-SQL checks.
check-migration-hygiene:
name: Check migration hygiene
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Run migration hygiene checks
env:
BASE_SHA: ${{ github.event.before }}
run: ./scripts/check-migration-hygiene.sh
build-artifacts:
name: Build Artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Restore Go module cache
id: restore-go-module-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
# Per `go help cache`, Go's content-addressed build cache includes
# compiler options, so this base-tag directory can serve builds with
# additional tags. Race builds stay separate; Windows native/cgo
# non-race builds share theirs.
- name: Restore non-race Go build cache
id: restore-non-race-go-build-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ github.sha }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-
- name: Build reusable Linux artifacts
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: |
set -euo pipefail
mkdir -p artifacts
source ./.buildflags
go_version="$(go version)"
commit="$(git rev-parse HEAD)"
go build -tags gms_pure_go -o artifacts/bd-linux-gms-pure ./cmd/bd
chmod +x artifacts/bd-linux-gms-pure
go test -tags gms_pure_go -c -o artifacts/bd-cmd-test ./cmd/bd
chmod +x artifacts/bd-cmd-test
(
cd artifacts
sha256sum bd-linux-gms-pure > SHA256SUMS
)
{
echo "commit=${commit}"
echo "go_version=${go_version}"
echo "build_tags=${BEADS_BUILD_TAGS}"
echo "artifact=bd-linux-gms-pure"
} > artifacts/build-manifest.txt
- name: Upload build artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-build-artifacts
path: artifacts/
retention-days: 1
if-no-files-found: error
# F4.3/F7b: pr.yml's check-doc-freshness-platforms and
# pr-preflight-platforms ubuntu legs compile several ./scripts and
# ./cmd/bd test binaries but, before this, used no GOCACHE at all (every
# run cold-compiled them). This warms the non-race GOCACHE this job
# already saves (below) with exactly those packages. Shared with
# blacksmith-go-build-cache's non-race leg (the same-repo-PR path's
# seed) so the two paths can never drift apart (F7b spec 4.2).
- name: Warm non-race GOCACHE for preflight/doc-freshness
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: bash scripts/ci/warm-non-race-cache.sh
- name: Save Go module cache
if: steps.restore-go-module-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
- name: Save non-race Go build cache
if: steps.restore-non-race-go-build-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ github.sha }}
# F4.7: pr.yml's `windows-test-binaries` job only restores the module cache
# and the Windows cross-compile GOCACHE; PR workflows never save caches
# (forks and same-repo PRs alike would otherwise be able to poison a
# shared key). This is the seeder, mirroring build-artifacts' and test's
# module/GOCACHE save pattern for the one new cache key xcompile added.
#
# Two legs, not one: pr.yml's windows-test-binaries job (pr.yml:522) lands
# on `blacksmith-8vcpu-ubuntu-2404` for same-repo PRs/merge_group and
# `ubuntu-latest` for forks/Dependabot. `runner.os`/`runner.arch` alone
# look identical between those two (both report Linux/X64), but Blacksmith
# runners cannot see caches `actions/cache` saved from a GitHub-hosted
# runner (and vice versa): the cache storage is scoped to the runner
# infrastructure, not just the key. A single ubuntu-latest seeder leg would
# therefore only ever warm the fork-PR path and leave every same-repo PR
# (the common case) cold on every run. Seeding from both runner selections,
# with identical keys/paths, covers both consumer legs. The ternary form
# (rather than a literal Blacksmith label in a matrix array) is required
# for actionlint: it resolves literal matrix arrays of runner labels and
# fails on an undeclared self-hosted label, but treats a ternary
# expression as a dynamic value it can't resolve, and skips validation --
# the same reason every other Blacksmith `runs-on` in this repo uses the
# ternary form.
windows-test-binaries-cache:
name: Save Windows test binaries cache
strategy:
fail-fast: false
matrix:
runner: [blacksmith, github]
runs-on: ${{ matrix.runner == 'blacksmith' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Restore Go module cache
id: restore-go-module-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Install mingw cross-compiler
timeout-minutes: 12
run: |
updated=""
for attempt in 1 2 3; do
if sudo timeout 120 apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 update; then
updated=yes
break
fi
echo "::warning::apt-get update attempt $attempt failed or timed out"
if [ "$attempt" -lt 3 ]; then sleep 10; fi
done
if [ -z "$updated" ]; then
echo "::warning::apt-get update failed after 3 attempts; proceeding with cached index"
fi
sudo timeout 300 apt-get install -y gcc-mingw-w64-x86-64
- name: Restore Go build cache (Windows cross-compile)
id: restore-xcompile-go-build-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/xcompile-windows-amd64
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-xcompile-windows-amd64-${{ github.sha }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-xcompile-windows-amd64-
- name: Build Windows test binaries
env:
GOCACHE: ${{ runner.temp }}/go-cache/xcompile-windows-amd64
run: bash scripts/ci/build-windows-test-binaries.sh "$RUNNER_TEMP/win-bin"
- name: Save Go module cache
if: ${{ !cancelled() && steps.restore-go-module-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
- name: Save Go build cache (Windows cross-compile)
if: ${{ !cancelled() && steps.restore-xcompile-go-build-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/xcompile-windows-amd64
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-xcompile-windows-amd64-${{ github.sha }}
# Fast shell/Make guard for direct source-time build-tag declarations.
# Workflow `run` steps are checked structurally in the required policy wrapper.
check-build-tags:
name: Check build-tag policy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- run: ./scripts/check-build-tags.sh
- run: ./scripts/check-go-install-guidance.sh
- run: ./scripts/check-winget-portable-alias.sh
# Fast check to ensure all version files are in sync
check-version-consistency:
name: Check version consistency
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Check all versions match
run: ./scripts/check-versions.sh
# Catch duplicate migration version numbers before any Go build.
# Two long-lived branches both claiming 'the next number' produce a silent
# under-apply when merged; this job fails at PR time with the conflicting
# filenames so it is caught before any test even compiles.
check-no-duplicate-migrations:
name: Check no duplicate migration versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Check for duplicate migration version numbers
run: |
dup=$(
find internal/storage/schema/migrations -maxdepth 1 -name '*.up.sql' -printf '%f\n' \
| sed 's/^\([0-9]*\)_.*/\1/' \
| sort | uniq -d
)
if [ -n "$dup" ]; then
echo "Duplicate migration version(s) detected: $dup"
echo "Conflicting files:"
while IFS= read -r v; do
find internal/storage/schema/migrations -name "${v}_*.up.sql" -print
done <<< "$dup"
echo "Renumber one of the colliding files before merging."
exit 1
fi
# Check documentation references match actual CLI flags
check-doc-flags:
name: Check doc flags freshness
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Build bd
run: CGO_ENABLED=0 go build -tags gms_pure_go -o bd ./cmd/bd/
- name: Validate docs against CLI
run: |
./scripts/check-doc-flags.sh ./bd
./scripts/check-doc-freshness.sh
detect-package-gates:
name: Detect package gates
runs-on: ubuntu-latest
outputs:
mcp_package: ${{ steps.detect.outputs.mcp_package }}
npm_package: ${{ steps.detect.outputs.npm_package }}
reason: ${{ steps.detect.outputs.reason }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Decide package gates
id: detect
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
PUSH_AFTER_SHA: ${{ github.sha }}
run: ./scripts/ci/detect-package-gates.sh
package-mcp:
name: Package Gate (MCP)
runs-on: ubuntu-latest
needs: [detect-package-gates, build-artifacts]
steps:
- name: Check applicability
id: applicability
run: |
echo "run=${{ needs.detect-package-gates.outputs.mcp_package }}" >> "$GITHUB_OUTPUT"
if [[ "${{ needs.detect-package-gates.outputs.mcp_package }}" != "true" ]]; then
echo "MCP package gate is not applicable: ${{ needs.detect-package-gates.outputs.reason }}"
fi
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
if: steps.applicability.outputs.run == 'true'
- name: Set up Python
if: steps.applicability.outputs.run == 'true'
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.14'
- name: Install uv
if: steps.applicability.outputs.run == 'true'
run: python -m pip install uv==0.11.16
- name: Download build artifacts
if: steps.applicability.outputs.run == 'true'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: ci-build-artifacts
path: ci-build-artifacts
- name: Verify build artifacts
if: steps.applicability.outputs.run == 'true'
run: |
set -euo pipefail
cd ci-build-artifacts
sha256sum -c SHA256SUMS
chmod +x bd-linux-gms-pure
- name: Run MCP package gate
if: steps.applicability.outputs.run == 'true'
env:
BEADS_TEST_BD_BINARY: ${{ github.workspace }}/ci-build-artifacts/bd-linux-gms-pure
run: make ci-package-mcp
package-npm:
name: Package Gate (npm)
runs-on: ubuntu-latest
needs: [detect-package-gates, build-artifacts]
steps:
- name: Check applicability
id: applicability
run: |
echo "run=${{ needs.detect-package-gates.outputs.npm_package }}" >> "$GITHUB_OUTPUT"
if [[ "${{ needs.detect-package-gates.outputs.npm_package }}" != "true" ]]; then
echo "npm package gate is not applicable: ${{ needs.detect-package-gates.outputs.reason }}"
fi
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
if: steps.applicability.outputs.run == 'true'
- name: Set up Node.js
if: steps.applicability.outputs.run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: '24'
- name: Download build artifacts
if: steps.applicability.outputs.run == 'true'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: ci-build-artifacts
path: ci-build-artifacts
- name: Verify build artifacts
if: steps.applicability.outputs.run == 'true'
run: |
set -euo pipefail
cd ci-build-artifacts
sha256sum -c SHA256SUMS
chmod +x bd-linux-gms-pure
- name: Run npm package gate
if: steps.applicability.outputs.run == 'true'
env:
BEADS_TEST_BD_BINARY: ${{ github.workspace }}/ci-build-artifacts/bd-linux-gms-pure
run: make ci-package-npm
pr-policy-wrapper:
name: PR Policy (wrapper timing)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
# Same cold-fetch exposure as pr.yml's pr-policy-wrapper: setup-go above
# runs with cache: false, so every run pulls the whole module graph from
# the proxy. Retrying it here means a proxy blip costs seconds instead of
# failing a required check.
#
# Deliberately NOT wrapped around the build: `make ci-pr-policy` runs a
# `go build ./cmd/bd` (scripts/ci/pr-policy.sh, build_docs_binary), and a
# compile error is not transient. See pr.yml's copy for the full rationale.
#
# 3 attempts x 120s + 2 backoffs x 10s = 380s worst case. 8m leaves ~100s
# of headroom, matching the bounded apt-get step in release.yml.
- name: Download modules
timeout-minutes: 8
run: |
downloaded=""
for attempt in 1 2 3; do
if timeout 120 go mod download; then
downloaded=yes
break
fi
echo "::warning::go mod download attempt $attempt failed or timed out"
# No backoff after the final attempt - there is nothing left to wait for.
if [ "$attempt" -lt 3 ]; then
sleep 10
fi
done
# Unlike the best-effort apt-get retries elsewhere in this repo, this
# one is load-bearing: nothing downstream can build without the
# modules. Fail here, naming the fetch, so a module outage is not
# reported as a build failure.
if [ -z "$downloaded" ]; then
echo "::error::go mod download failed after 3 attempts - module fetch failure, not a build failure"
exit 1
fi
- name: Run PR policy wrapper
run: make ci-pr-policy
# macOS full -race -short suite. Linux runs the same suite under Bazel
# (bazel.yml's `test` lane, on every push to main, executed on rbe-west),
# and Windows uses smoke tests below; rbe-west has no macOS workers, so this
# is the one lane that still runs the suite on a runner. Blacksmith macOS,
# the image pr.yml's same-repo macOS legs use; blacksmith-macos-go-build-cache
# seeds its module and non-race caches, and this job saves only its own race
# cache (keyed per go.sum and UTC day, F7b review fix S7).
#
# ./cmd/bd has outgrown `go test`'s 10m per-package default (see
# scripts/test.sh, scripts/ci/pr-core.sh and #6091), and when it trips the
# alarm the panic names whichever test was in flight, so it reads like a
# hang. -timeout=30m sits on the invocation and inside one finite job
# budget: the go deadline fires first and prints goroutine stacks, so a real
# hang is still diagnosable rather than cut off by a bare job kill.
test:
name: Test (macOS)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'gastownhall/beads'
runs-on: ${{ 'blacksmith-6vcpu-macos-26' }}
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Compute cache date
id: cache-date
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Go module cache
id: restore-go-module-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Restore non-race Go build cache
id: restore-non-race-go-build-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-
- name: Restore race Go build cache
id: restore-race-go-build-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-
- name: Install Dolt (Linux/macOS)
run: ./scripts/ci/install-dolt.sh
- name: Verify dolt on PATH
run: dolt version
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Build
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: go build -v -tags gms_pure_go ./cmd/bd
- name: Test
env:
BEADS_TEST_BD_BINARY: ${{ github.workspace }}/bd
GOCACHE: ${{ runner.temp }}/go-cache/race
run: go test -tags gms_pure_go -v -race -short -timeout=30m -skip '^TestEmbedded' ./...
# Restore-only for the module and non-race caches (the macOS saver
# owns them); this job is the race cache's only reader and writer.
- name: Save race Go build cache
if: ${{ !cancelled() && steps.restore-race-go-build-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
# Windows smoke tests only - full test suite times out (see bd-bmev)
# Linux/macOS run comprehensive tests; Windows just verifies binary works
#
# Windows uses -tags gms_pure_go to avoid the ICU regex dependency.
# go-icu-regex's regex_windows.go also uses Go stdlib regexp (build tag: windows).
# CGO is still required for gozstd (bundled C source) and the embedded dolt engine.
# F7b: pr.yml's standalone Windows jobs (test-windows-liveness,
# worktree-remove-windows, etc.) moved to same-repo Blacksmith
# (blacksmith-*vcpu-windows-2025); this job's own module/non-race GOCACHE
# saves already cover the fork/github path (windows-latest), but Blacksmith
# runners cannot see caches `actions/cache` saved from a GitHub-hosted
# runner (and vice versa) even for an identical key, so the `venue` matrix
# dimension here seeds the Blacksmith selection too -- same reasoning as
# windows-test-binaries-cache's `runner` matrix.
test-windows:
name: Test (Windows - smoke, ${{ matrix.venue }})
# F7b review fix (B2): added the repository check to match
# blacksmith-go-build-cache's convention
# above (this job's push-to-main guard predates F7b and already had the
# event/ref check; the repository check closes the same fork gap F7c's
# own blacksmith-setup-go-cache guard closes). Pinned by
# TestBlacksmithSaverJobsGuardedAgainstPullRequest.
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'gastownhall/beads'
runs-on: ${{ matrix.venue == 'blacksmith' && 'blacksmith-4vcpu-windows-2025' || 'windows-latest' }}
# F7b review fix (S8): this job now runs on paid Blacksmith Windows
# (4x billing) for its blacksmith venue leg; it previously had no
# timeout-minutes at all. 20 matches test-windows-liveness's timeout
# (S6) for consistency.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
venue: [blacksmith, github]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
# F7b review fix (S7/Speed): see blacksmith-go-build-cache's identical
# step above for the full rationale.
- name: Compute cache date
id: cache-date
shell: bash
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
# F7b review fix (S9): same Windows toolchain diagnostic as pr.yml's
# moved Windows jobs, run here on the Blacksmith leg too (the venue
# this job's github leg already exercises on windows-latest every push
# without issue, so only the blacksmith leg's image is unverified).
- name: Check Windows toolchain diagnostics
if: matrix.venue == 'blacksmith'
shell: bash
run: go env CGO_ENABLED CC GOOS GOARCH
- name: Restore Go module cache
id: restore-go-module-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Restore non-race Go build cache
id: restore-non-race-go-build-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Build (pure Go regex)
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: go build -v -tags gms_pure_go -o bd.exe ./cmd/bd
- name: Smoke test - version
run: ./bd.exe version
- name: Smoke test - help
run: ./bd.exe help
# F7b review fix (S2): warms the SAME non-race GOCACHE namespace that
# pr-preflight-platforms'/worktree-remove-windows'/test-windows-liveness'
# Windows legs restore from, on the exact same runner selection
# (blacksmith-4vcpu-windows-2025), so their cold `cmd/bd` test compiles
# (the real long pole; see pr-preflight-platforms' S2 comment) get a
# true cache hit. Confirmed to run under Git Bash on Windows (reviewer
# verification); Blacksmith-leg only -- the github (windows-latest)
# venue leg has no PR-side consumer for this namespace, so warming it
# there would be wasted GitHub-hosted cache churn for no reader.
- name: Warm non-race GOCACHE (Windows preflight/liveness consumers)
if: matrix.venue == 'blacksmith'
shell: bash
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: bash scripts/ci/warm-non-race-cache.sh
- name: Save Go module cache
if: steps.restore-go-module-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
- name: Save non-race Go build cache
if: steps.restore-non-race-go-build-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
fmt-check:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Check gofmt
run: make fmt-check
# F7b: the saver for the race and non-race GOCACHEs that same-repo-PR
# (Blacksmith, blacksmith-4vcpu-ubuntu-2404) jobs restore: the non-race one
# for pr-preflight-platforms' and check-doc-freshness-platforms' ubuntu
# legs; the race one compiles ./scripts/... with -race (once the compile
# set of scripts-go-checks' retired scripts-test leg). Blacksmith runners
# cannot see caches `actions/cache` saved from a GitHub-hosted runner (and
# vice versa) even for an identical key, so without this those legs would
# stay cold forever.
#
# The `venue` matrix also seeds the ubuntu-latest (fork/Dependabot) path's
# race cache, which the legacy embedded build used to save before Bazel
# took over that tier on push; build-artifacts still seeds that path's
# non-race cache, so the github x non-race leg is excluded as redundant.
# The ternary `runs-on` form (rather than a literal Blacksmith label) is
# required for actionlint, same as every other Blacksmith `runs-on` here.
# main.yml only triggers on push to main (already trusted).
#
# F7b review fix (B2): pin push-to-main-only at the job level too, not just
# via this workflow's current `on: push` trigger (same defense-in-depth
# rationale as F7c review fix S2's blacksmith-setup-go-cache guard above --
# if main.yml ever gained a pull_request/merge_group trigger, a bare
# `on: push` assumption would silently let this job, and the unguarded
# saver below it, run on a same-repo PR, making every same-repo PR a writer
# of this Blacksmith cache namespace). Pinned by
# TestBlacksmithSaverJobsGuardedAgainstPullRequest.
blacksmith-go-build-cache:
name: Warm Go build cache (${{ matrix.flavor }}, ${{ matrix.venue }})
runs-on: ${{ matrix.venue == 'blacksmith' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'gastownhall/beads'
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
flavor: [race, non-race]
venue: [blacksmith, github]
# build-artifacts seeds the GitHub-hosted non-race cache.
exclude:
- flavor: non-race
venue: github
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
# F7b review fix (S7/Speed): bounds this saver's writes to at most once
# per UTC calendar day per go.sum, not once per push to main. The old
# ${{ github.sha }} suffix wrote a brand-new multi-GB race+non-race
# build-cache entry on every single push regardless of whether go.sum
# changed; on Blacksmith's 25 GB/week/repo quota (LRU eviction, no
# per-repo exemption the way GitHub-hosted actions/cache effectively
# has) that churn (measured ~1.74GB/push for this job's two flavors
# alone) could exhaust the week's budget in a single day of ordinary
# push traffic and evict every other Blacksmith-reachable job's cache.
# Same convention as F7c review fix S5's blacksmith-setup-go-cache
# (main.yml, above). Pinned by TestBlacksmithSaverCacheKeysAreNotPerCommit.
- name: Compute cache date
id: cache-date
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Go module cache
id: restore-go-module-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Restore race Go build cache
id: restore-race-go-build-cache
if: matrix.flavor == 'race'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-
- name: Restore non-race Go build cache
id: restore-non-race-go-build-cache
if: matrix.flavor == 'non-race'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-
# -run '^$' selects no tests (only compiles), so this needs no
# Dolt/test-env setup.
- name: Warm race GOCACHE
if: matrix.flavor == 'race'
env:
GOCACHE: ${{ runner.temp }}/go-cache/race
run: go test -race -run '^$' -tags gms_pure_go ./scripts/...
# pr-preflight-platforms'/check-doc-freshness-platforms' ubuntu legs via
# warm-non-race-cache.sh, shared with build-artifacts' identical step so
# the two paths can never drift apart (F7b spec 4.2).
- name: Warm non-race GOCACHE (preflight/doc-freshness)
if: matrix.flavor == 'non-race'
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: bash scripts/ci/warm-non-race-cache.sh
- name: Save race Go build cache
if: ${{ !cancelled() && matrix.flavor == 'race' && steps.restore-race-go-build-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
- name: Save non-race Go build cache
if: ${{ !cancelled() && matrix.flavor == 'non-race' && steps.restore-non-race-go-build-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
# macOS saver: pr.yml's pr-preflight-platforms and
# check-doc-freshness-platforms macOS legs run on blacksmith-6vcpu-macos-26
# for same-repo PRs/merge_group and on macos-latest for fork/Dependabot PRs,
# and Blacksmith and GitHub-hosted runners cannot see each other's
# actions/cache entries, so the `venue` matrix seeds both (same convention as
# test-windows). This job is their only seeder
# (and the Blacksmith leg also seeds the `test` job's module and non-race
# caches), and runs only the shared warm-up those legs compile
# (warm-non-race-cache.sh, the same script the Linux/Windows seeders use)
# plus the non-test ./cmd/bd build -- no tests, so it stays a few minutes of
# macOS time per push. Same push-to-main-only job guard (B2) and go.sum +
# UTC-day cache keys (S7) as blacksmith-go-build-cache, so a PR can never
# write this namespace and ordinary push traffic writes at most one
# non-race entry per day per venue. Pinned by
# TestBlacksmithSaverJobsGuardedAgainstPullRequest,
# TestBlacksmithSaverCacheKeysAreNotPerCommit and
# TestBlacksmithMacOSSaverMatchesPRLegs.
blacksmith-macos-go-build-cache:
name: Warm macOS Go build cache (${{ matrix.venue }})
runs-on: ${{ matrix.venue == 'blacksmith' && 'blacksmith-6vcpu-macos-26' || 'macos-latest' }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'gastownhall/beads'
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
venue: [blacksmith, github]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Compute cache date
id: cache-date
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Go module cache
id: restore-go-module-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Restore non-race Go build cache
id: restore-non-race-go-build-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-
# Records each venue's toolchain in the log so an image drift between
# Blacksmith and GitHub's macos-latest is visible next to the cache it
# seeds.
- name: Check macOS toolchain diagnostics
run: |
sw_vers
go env GOOS GOARCH CGO_ENABLED CC
bash --version | head -n 1
- name: Build
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: go build -tags gms_pure_go -o /dev/null ./cmd/bd
- name: Warm non-race GOCACHE for macOS preflight/doc-freshness
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: bash scripts/ci/warm-non-race-cache.sh
- name: Save Go module cache
if: ${{ !cancelled() && steps.restore-go-module-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
- name: Save non-race Go build cache
if: ${{ !cancelled() && steps.restore-non-race-go-build-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
test-nix:
name: Test Nix Flake
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: DeterminateSystems/determinate-nix-action@527f17dd63d2d60d3e5552934bc84b9a33a14d11 # v3
- name: Run bd help via Nix
id: nix_help
run: |
nix run .#default -- --help > help.txt
# Every flake check for the runner's own system (today: hook-timeout-
# backends, checks.nix). `nix flake check` rather than a spelled-out
# `.#checks.x86_64-linux.<name>`: no hardcoded system, and a check added
# to checks.nix is run without a workflow edit.
- name: Run the flake checks
run: |
nix flake check -L
- name: Verify help text
if: steps.nix_help.outcome == 'success'
run: |
FIRST_LINE=$(head -n 1 help.txt)
EXPECTED="Issues chained together like beads. A lightweight issue tracker with first-class dependency support."
if [ "$FIRST_LINE" != "$EXPECTED" ]; then
echo "First line of help.txt doesn't match expected output"
echo "Expected: $EXPECTED"
echo "Got: $FIRST_LINE"
exit 1
fi
echo "Help text first line is correct"
# F7c: Blacksmith cannot see GitHub-hosted cache entries, so the advisory
# workflows that moved onto a same-repo-PR Blacksmith runner (Regression's
# PR run, Cross-Version Smoke, Proxied Local) need a
# Blacksmith-side writer for their Go build
# cache. This job is push-to-main only (always trusted), so it is the ONLY
# writer: it always restores whatever is available, unconditionally re-runs
# every warm-up command (not gated on a cache hit), and then always saves
# under a key suffixed with this push's commit SHA. Every PR-side consumer
# uses `actions/cache/restore` only (never saves) with the same key
# prefix/restore-keys below, so a same-repo PR can read this cache but can
# never write an entry another PR or main would later read back unverified
# (B2, F7c implementation report). This also means the key format is one we
# define ourselves (`blacksmith-sg-v1-...`), not setup-go's own implicit
# key, so there is no dependency on Blacksmith's `$ImageOS` resolving the
# same way setup-go's own cache-action would have assumed.
#
# Precondition (spec-f7.md §3): an org admin must confirm Blacksmith's
# "branch-protected caches" toggle is ON before this seed is trusted to
# feed PR-scoped restores; a mismatched or OFF setting only degrades PR
# jobs to a cold cache (restore-only, so there is no correctness risk
# either way) -- see the F7c implementation report.
blacksmith-setup-go-cache:
name: Seed setup-go cache (Blacksmith)
# A literal (non-expression) Blacksmith label is actionlint's unknown-
# runner-label check; every other same-repo Blacksmith job in this repo
# routes through a conditional expression instead (actionlint only
# validates literal runs-on strings). This job is push-to-main only
# (always trusted, so there is nothing to gate on), but it still wraps
# the label in a trivial expression to keep actionlint clean and match
# repo convention.
runs-on: ${{ 'blacksmith-4vcpu-ubuntu-2404' }}
# F7c review fix S2: pin push-to-main-only at the job level, not just via
# this workflow's current `on: push` trigger. If main.yml ever gained a
# pull_request (or merge_group) trigger in the future, a bare
# `github.repository == ...` guard would let this job - and the bare,
# always-saving cache below it - run on a PR, making every same-repo PR a
# writer of the Blacksmith setup-go cache namespace every advisory
# consumer trusts. Pinned exactly by
# TestBlacksmithSeederGuardedAgainstPullRequest.
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'gastownhall/beads'
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
# F7c review fix S5: the old key suffix was ${{ github.sha }}, so every
# single push to main - whether or not go.sum changed - saved a brand
# new multi-GB ~/go/pkg/mod + ~/.cache/go-build entry under this
# namespace. On a cache store with LRU eviction (Blacksmith), that churn
# risked evicting F7a's own beads-go-mod-v2-*/beads-go-build-v2-* cache
# entries. Keying per UTC day instead still bounds staleness (a go.sum
# change is picked up on save on the very next push, and a same-day
# restore-keys fallback to yesterday's entry is only ever a prefix
# away), while capping writes to at most once per calendar day instead
# of once per push. Pinned by TestBlacksmithSeederCacheKeyIsNotPerCommit.
- name: Compute cache date
id: cache-date
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
# Unconditional (not gated on a cache hit): this job's entire purpose is
# to keep the Blacksmith-side cache warm, so it must always repopulate
# GOCACHE/GOMODCACHE even when the restore step above already found a
# usable entry (a stale or partial restore should still self-heal here).
- name: Build bd
run: make build
# Always save (even if a warm-up step above failed) under a fresh,
# commit-specific key: the content is still a valid, newer GOCACHE/
# GOMODCACHE snapshot than whatever was restored, and `cache/save` is a
# pure write with no read-back of PR-controlled state, so there is no
# poisoning concern in saving unconditionally here.
- name: Save Blacksmith setup-go cache
if: always()
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}