James Netherton created CAMEL-26775:
---------------------------------------

             Summary:  Incremental CI build silently skips all tests when the 
PR diff has more than 300 files
                 Key: CAMEL-26775
                 URL: https://issues.apache.org/jira/browse/CAMEL-26775
             Project: Camel
          Issue Type: Bug
          Components: build system
            Reporter: James Netherton


h3. Problem

The "mvn test" step of {{pr-build-main.yml}} runs 
{{{}.github/actions/incremental-build/incremental-build.sh{}}}. To choose the 
modules to test, the script fetches the PR diff from the GitHub REST API 
({{{}fetchDiff{}}}: {{{}GET /repos/\{repo}/pulls/{id{}}}} with {{{}Accept: 
application/vnd.github.v3.diff{}}}).

GitHub refuses that format when the PR exceeds its [diff 
limits|https://docs.github.com/en/repositories/creating-and-managing-repositories/repository-limits]
 (at most 300 files; a pull request diff is also limited to 20,000 lines and 1 
MB of raw diff data) and answers HTTP 406. For apache/camel#29461 (563 files) 
the response was:

{code:json}
{
  "message": "Sorry, the diff exceeded the maximum number of files (300). 
Consider using 'List pull requests files' API or locally cloning the repository 
instead.",
  "errors": [ { "resource": "PullRequest", "field": "diff", "code": "too_large" 
} ],
  "status": "406"
}
{code}
{{fetchDiff}} then logs {{WARNING: Failed to fetch PR diff (HTTP 406). Falling 
back to full build.}} and returns an empty diff. Despite that message, nothing 
falls back to a full build: the caller logs {{Could not fetch diff, skipping 
tests}} and exits 0. The step passes in under a second without running any 
test, and the PR shows green checks.

Seen on [apache/camel#29461|https://github.com/apache/camel/pull/29461] (563 
files): [CI job 
log|https://github.com/apache/camel/actions/runs/42601440530/job/129106621287]

The PRs most affected are the largest ones, such as dependency migrations or 
cross-cutting refactorings, which are the ones that most need test coverage.
h3. Proposed fix
 * When the API does not return the diff, compute it locally. The job already 
checks out the PR and fetches the base branch for Scalpel, so {{git diff $(git 
merge-base origin/<base> HEAD) HEAD}} works. Push builds already use a local 
{{{}git diff{}}}.
 * If no diff can be obtained at all, fail the step, or really run a full 
build, instead of exiting 0.
 * Correct the warning message so it says what the script actually does.

_Claude Code on behalf of jamesnetherton_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to