Skip to content

Conditionally enable OpenRewrite FQCN shortening in CI#23060

Open
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:elderly-mackerel
Open

Conditionally enable OpenRewrite FQCN shortening in CI#23060
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:elderly-mackerel

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 7, 2026

Follow-up to #23041 which disabled OpenRewrite entirely because it quadrupled CI build times.

This re-enables OpenRewrite conditionally: regen.sh now greps the diff for fully qualified class name patterns and only adds -Prewrite when FQCNs are detected. Most builds (dependency bumps, doc changes, code without FQCNs) skip it entirely.

How it works

Before the build, the script:

  1. Ensures the parent commit is available (git fetch --deepen=1 for shallow clones)
  2. Diffs HEAD~1 HEAD on .java files (excluding generated, imports, packages, comments)
  3. If any FQCN pattern is found (e.g. java.util.List, org.apache.camel.Exchange), appends -Prewrite to MAVEN_EXTRA_ARGS
  4. The existing mvn install picks it up — no separate build pass needed

For PR builds, actions/checkout creates a merge commit where HEAD~1 is the base branch tip, so the diff covers all PR changes. For main builds, HEAD~1 is the previous (squash-merged) commit.

Test plan

  • Tested regex locally: correctly detects FQCNs in commits that have them
  • Correctly skips commits without FQCNs (dep bumps, FQCN removals)
  • Import/package/comment lines are filtered out (no false triggers)
  • Handles shallow clones (--deepen=1 to get parent commit)
  • All fetch failures are gracefully handled (falls back to skipping OpenRewrite)
  • Verify CI passes with this change

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet marked this pull request as draft May 7, 2026 14:14
@gnodet gnodet force-pushed the elderly-mackerel branch from 624ac55 to 6d55874 Compare May 7, 2026 14:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🧪 CI tested the following changed modules:

  • etc

⚙️ View full build and test results

@gnodet gnodet force-pushed the elderly-mackerel branch from 6d55874 to ed93c75 Compare May 7, 2026 15:01
Instead of always running OpenRewrite (which quadruples build time),
detect FQCNs in the diff and only enable -Prewrite when needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented May 7, 2026

Claude Code on behalf of Guillaume Nodet

Benchmark results

Tested with two companion PRs to measure the impact:

PR OpenRewrite Build time (JDK 21)
#23068 (no FQCNs) skipped ~22 min
#23069 (with FQCNs) triggered ~30 min

~8 minutes saved (~36% faster) on builds that don't introduce FQCNs, which is the common case (dependency bumps, doc changes, clean code).

When FQCNs are detected, OpenRewrite runs as before — no regression in correctness.

@gnodet gnodet marked this pull request as ready for review May 7, 2026 21:02
@gnodet gnodet requested review from apupier and oscerd May 7, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant