Skip to content

ci: add make static-check-changed for fast local SCA - #33012

Merged
fengttt merged 3 commits into
matrixorigin:mainfrom
fengttt:static-check-changed
Nov 20, 2026
Merged

fengttt merged 3 commits into
matrixorigin:mainfrom
fengttt:static-check-changed

Conversation

@fengttt

@fengttt fengttt commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29249

What this PR does / why we need it:

make static-check always lints all of ./.... From a cold cache that takes 20+ minutes (golangci-lint alone took about 21 minutes on CI). PR CI already narrows the lint to the affected packages with .github/ci/static-analysis.cjs, but that selector only runs inside GitHub Actions. This PR adds a local way to use it.

make static-check-changed finds the files changed since the merge base with STATIC_CHECK_BASE. It counts commits, staged, unstaged and untracked files. The base defaults to upstream/main, or origin/main if there is no upstream remote. It then picks packages with the same selectPackages logic CI uses, and runs molint and golangci-lint through static-check-selected.

It falls back to the full graph in the same cases CI does: build or analyzer config changes, or affected packages reaching half the graph. It also falls back when the base can't be found. It is a local fast path, not a gate; make static-check and the CI selection are unchanged.

Selection examples (502 packages in total):

Change Packages checked
a file in pkg/sql/colexec/group 37
a file in pkg/frontend 32
a file in pkg/container/vector full scan (329 packages depend on it)

Changes:

  • static-analysis.cjs: new localChanges(), used when SCA_LOCAL_BASE is set. Untracked files the local diff reports as added also pass the tracked-source check. Git-ignored Go inputs still force a full scan.
  • Makefile: static-check-changed target and the STATIC_CHECK_BASE default.
  • static-analysis.test.cjs: a unit test for localChanges(). The existing real-Make fixture now also covers a narrowed selection, an untracked file, a missing base, and analyzer failure propagation.
  • .github/ci/README.md: documents the target.

Testing:

  • node --test .github/ci/*.test.cjs: 52 of 52 pass.
  • make static-check-changed on this branch exits 0. It runs a full scan because the change touches .github/ci/.

🤖 Generated with Claude Code

Run molint and golangci-lint only on the packages affected by the working
tree's changes since the merge base with STATIC_CHECK_BASE (default
upstream/main, else origin/main). Selection reuses the PR CI selector;
untracked inputs count as changes, and a missing base, config/build edits
or a closure reaching half the graph fall back to the full graph.
make static-check remains the full gate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fengttt
fengttt requested a review from XuPeng-SH as a code owner November 20, 2026 18:16
@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 →

@mergify mergify Bot added the kind/test-ci label Nov 20, 2026
@mergify

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

This branch was successfully deployed

No deployments
ci — 051dab6d Deployed Nov 20, 2026 by fengttt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants