Skip to content

perf(pre-commit-advisory): skip the Go hook caches when the diff has no Go - #59

Merged
blairham merged 1 commit into
mainfrom
feat/advisory-go-cache-gate
Aug 15, 2026
Merged

perf(pre-commit-advisory): skip the Go hook caches when the diff has no Go#59
blairham merged 1 commit into
mainfrom
feat/advisory-go-cache-gate

Conversation

@blairham

@blairham blairham commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The advisory job's time is ~99% cache transfer on non-Go PRs: the Go hook caches are ~1.7GB compressed (k5s), costing 40–50s restore per PR run and ~70s save per main push, while a workflows-only diff's hook run takes ~1s (measured on k5s#99: 72–87s job total).
  • Adds a Detect Go-relevant changes step (diff endpoints already available; checkout is fetch-depth: 0) matching *.go, go.mod/go.sum, .golangci.*, .pre-commit-config.yaml, and gates the Go cache restore and the main-push warm/save seed steps on it.
  • Skipping the seed on a non-Go push is strictly correct, not just cheap: such a push changes no Go analysis input, so the previously saved cache is still exact and the restore-keys prefix serves it regardless of which sha saved it.
  • Unavailable diff base (branch-create zeros, force-push) defaults to changed=true — the failure mode is a wasted restore, never a cold Go PR.
  • Expected effect: non-Go PR advisory runs drop from ~72–87s to ~25–30s; non-Go main pushes stop re-uploading an identical 1.7GB. Go-touching runs are unchanged.

Test plan

  • actionlint green
  • Validation PR k5s#100 (closed after validating), run 31885494820: workflows-only diff logged the skip and the advisory job ran in 30s (from 72–87s)
  • Run 31885721380 (.go-touching commit): logged the restore path, restored go-hook-caches-Linux-…, golangci hooks ran warm and passed

🤖 Generated with Claude Code

…no Go

The Go hook caches (~/go/pkg/mod + go-build + golangci-lint) are ~1.7GB
compressed on k5s — 40-50s to restore on every PR run and ~70s to save
on every main push. They exist only for the diff-triggered
language:golang hooks, which skip when nothing Go-relevant changed, so
a non-Go PR pays the whole transfer for a hook run that takes ~1s
(measured on k5s#99: 52s restore, 1s hook run, job 72-87s total against
~25s of genuinely needed work).

Detect Go-relevant changes (*.go, go.mod/go.sum, .golangci.*,
.pre-commit-config.yaml) between the run's diff endpoints and gate the
restore AND the main-push seed steps on it. Skipping the seed on a
non-Go push is strictly correct: the push changed no Go analysis input,
so the previously saved cache is still exact and the restore-keys
prefix serves it regardless of sha. An unavailable diff base
(branch-create zeros, force-push) defaults to changed=true — the
failure mode is a wasted restore, never a cold Go PR.
@blairham
blairham merged commit e0dca88 into main Aug 15, 2026
2 checks passed
@blairham
blairham deleted the feat/advisory-go-cache-gate branch August 15, 2026 14:16
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.

1 participant