Skip to content

Run PR tests only for changes made on the PR branch - #13343

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
pablo/sdct-1444-pr-test-selection
Nov 20, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
pablo/sdct-1444-pr-test-selection

Conversation

@PabloRzBo

@PabloRzBo PabloRzBo commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

A secondary improvement: it reduces CI cost, not pipeline duration.

  • Main effect: PR pipelines now skip the Gradle projects a PR does not change, even after master has moved since the branch point.
  • Minor effect: changes under .github/, .claude/ and .agents/ no longer make a PR run every test.

Motivation

Change tracking diffed origin/master..HEAD, which compares the two trees. Every file changed on master after the branch point counted as a PR change, and master touches buildSrc/, .gitlab*, gradle/ or root files almost daily. So test selection was effectively off: in 357 recent PR pipelines, 31% ran the full suite only because of master changes, and only 23% got any selection. Diffing from the merge base (origin/master...HEAD) counts only the PR's own changes.

Additional Notes

Measured effect

Measured on real CI jobs from 2026-11-07 to 2026-11-12 (after the S3 build cache, #12604): 357 PR pipelines, classified by replaying the selection logic with the git state each one saw (12/12 agreement with sampled job logs).

PR pipelines Count Share
Selection already works 83 23%
Full suite because of the PR's own changes (unchanged by this PR) 163 46%
Full suite only because master moved (fixed by this PR) 110 31%

PR pipelines running the full suite: 76.7% → 45.8%.

The two parts of the change contribute very differently:

Part Affects Effect
Merge-base diff (...) 31% of PR pipelines (110 of 357), any PR whose branch is behind master Nearly all of the job-hours below
Ignoring .github/, .claude/, .agents/ ~5% of merged PRs (40 of 740 from 2026-08-12 to 2026-11-12 changed a non-Markdown file there; Markdown was already ignored) Minor

For those 110 pipelines, the saving is the time of each test job that would become empty, minus the median duration of 2,703 real empty jobs (for example 7.4 min for test_inst). Smoke, build and check jobs are not counted, and 56 of the 110 save nothing because they touch core modules that keep every shard selected.

Period Job-hours saved Range Share of all GitLab job-hours Share of PR job-hours
5-day window (measured) 236 195–288 0.64% 1.76%
Per week ~330 270–400 0.64% 1.76%
Per month ~1,440 1,190–1,750 0.64% 1.76%
Per year ~17,000 14,000–21,000 0.64% 1.76%

Week, month and year are linear extrapolations of the window. The range comes from the 25th–75th percentile of empty-job durations. 54% of the saving comes from jobs that really executed tests (cache misses, non-cacheable tasks) and 46% from jobs that mostly restored cached results. Pipeline duration is unchanged: smoke tests stay on the critical path.

Tests

Check Result
Local Gradle dry runs, branch from an older master Without the fix: Global effect change: .gitlab/check_test_agent_results.sh (no tasks will be skipped), 104 test tasks. With the fix: only the changed module selected, 44 of 46 test aggregates skipped
DDCI control: one-line rxjava-3.0 change without the fix, after master changed settings.gradle.kts and build-logic/ (#13294) Changed file: build-logic/smoke-test/README.md at root project (no task will be skipped): all tests ran
DDCI treatment: the same change with the fix origin/master...HEAD, only RxJavaModule.java counted, 40 Skipping lines; only the rxjava shards and smoke tests did work
DDCI negative control: a deliberately failing rxjava-3.0 test Exactly the 11 rxjava jobs failed, nothing else: failures in selected modules are still caught
DDCI run of this branch Full suite passes (it changes buildSrc/, so nothing is skipped)

No unit test covers this plugin; the checks above exercise it end to end.

Advantages

  • Test selection behaves as documented: a PR runs the tests of what it changes.
  • Fewer jobs doing work on most PRs, so less runner time and less exposure to flaky tests and timeouts in unrelated modules.
  • Two-line change, no new configuration, merge queue and master unchanged.

Drawbacks

  • Smaller gain than before the S3 build cache (Introduce a Gradle S3 build cache #12604): a fallback now restores most unaffected tests from the cache, so the saving is about 0.6% of CI time rather than a speed-up. No effect on pipeline duration.
  • 46% of PR pipelines still run the full suite because their own diff touches build-logic/, .gitlab/, metadata/, .gitlab-ci.yml, gradle/ or buildSrc/; this PR does not change those rules.
  • A PR no longer tests its changes combined with newer master changes. The merge queue still runs the full suite on the merged result, so incompatibilities are caught there rather than on the PR.
  • The three-dot diff needs the merge base. CI already computes it in .gitlab/find-gh-base-ref.sh; in a local shallow clone without it, the existing require fails the build loudly instead of silently skipping tests.

Jira ticket: SDCT-1444

🤖 Generated with Claude Code

Git change tracking diffed `<base>..HEAD`, which compares the two trees.
Every file changed on master since the branch point counted as a PR
change, so most PR pipelines hit a "run everything" path changed on
master and ran the full suite. Diff from the merge base instead
(`<base>...HEAD`), and ignore GitHub and agent config directories,
which do not affect Gradle tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PabloRzBo PabloRzBo added type: bug fix Bug fix tag: no release notes Changes to exclude from release notes comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM labels Nov 10, 2026
@PabloRzBo
PabloRzBo marked this pull request as ready for review November 12, 2026 13:04
@PabloRzBo
PabloRzBo requested review from a team as code owners November 12, 2026 13:04
@PabloRzBo
PabloRzBo requested review from amarziali and mhlidd and removed request for a team November 12, 2026 13:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T13:07:00.157003Z d267671 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-prod-us1-4 datadog-prod-us1-4 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The merge-base comparison correctly excludes newer master-only changes from PR test selection. Source and CI configuration inspection identified no actionable regression in that change or the configuration-directory exclusions.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit d267671

Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com>
@bric3

bric3 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

suggestion: The description hints at bold improvements, but the reality is it touches less that 10% of the PRs. I.e. clearly state it's a secondary improvement.

I looked over this period from 12 August and 12 November 2026, 67 of 741 merged PRs (9.0%) touched .github/, .claude/, or .agents/. Of those 67, 26 changed only Markdown files within those directories, which the existing rules already ignored. The remaining 41 (5.5% of all merged PRs) changed at least one non-Markdown file there and could benefit from the new exclusions.

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 60.91% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c28ed25 | Docs | Give us feedback!

@PabloRzBo

Copy link
Copy Markdown
Contributor Author

suggestion: The description hints at bold improvements, but the reality is it touches less that 10% of the PRs. I.e. clearly state it's a secondary improvement.

I looked over this period from 12 August and 12 November 2026, 67 of 741 merged PRs (9.0%) touched .github/, .claude/, or .agents/. Of those 67, 26 changed only Markdown files within those directories, which the existing rules already ignored. The remaining 41 (5.5% of all merged PRs) changed at least one non-Markdown file there and could benefit from the new exclusions.

Your count is right for the new exclusions but most of the effect of this change comes from the merge-base diff, though, which applies to any PR whose branch is behind master: in 357 PR pipelines from Nov 7–12, 31% ran the full suite only because master had moved. I've split the two in the description in order to make this difference clearer.

@dd-octo-sts

dd-octo-sts Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.95 s 13.97 s [-0.7%; +0.4%] (no difference)
startup:insecure-bank:tracing:Agent 12.89 s 12.98 s [-1.4%; +0.0%] (no difference)
startup:petclinic:appsec:Agent 16.75 s 17.16 s [-6.7%; +2.0%] (no difference)
startup:petclinic:iast:Agent 17.06 s 17.20 s [-1.7%; +0.1%] (no difference)
startup:petclinic:profiling:Agent 16.86 s 16.82 s [-0.8%; +1.3%] (no difference)
startup:petclinic:sca:Agent 17.24 s 17.10 s [-0.0%; +1.7%] (no difference)
startup:petclinic:tracing:Agent 16.21 s 16.60 s [-3.2%; -1.4%] (significantly better)

Commit: c28ed251 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

Comment thread docs/how_to_work_with_gradle.md Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for follow up the clean up

@PabloRzBo PabloRzBo changed the title Run PR tests only for changes made on the PR branch [SDCT-1444] Run PR tests only for changes made on the PR branch Nov 12, 2026
@dd-octo-sts

dd-octo-sts Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Remove the tag from the pull request title

If you need help, please check our contributing guidelines.

@PabloRzBo PabloRzBo changed the title [SDCT-1444] Run PR tests only for changes made on the PR branch Run PR tests only for changes made on the PR branch Nov 12, 2026

@bric3 bric3 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.

Small clarification to the description of the directory exclusions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 0600186 into master Nov 20, 2026
688 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the pablo/sdct-1444-pr-test-selection branch November 20, 2026 18:55
@github-actions github-actions Bot added this to the 1.70.0 milestone Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants