← Back to Pull requests

ci: persist golangci-lint analysis cache between runs #11505

Closed
unknown closed this pull request without merging on Nov 05, 2026 03:38 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 02:25 UTC
Author

Problem

The lint job re-analyzes the entire repository on every run because nothing persists golangci-lint's per-file analysis cache between runs. The lint and lint submodules steps bind mount ~/.cache/golangci-lint into the tools container as /root/.cache/golangci-lint, but that directory is never saved or restored, so every job starts cold. The log confirms it: every run ends with File cache stats: 0 entries of total size 0B, and the main-repo lint pass takes ~8 minutes (measured in job 126979734038, 01:46:55 to 01:55:12).

The Go module cache and build cache are already restored through the setup-go composite action, so dependency downloads aren't the issue here. The missing piece is the analysis cache that lets golangci-lint skip packages whose sources haven't changed. This PR is separate from #11504, which caches the compiled linter binary itself (a ~3.6 minute saving); this one addresses the ~8 minute analysis pass.

Solution

In this PR, we add an actions/cache step to the lint job that restores and saves ~/.cache/golangci-lint.

The cache is keyed as follows:

  • The exact key is lint-analysis-<os>-go-<version>-<config/tools hash>-<commit SHA>. The commit SHA makes the key unique per run so every run saves a fresh snapshot (a static key would save once and then never update).

  • The restore-key prefix drops the SHA: lint-analysis-<os>-go-<version>-<config/tools hash>-. A source-only change therefore restores the most recent previous snapshot and only re-analyzes the changed packages.

  • The config/tools hash covers .golangci.yml, tools/go.mod, tools/go.sum, tools/.custom-gcl.yml, and tools/linters/*/.go. Any change to the lint config, the pinned linter version, its dependencies, or the custom linter plugins falls back to a clean analysis rather than restoring results produced by a different linter.
  • The existing cache cleanup job (deletes caches older than 12 hours) bounds how many snapshots accumulate, and GitHub's 10GB LRU eviction applies on top of that.

    Expected impact

    Locally, running the same image the CI lint job uses (lnd-tools), a warm analysis cache cut the main-repo lint pass from 1m36s to 1m22s on a warm tree with Docker overhead dominating. The CI saving is larger because the CI pass is cold-typechecking everything with GOGC=50, which is what makes the cold 8 minutes. The exact CI saving can't be measured without a real runner round-trip; the expected effect is that packages whose sources didn't change are skipped.

    Verification

  • actionlint v1.7.12 on .github/workflows/main.yml: clean.

  • YAML parse of the workflow: OK; the lint job now lists the golangci-lint analysis cache step before the lint steps.

  • git diff --check: clean.

  • scripts/check-release-notes.sh with the PR ref: passes.

  • Local cache behavior verified: running custom-gcl cache status against the bind-mounted directory after a lint pass shows a populated cache (Size: 4.4MiB), and a second run is faster than the first.

  • Not verified: a real GHA cache restore on a runner. The first run after this merges populates the cache; the second run should show Cache restored from key: lint-analysis-... and a File cache stats line with nonzero entries in the lint log.
  • Out of scope

  • The 12 submodule lints still run as 12 sequential docker run invocations. They share the same analysis cache directory, so submodule packages reused from the main pass benefit too, but a parallel fan-out or single-pass lint is a separate change.

  • The GOGC=50 setting and the runner disk-cleanup step (~3 minutes) are untouched; whether they belong in the lint job is a separate question.
  • Diff: 470 lines (+352 / -118) across 5 files Reviewer: ziggie1984 Review duration: 73m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 470 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.368
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11505"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.7% (MEDIUM) · Higher = larger blast radius
    45.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%