CI: Upload regen patch artifact when the uncommitted-changes check fails - #25959
Conversation
When the Build and test workflow fails because regenerated files are not committed, save the regenerated changes as a regen-patch artifact (patch + PR number) instead of discarding them, and extend the CI commenter to post apply instructions on the PR. Anyone with push access to the PR branch (the author, or committers via Allow edits from maintainers) can then fix the PR in seconds without re-running the ~15 minute regen build locally. A later clean run marks the comment as resolved. Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLj5xMfVRiqGwEge1JKC81
gnodet
left a comment
There was a problem hiding this comment.
Well-designed CI enhancement. The approach is correct, follows existing patterns in the workflow, and introduces no new permissions or secrets.
Nice touches:
--binaryflag ongit diffhandles potential binary generated filesgit add -A+git diff --cachedcaptures newly-added untracked files that a plaingit diffwould missoverwrite: trueon the regen-patch upload is consistent with the existing ci-comment artifact pattern- Separate
<!-- regen-patch -->marker avoids collisions with the existing<!-- ci-tested-modules -->test summary marker - Idempotent comment logic: resolved comments aren't re-posted, new clean runs update warnings to resolved, errors handled gracefully with
core.warning() - All actions are SHA-pinned and match versions used elsewhere in the workflow
One minor gap (non-blocking): when a previously-failing regen check passes on a push where all tests also pass (no test comment produced), neither regen-patch nor ci-comment artifacts carry the PR number, so the old warning comment won't auto-resolve to the ✅ state. This is cosmetic — CI status badges show the real outcome, and the comment self-heals on the next push that produces test output. A low-priority follow-up could have the "Save PR number" step always upload a minimal artifact containing just the PR number.
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Milestone | (none) | 4.23.0 |
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Motivation
A lot of PRs fail on the
Fail if there are uncommitted changesstep of the Build and test workflow (generated files not regenerated/committed — e.g. #25939). At that point CI has already done the expensive work:regen.shsucceeded and the regenerated files are sitting in the runner's workspace — we currently just print the diff into the log and throw it away. Fixing such a PR today means checking it out and running a ~15 minute regen build locally.Changes
pr-build-main.yml— when the uncommitted-changes check fails, the regenerated changes are saved withgit diff --cached --binaryand uploaded as aregen-patchartifact together with the PR number (theci-commentartifact is not produced on this failure path, so the patch artifact must carry the PR number itself — same approach camel-quarkus uses for its dependabot branch synchronization).pr-test-commenter.yml— the existing commenter workflow (which already runs in the base-repo context withpull-requests: write) now also looks for aregen-patchartifact on the completed run and posts/updates a single marker-based comment on the PR with ready-to-use apply instructions:git apply --indexstages everything including newly added/deleted generated files (a plaingit commit -amwould miss untracked new files). When a later run is clean, the comment is updated to a resolved state instead of leaving a stale warning.Who can use it
Anyone with push access to the PR branch: the PR author, or any committer/PMC member when Allow edits from maintainers is enabled on the fork PR (it is by default for user-owned forks). This makes fixing a contributor's failing PR a ~30 second operation.
Security considerations
No new tokens, secrets, or permissions are introduced. The patch is uploaded by the unprivileged build job as plain data; nothing applies it automatically — a human applies and pushes it with their own credentials, and the resulting commit goes through normal review. A possible follow-up (separate discussion) would be a
/regencomment command that applies the patch from CI automatically, following the camel-quarkussynchronize-dependabot-branch.yamlpattern, but that requires a bot account PAT to push to forks — hence doing this cheap step first.Claude Code on behalf of Croway