Skip to content

ci: warm reusable SCA analysis caches - #28101

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/warm-sca-analysis-cache
Sep 4, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/warm-sca-analysis-cache

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

Refs #28100

What this PR does / why we need it:

Adds the trusted main producer for the golangci-lint analysis cache consumed by matrixorigin/CI#444, and splits reusable analyzer commands without changing the complete SCA contract.

  • make static-check remains the full package-graph verification, molint, header, dependency, and golangci entry point.
  • make static-check-analysis remains full ./... package-graph verification plus molint and golangci for PR CI; the trusted CI workflow owns conservative license scope selection.
  • make static-check-golangci exists only so the producer can populate the cache consumed by golangci. It does not repeat package-graph, molint, or license validation because the producer is not a validation gate and golangci itself owns cache population.
  • The producer is scheduled daily to keep module/native/tool caches inside the configured seven-day retention window.
  • Expensive full golangci warming runs only when the exact analysis key misses. Weekly generation rollover normally causes one cold warm per week; exact daily hits skip it.
  • A compatible prefix cache can seed a new exact entry, while golangci-lint revalidates package source and dependency inputs.
  • Only golangci-lint analysis data is published. The roughly 4.7-GiB Go build cache is excluded to avoid thrashing the repository-wide 10-GiB cache quota.
  • Publication rejects an empty cache, more than 200,000 files, or an estimated zstd archive above 160 MiB. It does not use filesystem-block usage, which substantially overstates this many-small-file workload.
  • An exact-but-unusable cache fails before the long warm because GitHub cache keys are immutable and warming cannot repair the existing key. Misses and usable prefix restores can still warm and publish a new exact key.
  • The shared restore action records exact/prefix/miss/unusable state, matched key, restored disk size, and restore-path time.
  • Golangci concurrency is limited to one so a cold generation fits the unchanged 4-core/8-GiB runner.

This producer is a cache optimization, not a reduced validation gate. PR SCA continues to run complete package-graph verification, both full-package analyzers, and all applicable license checks.

QA test plan

Fast checks completed at the current heads:

  • actionlint, YAML parsing, and git diff checks pass;
  • Make dry-runs prove make static-check still contains package-graph, molint, both license, and full golangci checks;
  • Make dry-runs prove make static-check-analysis still contains package-graph, full ./... molint, and full golangci;
  • Make dry-runs prove the producer target runs exactly full ./... golangci without repeating package-graph, molint, or license work;
  • companion ci: reuse SCA analysis caches CI#444 has eleven license-scope tests and five exact/prefix/miss/unusable cache-state tests;
  • a local representative accumulated golangci cache had 89,757 files and 353 MiB filesystem usage but a 6,971,000-byte zstd archive produced in 10.43 seconds, validating the archive-based budget and file-count guard.

An earlier Linux arm64 4 CPU/8 GiB cold run showed concurrency 1 fits where automatic concurrency can OOM. No full local hot-duration result is claimed.

Staged acceptance and rollback

matrixorigin/CI#444 must merge first. Then rerun this PR to validate the new cold consumer/fallback path. A trusted main cache cannot be published safely from an unmerged PR, so exact-hit timing is measured after this producer first runs on main: record cache size, exact/fallback hit state, restore time, analyzer time, and total SCA against issue #28100 baseline of 45m24s average and 43m40s median.

The initial 20 to 30 minute common-PR range is an estimate, not a measured result. If the cache is unavailable, corrupt, or rejected, PR SCA falls back to the complete cold analyzer path; disabling the restore action rolls back only the optimization, not test coverage.

Dependency and merge order: matrixorigin/CI#444 first, then this PR.

Path-compatibility correction

The producer now keeps GOMODCACHE at the deterministic $GITHUB_WORKSPACE/.sca-go-module-cache path also used by the optimized PR consumer. .gitignore and .licenserc.yml explicitly exclude that CI-only directory, so the stable path does not pollute the worktree or expand complete license scans. The shared v3 restore action includes module root, GOMODCACHE, GOROOT, and GOCACHE in its compatibility identity because golangci-lint package hashes contain absolute compiled-file paths.

Historical trusted-producer run 33789617303 and PR SCA run 33828032583 confirm that the relevant runner pool uses the same four absolute roots. If a runner has a different layout, it receives a different outer lineage and performs a complete cold analysis instead of reporting a misleading exact hit. The companion action includes a deterministic test that changing any compatibility input changes the cache identity.

Network-failure hardening

SCA run 33837308158 exposed a separate Prepare ENV failure before analysis began. The approximately 1.0 GB Go module archive restored only about 10.7% before timing out, the full native-cache restore was reset, and the fallback then downloaded ONNX Runtime twice: the first standalone make thirdparties succeeded, but make cgo correctly discarded that generation because it had no complete provenance stamp and the second raw GitHub download exhausted all four SSL-connect retries.

This revision now also:

  • publishes a dedicated small ONNX Runtime fallback cache, keyed by OS, architecture, and the exact thirdparty recipe/download implementation;
  • records one library plus a SHA-256 manifest and rejects an exact-but-incomplete/corrupt immutable cache in the trusted producer;
  • supplies that verified fallback to the single top-level make cgo owner when the full native cache misses;
  • removes the temporary fallback before the later source/license scan.

The companion matrixorigin/CI#444 consumer restores this small archive only when the full native cache is unusable. A missing or corrupt fallback remains an optimization miss and uses MatrixOne's existing checksum-verified download path. The consumer no longer invokes standalone make thirdparties, so a cold fallback performs one complete native generation and can download ONNX at most once.

Additional exact-head checks: actionlint 1.7.12 and git diff --check pass; a Make dry-run proves ONNX_PREBUILT_DIR reaches the platform-specific ONNX recipe; all eleven license-scope tests and both analysis-cache contract test suites in CI#444 pass.

@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner September 3, 2026 23:11
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Sep 3, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/warm-sca-analysis-cache branch from 44dcaff to 73e5594 Compare September 3, 2026 23:13
@XuPeng-SH
XuPeng-SH force-pushed the codex/warm-sca-analysis-cache branch from 73e5594 to 61b2a8f Compare September 3, 2026 23:57
@XuPeng-SH
XuPeng-SH force-pushed the codex/warm-sca-analysis-cache branch from 61b2a8f to 47cdb78 Compare September 4, 2026 00:14
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Sep 4, 2026

This branch was previously deployed

1 inactive deployment
ci — 8405d991 Deployed Sep 4, 2026 by XuPeng-SH via Matrixone Utils CI / Coverage #50582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants