Skip to content

CAMEL-26775: ci - a PR whose diff the GitHub API refuses is tested from the local diff - #29469

Merged
davsclaus merged 2 commits into
apache:mainfrom
jamesnetherton:CAMEL-26775-ci-pr-diff-too-large
Nov 9, 2026
Merged

davsclaus merged 2 commits into
apache:mainfrom
jamesnetherton:CAMEL-26775-ci-pr-diff-too-large

Conversation

@jamesnetherton

@jamesnetherton jamesnetherton commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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 main after a depth-1 checkout, and /component-test builds. 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 base branch fetch steps of pr-build-main.yml reuse its fetchBaseBranch instead of their own copy of the deepen loop. The CI scripts validation workflow runs the shell tests.

🤖 Generated with Claude Code

…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>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🌟 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.

@github-actions github-actions Bot added the docs label Nov 9, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good. The fallback chain (GitHub API → local git diff → fail) is well-implemented and handles all relevant failure modes:

  • curl … || true in fetchApiDiff correctly swallows network errors, leaving http_code empty, which then fails the regex gate (^2[0-9][0-9]$) and falls through to localDiff — the silent-failure gap is closed.
  • localDiff uses git merge-base + git diff which works correctly for the detached-HEAD merge commits that GHA creates on pull_request events.
  • The regex change (=~ ^2[0-9][0-9]$) in place of arithmetic comparison prevents a bash error when http_code is empty.
  • Test coverage in pr_diff_test.sh is 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 davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml is 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>
@jamesnetherton

Copy link
Copy Markdown
Contributor Author

@davsclaus thanks for the review, good catch on camel-spring-boot. Addressed in 8c551bf:

  • localDiff now fetches origin/<base> itself when the merge base is not in the checkout, with the same deepen loop (now fetchBaseBranch in pr_diff.sh). CSB works from its depth-1 checkout without a companion PR. The two fetch steps in pr-build-main.yml reuse the function instead of their own copy of the loop, and the step comment mentions the diff fallback.
  • /component-test is covered by the same change: with the fetch step skipped, localDiff fetches on its own, so I kept failing on an empty diff rather than continuing with the extra modules only.
  • pr_diff_test.sh has a component-removal case, and a depth-1 clone without origin/main (the CSB setup) that checks the fallback fetches and deepens to the right merge base.

Claude Code on behalf of @jamesnetherton

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 8c551bf. Thanks James, all three points are in:

  • localDiff now fetches origin/<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.yml now source pr_diff.sh and reuse the function instead of two copies of the deepen loop. pr_diff.sh only defines functions, so sourcing it there is safe, and the step comment mentions the diff fallback.
  • pr_diff_test.sh covers a component removal and a depth-1 clone without origin/main.

LGTM.

Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies; please verify before applying.

@davsclaus davsclaus added this to the 4.24.0 milestone Nov 9, 2026
@davsclaus davsclaus added the task label Nov 9, 2026
@davsclaus
davsclaus merged commit b40d8b6 into apache:main Nov 9, 2026
5 checks passed
@jamesnetherton
jamesnetherton deleted the CAMEL-26775-ci-pr-diff-too-large branch November 9, 2026 14:04
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.

3 participants