ci: scope spotless to changed Java files via -DspotlessFiles - #31892
ci: scope spotless to changed Java files via -DspotlessFiles#31892chirag-madlani wants to merge 1 commit into
Conversation
Previously the Java Checkstyle job ran `mvn -B spotless:apply` across the whole reactor (~16k Java files, ~10-15 min wall-clock on a cold Maven cache) and then diffed the changed files to see if spotless had touched them. On slow runners this hit the 20-min job timeout, which produces conclusion=cancelled instead of conclusion=failure — so auto-revert-release.yml silently skips instead of reverting. spotless-maven-plugin 2.41.1 accepts `-DspotlessFiles=<comma-separated regex>` matched against absolute paths. Build one anchored `.*<path>` regex per changed file, with regex metacharacters escaped, and run `spotless:check` against just those. Fails fast on formatting drift, no in-place edits, no post-run git diff dance. Drops the step from minutes to seconds and eliminates the timeout-masks-failure hazard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ ApprovedScopes Maven Spotless checks to changed Java files via -DspotlessFiles and switches to spotless:check to eliminate timeout hazards and speed up CI validation. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
✅ Playwright Results — workflow succeededValidated commit ✅ 553 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 49m 43s ⏱️ Max setup 4m 55s · max shard execution 14m 55s · max shard-job elapsed before upload 19m 51s · reporting 5s 🌐 215.62 requests/attempt · 2.83 app boots/UI scenario · 4.02% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Describe your changes:
Stacked on #31891. Fixes the timeout-masks-failure hazard we hit while live-testing #31828:
mvn -B spotless:applyon the whole reactor was slow enough on a cold Maven cache to hit the 20-mintimeout-minutescap, which producesconclusion=cancelled(notfailure), which auto-revert-release.yml correctly does not treat as a revertable signal — so broken cherry-picks slip through silently when the runner is slow.Scope spotless itself to only the changed Java files via
-DspotlessFiles=<regex-list>(supported by spotless-maven-plugin 2.41.1). Drops the step from ~10-15 min to seconds and eliminates the failure mode.Base branch:
ci/shallow-fetch-validate(from #31891). Merge that first, then rebase this.Type of change:
High-level design:
Regex construction. For each changed relative path, escape regex metacharacters (
[]().^$+*?|\), prepend.*so the pattern survives Maven's absolute-path resolution, and join with commas. Passed as a single-DspotlessFiles=<list>argument.spotless:checkvsspotless:apply. Switched tocheck— fails fast on drift, no in-place edits, no post-rungit status --porcelaindance. Exit code is authoritative.Baseline drift is still ignored. The regex only matches files the push touched, so pre-existing formatting drift on other files in the release branch is untouched (matches the same scope-of-check principle #31828 established for lint and prettier).
Alternative considered. Bumping
timeout-minutesfrom 20 → 40. Rejected because it masks the underlying issue (spotless doing 100× the work needed) and doesn't fix cold-cache runs that could still exceed a higher cap.Tests:
Use cases covered
spotless:checkreports the violation, job fails withconclusion=failure, auto-revert fires.checkto fail.steps.files.outputs.anygate skips the step (unchanged).Manual testing performed
spotless:check -DspotlessFiles=<regex>is a valid invocation for spotless-maven-plugin 2.41.1 (project version pinned inpom.xml:162).9.9.9reproduces the live smoke — same delta as before but the Java job now finishes in seconds.Checklist:
Fixes <issue-number>: <short explanation>— perf/reliability follow-up to ci: auto-revert failing commits on release branches #31828, no separate issue.🤖 Generated with Claude Code
Greptile Summary
This PR limits release-branch Spotless validation to changed Java files, replacing full-tree formatting and post-format diff inspection with a direct scoped check.
spotless:applyfollowed bygit statusinspection intospotless:check.Confidence Score: 5/5
The PR appears safe to merge, with changed Java files still reaching Spotless validation while unrelated baseline drift remains excluded.
Spotless accepts the generated comma-separated regex list, matches each expression against absolute paths, and the workflow escapes repository-relative paths before invoking the non-mutating check goal.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Changed Java paths] --> B[Escape regex metacharacters] B --> C[Prefix each pattern with .*] C --> D[Join patterns with commas] D --> E[mvn spotless:check] E -->|Formatting clean| F[Validation succeeds] E -->|Formatting drift| G[Validation fails]Reviews (1): Last reviewed commit: "ci: scope spotless to changed Java files..." | Re-trigger Greptile