Skip to content

ci: scope SpotBugs to a PR's changed modules (per-module skip) - #1484

Draft
joaodinissf wants to merge 1 commit into
ci/static-analysis-sariffrom
ci/spotbugs-skip
Draft

ci: scope SpotBugs to a PR's changed modules (per-module skip)#1484
joaodinissf wants to merge 1 commit into
ci/static-analysis-sariffrom
ci/spotbugs-skip

Conversation

@joaodinissf

@joaodinissf joaodinissf commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #1400 (recreated from an in-repo branch to form a native stacked-PR chain).

Note

Stacked on #1396#1399. Against master the diff includes those commits (they drop out as they merge) — review only the SpotBugs-scoping commit (compute-spotbugs-skip.sh + the spotbugs-job edits in verify.yml).

Problem

SpotBugs is the spotbugs job's long pole (per-module bytecode analysis + a JVM fork per module). A PR only needs its changed modules scanned.

What this does

A pre-step injects <spotbugs.skip>true> into every unchanged reactor module's pom, so the plugin skips the goal — and the per-module fork — for them. The full-reactor compile is kept (a changed module keeps its complete aux-classpath). pull_request only; master/snapshot run a full scan. A build/config change → full scan (fail-safe).

  • .github/scripts/compute-spotbugs-skip.sh — diff → changed modules → inject skip into the unchanged ones (idempotent; never touches ddk-parent).
  • verify.yml spotbugs job — fetch-depth: 0 + the scope step; -Djgit.dirtyWorkingTree=ignore (the scope step intentionally dirties poms and this job releases nothing — releases/maven-verify keep =error); SARIF upload guarded against an empty scan set.

Validated

Controlled fork probe (cold cache): a one-module Java change → scanning 1 / skipping 62; spotbugs job 2m45s vs 8m33s–9m13s full scans, BUILD SUCCESS, 0 violations, SARIF uploaded; all other jobs green.

Why not -Dspotbugs.onlyAnalyze

Cleaner-looking (one flag) but SpotBugs screens too late (after the per-module fork) — ~17% vs ~88% measured. If an upstream SpotBugs early-exit lands, switch to onlyAnalyze and drop this script (noted in the script header).

Merge chain: #1399 (merged) → #1396#1400 (this PR)#1456#1457#1397

🤖 Generated with Claude Code

SpotBugs' per-module analysis is the spotbugs job's long pole. A PR only needs
its changed modules scanned, so a pre-step injects <spotbugs.skip>true> into
every unchanged reactor module's pom — the plugin then skips the goal, and the
per-module JVM fork, for them. The full-reactor compile is kept (a changed
module keeps its complete aux-classpath); a build/config change falls back to a
full scan. pull_request only — master/snapshot run a full scan.

-Dspotbugs.onlyAnalyze was the cleaner-looking alternative but screens too late
(after the per-module fork), ~17% vs ~88% measured; the script header documents
the migration if an upstream SpotBugs early-exit ever lands.

- .github/scripts/compute-spotbugs-skip.sh: diff -> changed modules -> inject
  skip into the unchanged ones (idempotent; build/config change -> full scan).
- verify.yml spotbugs job: fetch-depth 0 + a scope step before compile;
  -Djgit.dirtyWorkingTree=ignore because the scope step dirties poms on purpose
  and this job releases nothing (releases/maven-verify keep =error); SARIF upload
  guarded so an empty scan set (no module scanned) doesn't fail the upload.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joaodinissf joaodinissf changed the title ci: scope SpotBugs to the PR's changed modules (per-module skip) ci: scope SpotBugs to a PR's changed modules (per-module skip) Aug 3, 2026
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