perf(pre-commit-advisory): skip the Go hook caches when the diff has no Go - #59
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Detect Go-relevant changesstep (diff endpoints already available; checkout isfetch-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.restore-keysprefix serves it regardless of which sha saved it.changed=true— the failure mode is a wasted restore, never a cold Go PR.Test plan
.go-touching commit): logged the restore path, restoredgo-hook-caches-Linux-…, golangci hooks ran warm and passed🤖 Generated with Claude Code