Repository navigation
CAMEL-26775: ci - a PR whose diff the GitHub API refuses is tested from the local diff - #29469
Conversation
…om the local diff The GitHub API refuses the diff of a PR beyond its diff limits (HTTP 406, for example more than 300 files). The incremental build then logged "Falling back to full build" but exited 0 without running any test, so the largest PRs got green checks untested. The diff is now computed from the local checkout against its merge base with the base branch, which the workflow already fetches for Scalpel. When neither the API nor the local history gives the diff, the step fails. The diff helpers move to pr_diff.sh with a test, and the CI scripts validation workflow runs the shell tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet-bot
left a comment
There was a problem hiding this comment.
The PR looks good. The fallback chain (GitHub API → local git diff → fail) is well-implemented and handles all relevant failure modes:
curl … || trueinfetchApiDiffcorrectly swallows network errors, leavinghttp_codeempty, which then fails the regex gate (^2[0-9][0-9]$) and falls through tolocalDiff— the silent-failure gap is closed.localDiffusesgit merge-base + git diffwhich works correctly for the detached-HEAD merge commits that GHA creates onpull_requestevents.- The regex change (
=~ ^2[0-9][0-9]$) in place of arithmetic comparison prevents a bash error whenhttp_codeis empty. - Test coverage in
pr_diff_test.shis comprehensive: HTTP 200, HTTP 406, curl exit-6, missing base branch, and the detached-HEAD scenario. - Push builds (no
prId) are unaffected.
One low-severity defensive improvement in the GHA step below.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
davsclaus
left a comment
There was a problem hiding this comment.
James, thanks for this. A green check on a PR that ran no tests at all is the worst kind of CI result, and this closes that hole for the biggest PRs, which need testing the most. Moving the diff helpers into pr_diff.sh with a test is a nice touch. The test covers the base branch moving on, the merge-commit checkout, a 406 with the API message, and curl failing. It is also good that the validation workflow now runs every *_test.sh, so reactor_timing_test.sh finally runs in CI too.
I checked the fallback against the workflow. git merge-base HEAD origin/<base> on the test merge commit gives its first parent, so the local diff has the same file list as the API diff, and deleted and renamed files resolve the same way in the module detection. The deepen loop in the Scalpel fetch step makes sure the merge base is reachable. The functions run inside command substitution, so a failing curl or git cannot trip set -e, and the new empty-diff exit 1 only applies to PR builds; push builds from main-build.yml keep their skip. No new expression interpolation in run: scripts and no token changes.
One thing to consider before merge: camel-spring-boot runs this action from @main (.github/workflows/pr-build-main.yml:103) after a default depth-1 actions/checkout with no base-branch fetch, so origin/main never exists there and localDiff always comes back empty. After this change, every CSB PR the API refuses (large regen PRs), and every transient API error, fails the step with no way out other than the skip-tests label. Could localDiff fetch origin/<base> itself when the ref is missing (the same deepen loop as the Scalpel step), or would you rather add the fetch to the CSB workflow in a companion PR?
Two smaller suggestions:
- The fetch step in
pr-build-main.ymlis skipped for/component-test(skip_full_build), so a component test on a large PR now fails without running the requested modules. Running the fetch there too, or continuing with an empty diff when extra modules were requested, would fix that. That step's comment ("Scalpel is observational, fetch failures must not break the build") could also mention that the diff fallback now relies on it. - A deletion case in
pr_diff_test.sh(git rm -r components/a) would cover the component-removal PRs that motivated this change.
Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies; please verify before applying.
…he checkout lacks it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@davsclaus thanks for the review, good catch on camel-spring-boot. Addressed in 8c551bf:
Claude Code on behalf of @jamesnetherton |
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — the previous nullglob finding remains unaddressed; no new issues found in 8c551bf.
The fallback chain (API → local git diff → fail) is correct. The new localDiff auto-fetches the base branch when the merge base is unreachable, which correctly covers the camel-spring-boot depth-1 checkout case. Test coverage is solid.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
davsclaus
left a comment
There was a problem hiding this comment.
Re-reviewed 8c551bf. Thanks James, all three points are in:
localDiffnow fetchesorigin/<base>itself (fetchBaseBranch) when the merge base is not in the checkout, so camel-spring-boot's depth-1 checkout works without a companion PR, and so does/component-test, which skips the fetch step.- Both fetch steps in
pr-build-main.ymlnow sourcepr_diff.shand reuse the function instead of two copies of the deepen loop.pr_diff.shonly defines functions, so sourcing it there is safe, and the step comment mentions the diff fallback. pr_diff_test.shcovers a component removal and a depth-1 clone withoutorigin/main.
LGTM.
Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies; please verify before applying.
The GitHub API refuses the diff of a PR beyond its diff limits (HTTP 406, for example more than 300 files). The incremental build then logged "Falling back to full build" but exited 0 without running any test, so the largest PRs got green checks untested.
The diff is now computed from the local checkout against its merge base with the base branch. When the checkout does not have the merge base, it fetches the base branch and deepens the shallow clone (50, 200, 1000 commits, then the full history), so the fallback also works for callers that skip the workflow's fetch step: camel-spring-boot, which runs this action from
mainafter a depth-1 checkout, and/component-testbuilds. When neither the API nor the local history gives the diff, the step fails.The diff helpers move to
pr_diff.shwith a test, and the base branch fetch steps ofpr-build-main.ymlreuse itsfetchBaseBranchinstead of their own copy of the deepen loop. The CI scripts validation workflow runs the shell tests.🤖 Generated with Claude Code