build: fix the custom linter cache wiring for CI
What changed, and why it matters
This commit fixes the GitHub Actions CI setup for running a custom code linter. It makes sure Docker can read and write build caches correctly and that the built linter image is available for later steps. There is no user-facing security fix here; it is purely a build-infrastructure improvement.
No security action required. Treat as a normal CI maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adjusts .github/workflows/main.yml and the Makefile so that the custom golangci-lint Docker image can use the GitHub Actions (gha) BuildKit cache backend. It exposes ACTIONS_RUNTIME_TOKEN and ACTIONS_RESULTS_URL via crazy-max/ghaction-github-runtime, adds –load to docker build so the image is stored locally, and only writes the cache during nightly runs (LINT_WRITE_CACHE=1) to avoid cache churn from pull requests. This is a CI reliability/performance fix, not a vulnerability patch.
Changed components
.github/workflows/main.ymlMakefileInspect captured patch +30 / −8
### .github/workflows/main.yml
@@ -49,6 +49,15 @@ on:
type: string
required: true
+ # Used by nightly.yml to run the nightly tier, which is also the only run
+ # that writes the shared lint caches (see the lint job).
+ workflow_call:
+ inputs:
+ tier:
+ description: "The tier to run, only nightly is supported"
+ required: true
+ type: string
+
permissions:
# Required to manage and delete caches.
actions: write
@@ -343,12 +352,24 @@ jobs:
# The lint targets build a Docker image that compiles the custom
# golangci-lint binary from source, which takes several minutes on a
# cold runner. Set up BuildKit with the GitHub Actions cache backend
- # so the image layers (and with them the compiled binary) are reused
- # across runs whenever the tools/ inputs are unchanged.
+ # so the image layers (and with them the compiled binary) can be
+ # reused across runs whenever the tools/ inputs are unchanged. The
+ # ghaction-github-runtime step exposes the GitHub cache credentials
+ # to plain run: steps; without it the gha cache backend in a
+ # manually invoked docker build has no way to reach the cache store.
+ - name: Expose GitHub runtime credentials for BuildKit
+ uses: crazy-max/ghaction-github-runtime@v3
+
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: lint
+ env:
+ # Cache exports are reserved for the nightly master run, which is
+ # reachable here as the workflow_call input. PR caches aren't
+ # readable by other PRs, and exporting on every push would churn
+ # the shared cache store for no reuse benefit.
+ LINT_WRITE_CACHE: ${{ inputs.tier == 'nightly' && '1' || '' }}
run: GOGC=50 make lint
- name: lint submodules
### Makefile
@@ -78,12 +78,13 @@ endif
# avoiding slow host-syncing overhead).
# Paths inside container must match GOCACHE/GOMODCACHE in tools/Dockerfile.
ifdef CI
-# In CI the custom linter build cache lives in GitHub Actions' cache
-# store (see the lint job in main.yml), so every lint job that shares
-# the same tools/ dependencies reuses the compiled linter binary instead
-# of rebuilding the roughly four minute compile from source.
-export DOCKER_BUILD_ARGS = --cache-from type=gha --cache-to type=gha,mode=max \
- --build-arg BUILDKIT_INLINE_CACHE=1
+# Read the custom linter build cache from GitHub Actions' cache store. Only
+# the nightly run writes it (LINT_WRITE_CACHE=1), so per-PR builds don't
+# evict the shared Go caches. The cache scopes are set in the lint job.
+DOCKER_BUILD_ARGS = --load --cache-from type=gha
+ifdef LINT_WRITE_CACHE
+DOCKER_BUILD_ARGS += --cache-to type=gha,mode=max
+endif
# CI mode: bind mount to host paths that GitHub Actions caches.
DOCKER_TOOLS_BASE = docker run \
--rm \Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.