Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

CI: turn the Go module cache on, and retry module downloads

Claudeebceab419396
diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml
new file mode 100644
index 00000000..9ed5c117
--- /dev/null
+++ b/.github/actions/setup-go/action.yml
@@ -0,0 +1,81 @@
+name: Set up Go
+description: >
+ actions/setup-go plus the two things this repository needs on top of it: a
+ module cache that actually restores, and a module download that survives a
+ transient proxy timeout.
+
+inputs:
+ go-version-file:
+ description: The go.mod whose toolchain line picks the Go version.
+ required: false
+ default: cli/beacon/go.mod
+ modules:
+ description: >
+ Module directories this job builds or tests, one per line. Their go.sum
+ files key the module cache, and their dependencies are downloaded up
+ front so a slow proxy fails a step that retries rather than a test step
+ that does not.
+ required: true
+
+runs:
+ using: composite
+ steps:
+ # actions/setup-go looks for go.sum in the working directory and walks up.
+ # This repository keeps five modules in subdirectories and none at the
+ # root, so the default lookup finds nothing, logs "Restore cache failed:
+ # Dependencies file is not found", and every job re-downloads every module
+ # from proxy.golang.org on every run. Naming the go.sum files explicitly is
+ # what turns the module cache on at all.
+ #
+ # The list is per-job rather than all five everywhere on purpose: it is
+ # hashed into the cache key, so a job that needs the collector's OTel tree
+ # gets an entry of its own instead of restoring -- and then never
+ # re-saving over -- the smaller entry written by a job that only builds the
+ # CLI.
+ - id: sums
+ shell: bash
+ env:
+ MODULES: ${{ inputs.modules }}
+ run: |
+ set -euo pipefail
+ {
+ echo 'paths<<SUMS_EOF'
+ while read -r dir; do
+ dir="${dir%/}"
+ [ -n "$dir" ] || continue
+ test -f "$dir/go.sum" || { echo "no go.sum in $dir" >&2; exit 1; }
+ echo "$dir/go.sum"
+ done <<< "$MODULES"
+ echo 'SUMS_EOF'
+ } >> "$GITHUB_OUTPUT"
+
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: ${{ inputs.go-version-file }}
+ cache-dependency-path: ${{ steps.sums.outputs.paths }}
+
+ # A cache hit makes this a no-op. On a miss it is where the download
+ # happens, and it retries: `go test` and `go build` fetch modules inline
+ # and give up on the first network error, which is how a proxy timeout
+ # reads as a failed test run rather than as a failed download.
+ - name: Download Go modules
+ shell: bash
+ env:
+ MODULES: ${{ inputs.modules }}
+ run: |
+ set -uo pipefail
+ while read -r dir; do
+ dir="${dir%/}"
+ [ -n "$dir" ] || continue
+ attempt=1
+ until (cd "$dir" && go mod download); do
+ if [ "$attempt" -ge 4 ]; then
+ echo "::error::go mod download failed in $dir after $attempt attempts"
+ exit 1
+ fi
+ delay=$((attempt * attempt * 2))
+ echo "go mod download failed in $dir; retrying in ${delay}s" >&2
+ sleep "$delay"
+ attempt=$((attempt + 1))
+ done
+ done <<< "$MODULES"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 69559e60..93429b38 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -156,9 +156,13 @@ jobs:
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
+ collector-builder/exporter/beaconjsonexporter
+ pkg/asymptoteobserve
- name: Check OpenCode plugin
working-directory: plugins/opencode-beacon
run: bun run check && bun test
@@ -219,9 +223,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
go-version-file: beacon-sandbox/go.mod
+ modules: |
+ beacon-sandbox
# These tests are hermetic: no Modal account, no Anthropic key, no sandbox, and no
# paid resources. (Go module downloads still happen, as in every other job here.)
# They gate because they are what makes a green verification run mean
@@ -258,9 +264,11 @@ jobs:
make_target: build-windows-amd64
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
- name: Build Beacon for ${{ matrix.goos }}/${{ matrix.goarch }}
working-directory: cli/beacon
run: make ${{ matrix.make_target }}
@@ -305,9 +313,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
+ collector-builder/exporter/beaconjsonexporter
+ pkg/asymptoteobserve
# The embedded hooks binary must match the platform under test: the CLI validates its
# architecture at runtime, so a macOS placeholder fails hook installation on Linux.
- name: Build platform-matched hooks binary
@@ -345,9 +357,14 @@ jobs:
shell: pwsh
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
+ collector-builder/exporter/beaconjsonexporter
+ pkg/asymptoteobserve
+ beacon-sandbox
# The embedded hooks binary must match the platform under test: the CLI validates its
# architecture at runtime, so a placeholder fails hook installation on Windows.
- name: Build platform-matched hooks binary
@@ -424,9 +441,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
- name: Build Linux beacon binary
working-directory: cli/beacon
run: make build-linux-amd64
@@ -452,9 +471,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
- name: Build collector for Linux
run: |
go install go.opentelemetry.io/collector/cmd/[email protected]
@@ -493,9 +514,11 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
- name: Validate packaging scripts
run: |
test -x packaging/macos/install-endpoint.sh
@@ -531,9 +554,11 @@ jobs:
shell: pwsh
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
# Cheap, and it runs before anything is built: a syntax error in a packaging script would
# otherwise surface inside an MSI custom action, where what the user sees is a rollback.
diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml
index fafa1cfe..fe8233d9 100644
--- a/.github/workflows/release-check.yml
+++ b/.github/workflows/release-check.yml
@@ -24,9 +24,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ cli/beacon
+ cli/beacon-hooks
- uses: goreleaser/goreleaser-action@v6
with:
# Keep formulas working until we intentionally migrate the tap to casks.
diff --git a/.github/workflows/windows-sandbox.yml b/.github/workflows/windows-sandbox.yml
index 6556b946..1388a1f2 100644
--- a/.github/workflows/windows-sandbox.yml
+++ b/.github/workflows/windows-sandbox.yml
@@ -48,9 +48,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- - uses: actions/setup-go@v5
+ - uses: ./.github/actions/setup-go
with:
- go-version-file: cli/beacon/go.mod
+ modules: |
+ beacon-sandbox
+ cli/beacon
+ cli/beacon-hooks
# Runs the generated-PowerShell parse test, which is skipped on a maintainer's machine
# without pwsh. The generated scripts are assembled in Go, so a syntax error in one is