[CI] detect package changes on first push of long-running branches#19045
Merged
Conversation
On the first push of a new backport or feature branch with no previous successful build, get_from_changeset() was unconditionally setting from=BUILDKITE_COMMIT, making from==to and producing an empty diff. This caused package tests to be silently skipped even when the pushed commit contained package changes (e.g. when the backport script had nothing to commit for CI infra and pushed the branch directly at BASE_COMMIT). Fix by computing the merge-base with origin/main and checking whether the commits exclusive to the branch touch packages/. If they do, use the merge-base as the changeset start; otherwise keep the empty-diff behaviour for CI infra-only first commits. Co-authored-by: Claude <noreply@anthropic.com>
Replace nested if/else accumulation pattern with early returns per branch case. Also removes the dead get_previous_commit call that was unreachable for main and long-running branches. Co-authored-by: Claude <noreply@anthropic.com>
…nches Add a "First push" sub-section under the branch context description to explain the merge-base approach used when no previous successful build exists for backport-* and feature/* branches. Also update the feature branches section to describe the content-aware check (package changes are tested; CI infra-only pushes skip package testing). Co-authored-by: Claude <noreply@anthropic.com>
mrodm
commented
May 18, 2026
Comment on lines
+662
to
+664
| merge_base=$(git merge-base "${BUILDKITE_COMMIT}" "origin/main") | ||
| if git diff --name-only "${merge_base}" "${BUILDKITE_COMMIT}" | grep -E '^packages/' > /dev/null; then | ||
| echo "${merge_base}" |
Collaborator
Author
There was a problem hiding this comment.
This will help to test packages in feature branches in the first commit if there is any.
Contributor
✅ Vale Linting ResultsNo issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
Contributor
🔍 Preview links for changed docs |
🚀 Benchmarks reportTo see the full report comment with |
teresaromero
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the first push of a new
backport-*orfeature/*branch with no priorsuccessful build,
get_from_changeset()was unconditionally returning an emptydiff range, causing package tests to be silently skipped even when the pushed
commit contained real
packages/changes. Fixed by computing the merge-basewith
origin/mainand checking whether commits exclusive to the branch touchpackages/before deciding whether to run package tests.Proposed commit message
WHAT
get_from_changeset()in.buildkite/scripts/common.shpreviously setfrom="${BUILDKITE_COMMIT}"for allbackport-*andfeature/*brancheswhen no previous successful build existed (first push). Since
get_to_changeset()also resolves toBUILDKITE_COMMITfor these branches,this produced an empty diff range and caused package tests to be silently
skipped — even when the pushed commit contained real package changes.
This happened in a specific scenario: when the backport pipeline created the
branch at
BASE_COMMITbut had no CI infrastructure changes to commit, thebranch was pushed pointing directly at
BASE_COMMIT(the package versionbump), which does contain
packages/changes.The fix computes
git merge-base "${BUILDKITE_COMMIT}" "origin/main"to findthe divergence point from
main, then checks whether commits exclusive to thebranch contain
packages/changes:from, so the affected packages are tested.from="${BUILDKITE_COMMIT}", producing an empty diff and skipping package testing as intended.The function is also refactored to use early returns, eliminating three levels
of nested
if/elseand removing a deadget_previous_commitcall that wasunreachable for
mainand long-running branches.docs/ci_pipelines.mdis updated to document the first-push behaviour forbackport-*,feature/*, andmainbranches.WHY
On the first push of a new
backport-*branch, package regressions couldmerge without package validation because CI annotated "No packages to be
tested" and skipped integration tests entirely. The same gap existed for
feature/*branches.Author's Checklist
grep -qreplaced withgrep -E ... > /dev/nullconsistent with the SIGPIPE warning documented throughoutcommon.sh.Related issues