Skip to content

ci: restore the Go cache in build, govulncheck and check-generated - #1458

Merged
lklimek merged 6 commits into
v1.8-devfrom
chore/ci-setup-go-cache
Sep 14, 2026
Merged

lklimek merged 6 commits into
v1.8-devfrom
chore/ci-setup-go-cache

Conversation

@lklimek

@lklimek lklimek commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: Three CI workflows rebuilt all Go code from scratch on every run because their cache never loaded. This PR fixes the step order so the cache is used, which makes those checks finish faster.

User story

As a contributor opening a pull request, I want the Build, Vulnerability Scan and Check-generated-code checks to reuse previous work, so I get CI results sooner.

Scenario

Base flow

A contributor pushes a change and waits for the Build, Vulnerability Scan and Check generated code checks.

Actual behavior

Each of these checks downloads all Go dependencies and compiles everything from zero on every run. The cache they are configured to use is never loaded. Separately, editing the check-generated workflow itself never re-runs the mock check it defines.

Expected behavior

The checks load a cache prepared by earlier runs and only rebuild what changed. Checks with nothing to do skip the cache download entirely. Editing the check-generated workflow re-runs its mock check.

Detailed discussion

Issue being fixed

In build.yml (3 jobs), govulncheck.yml and check-generated.yml (2 jobs), actions/setup-go ran before actions/checkout. setup-go's built-in cache (cache: true by default) hashes cache-dependency-path (default go.mod/go.sum) to build its key. At that point no files were checked out, so every run logged Restore cache failed: Dependencies file is not found ... Supported file pattern: go.mod and no GOMODCACHE/GOCACHE was ever restored or saved. tests.yml and lint.yml already use the correct order.

Current cost (latest green PR runs): test_apps install 121s, build install 41s, test_abci_cli install 42s, govulncheck scan 35s, check-mocks 48s — all cold.

What was done

  • actions/setup-go now runs after actions/checkout (and after get-diff-action where a job has one).

  • In jobs gated on GIT_DIFF, setup-go is gated too. Jobs with nothing to check no longer download a cache they never use. All Go-using steps in those jobs were already gated, so nothing else changes.

  • Each workflow gets its own cache key by adding files to cache-dependency-path, a documented setup-go pattern (advanced usage: multi-target builds):

    • build.yml, govulncheck.yml: go.sum + the workflow file.
    • check-generated.yml: go.sum + workflow file + per-job tool config (.mockery.yaml for check-mocks, buf.yaml/buf.gen.yaml/buf.lock for check-proto), so the two parallel jobs don't race for one key.

    Without this, every workflow would share setup-go's default key with tests.yml (-race builds). They would restore that cache, which is of little use to them, and never save their own.

  • check-generated.yml's check-mocks listed .github/workflows/check-generated.yml under get-diff-action's FILES. FILES matches bare file names, so a full path never matched and edits to the workflow never triggered the check. The path is now listed under PATTERNS (minimatch globs).

  • Cache footprint: caches are saved only on a key miss. Pull requests restore the base-branch entry and don't save while go.sum and the workflow file are unchanged. Expect about one new entry of ~300 MB per workflow on the base branch.

Known limitation, same as the existing tests.yml/lint.yml caches: the key doesn't include the BLS C library revision. cgo does not track external C headers or libraries in GOCACHE. In practice a BLS bump normally also bumps the go-bindings module in go.sum, which rotates the key.

Testing

  • actionlint 1.7.12 on the three files: no new findings. The only report is the pre-existing SC2155 in the check-proto script, also reported on the base version.
  • On this PR, govulncheck missed the cache as expected (new key) and saved it: Cache saved with the key: setup-go-Linux-x64-ubuntu24-go-1.27.1-eb3faf55…, distinct from the tests.yml key.
  • check-mocks runs on this PR once the PATTERNS fix is in, which exercises its cache path.
  • build.yml jobs and check-proto are gated on Go/proto diffs, so they're skipped here. They'll first exercise the new order on the next PR touching Go code.
  • The first run per key is a cache miss and pays the save step (~10–20s). Later runs restore it.

Breaking changes

None. CI-only change.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests (n/a, CI config)
  • I have made corresponding changes to the documentation (n/a)

Prior work

🤖 Generated with Claude Code

actions/setup-go ran before actions/checkout in these workflows, so its
cache step found no go.mod/go.sum and skipped the Go module and build cache
restore entirely ("Restore cache failed: Dependencies file is not found").
Every run compiled from scratch.

- run setup-go after checkout (and after get-diff-action where present)
- skip setup-go when the job's GIT_DIFF gate is empty, so skipped jobs don't
  download a cache they never use
- key each workflow's cache on go.sum plus the workflow file, and in
  check-generated on each job's tool config (.mockery.yaml / buf.*), so
  these caches don't collide with the tests.yml/lint.yml cache key

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: d5c6c347-df72-42b2-b163-ccc7454e6f69

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

get-diff-action's FILES input matches bare file names anywhere in the tree,
so the full path `.github/workflows/check-generated.yml` never matched and
edits to this workflow never triggered the mock check. List the path under
PATTERNS (minimatch globs) instead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

PR Hygiene

State: waiting-self-review · commit ba9df0ef8d4b8b641637b62643b452c25171138a

  • Author must post /self-reviewed ba9df0e after bot completion

Self-review is an author attestation that you have read the diff:
/self-reviewed — covers everything pushed so far; post it again after a new push.
Post it after this report appears for commit ba9df0ef8d4b8b641637b62643b452c25171138a, or name the commit explicitly with /self-reviewed ba9df0ef8d4b8b641637b62643b452c25171138a.

This report does not bypass CI or repository protection rules.

@lklimek
lklimek marked this pull request as ready for review September 14, 2026 09:27
@lklimek
lklimek requested a review from shumkov as a code owner September 14, 2026 09:27
@thepastaclaw

thepastaclaw commented Sep 14, 2026 •

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit ba9df0e) · triage: normal

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The cache ordering and per-workflow cache-key changes correctly address the primary CI cache issue, and the workflow-path pattern now reruns the mock check when the workflow changes. However, both generated-code jobs still trigger only on source-file patterns, so changes to their generation configuration can skip validation and allow stale generated output to merge.

🔴 2 blocking

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: general); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: low by gpt-6-astra (effort low) — This is a small, well-contained CI workflow change that reorders setup steps, adjusts cache keys and gates, and corrects a file-matching pattern without affecting product logic or critical surfaces.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 11% left, 5h 100% left), glm-5.3-flash (zai below 15% reserve: 5h 100% left, weekly 13% left)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `.github/workflows/check-generated.yml`:
- [BLOCKING] .github/workflows/check-generated.yml:31-34: Run mock generation checks when Mockery configuration changes
  The check-mocks job now hashes `.mockery.yaml` in its Go cache key, and `make mockery` uses that configuration to generate mocks, but `PATTERNS` does not include `.mockery.yaml`. A pull request that changes only `.mockery.yaml` leaves `GIT_DIFF` empty, so both setup-go and the generated-mock verification step are skipped. This allows configuration changes that require regenerated mocks to merge without validation. Add `.mockery.yaml` to the diff patterns.
- [BLOCKING] .github/workflows/check-generated.yml:70-72: Run protobuf generation checks when Buf configuration changes
  The check-proto job's generation output depends on `buf.yaml`, `buf.gen.yaml`, and `buf.lock`, and all three files are included in its cache-dependency-path, but none is included in `PATTERNS`. A pull request changing only a Buf configuration file leaves `GIT_DIFF` empty, so protobuf generation and the generated-code diff check are skipped. Generated `.pb.go` output can therefore become stale without CI detecting it. Include the Buf configuration files, and the workflow file whose generation commands and inputs define this check, in the patterns.

Comment thread .github/workflows/check-generated.yml Resolved
Comment thread .github/workflows/check-generated.yml Resolved
lklimek and others added 3 commits September 14, 2026 10:26
check-mocks and check-proto skip their generation checks when only
.mockery.yaml or a Buf config file (buf.yaml, buf.gen.yaml, buf.lock)
changes, since GIT_DIFF stays empty and both setup-go and the
verification step are skipped. Add these files (and the workflow file
itself for check-proto, matching check-mocks) to PATTERNS.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The check-proto CI job never ran on this branch's own workflow-file
change until PATTERNS was widened to cover it (see previous commit),
which surfaced generated code drift accumulated since the gogoproto
fork bump in go.mod (unrelated PR #1189). Diff is purely cosmetic:
regenerated gzipped FileDescriptorProto bytes and a comment-formatting
change from the current protoc-gen-gogofaster/buf versions; no field,
method, or wire-format changes (verified via `git diff --unified=0`
with the descriptor-byte and comment-only lines filtered out).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The CI changes correctly move setup-go after checkout, gate cache setup consistently with the existing diff checks, and isolate workflow and tool caches using appropriate dependency paths. The generated-code trigger fixes for Buf and Mockery configuration, including the workflow file itself, are present and address both prior findings. No new in-scope defects were found.

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: general); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: normal by gpt-6-astra (effort low) — The diff changes multiple CI workflows, cache-key and job-gating behavior, and regenerates many protobuf files, making it broader than a trivial configuration fix, but it does not modify a critical surface such as consensus, cryptography, funds movement, networking deserialization, or storage migrations.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort max); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 98% left, weekly 96% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 11% left, 5h 100% left)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Unify BLS revision handling in setup-go cache keys — The affected workflow caches, like the existing tests.yml and lint.yml caches, do not include the vendored BLS C headers or library revision in cache-dependency-path. Because cgo does not track external C dependencies in GOCACHE, a BLS revision change that does not also change go.sum could restore artifacts built against stale C inputs. This is an existing repository-wide cache-key policy issue and is outside this CI restoration PR.
    • Follow-up: Track a separate issue to adopt the BLS dependency globs used by e2e.yml across all Go cache configurations, or document the repository-wide cache-key policy for cgo dependencies.

@lklimek
lklimek merged commit 8041d43 into v1.8-dev Sep 14, 2026
35 of 37 checks passed
@lklimek
lklimek deleted the chore/ci-setup-go-cache branch September 14, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants