[llvm-branch-commits] [llvm] [🍒][ci] Fix the base branch we use to determine changes (#79503) (PR #79506)

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 25 13:50:41 PST 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/79506

>From fce5c171b463d766cb25208634553a39b94498a6 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 25 Jan 2024 16:38:53 -0500
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9F=8D=92][ci]=20Fix=20the=20base=20bra?=
 =?UTF-8?q?nch=20we=20use=20to=20determine=20changes=20(#79503)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We should diff against the base branch, not always against `main`. This
allows the BuildKite pre-commit CI to work properly when we target other
branches, such as `release/18.x`.

(cherry picked from commit 3b762891826192ded07286852d326f9c9060f52e)
---
 .ci/generate-buildkite-pipeline-premerge | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/.ci/generate-buildkite-pipeline-premerge b/.ci/generate-buildkite-pipeline-premerge
index f32eb7213b94027..009cb6933e8fa9d 100755
--- a/.ci/generate-buildkite-pipeline-premerge
+++ b/.ci/generate-buildkite-pipeline-premerge
@@ -22,19 +22,20 @@ set -o pipefail
 
 # Environment variables script works with:
 
-# Fetch origin/main to have an up to date merge base for main...HEAD diff.
-git fetch origin main:main
+# Set by buildkite
+: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH:=}
+: ${BUILDKITE_COMMIT:=}
+: ${BUILDKITE_BRANCH:=}
+# Fetch origin to have an up to date merge base for the diff.
+git fetch origin
 # List of files affected by this commit
-: ${MODIFIED_FILES:=$(git diff --name-only main...HEAD)}
+: ${MODIFIED_FILES:=$(git diff --name-only ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
 # Filter rules for generic windows tests
 : ${WINDOWS_AGENTS:='{"queue": "windows"}'}
 # Filter rules for generic linux tests
 : ${LINUX_AGENTS:='{"queue": "linux"}'}
 # Service agents, for interacting with Phabricator.
 : ${SERVICE_AGENTS:='{"queue": "service"}'}
-# Set by buildkite
-: ${BUILDKITE_COMMIT:=}
-: ${BUILDKITE_BRANCH:=}
 
 reviewID="$(git log --format=%B -n 1 | sed -nE 's/^Review-ID:[[:space:]]*(.+)$/\1/p')"
 if [[ "${reviewID}" != "" ]]; then

>From 02074f95e0aa098668071cd696f9e41d8f118550 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 25 Jan 2024 16:48:07 -0500
Subject: [PATCH 2/2] =?UTF-8?q?[=F0=9F=8D=92][ci]=20Diff=20against=20origi?=
 =?UTF-8?q?n/BASE-BRANCH?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Otherwise, when the base branch is not something that the CI runner
has checked out, that reference to e.g. release/18.x is ambiguous.

(cherry picked from commit 5aad7894812a53b69e989a61a567f5617df4a057)
---
 .ci/generate-buildkite-pipeline-premerge | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.ci/generate-buildkite-pipeline-premerge b/.ci/generate-buildkite-pipeline-premerge
index 009cb6933e8fa9d..7b1b4b8dac8a209 100755
--- a/.ci/generate-buildkite-pipeline-premerge
+++ b/.ci/generate-buildkite-pipeline-premerge
@@ -29,7 +29,7 @@ set -o pipefail
 # Fetch origin to have an up to date merge base for the diff.
 git fetch origin
 # List of files affected by this commit
-: ${MODIFIED_FILES:=$(git diff --name-only ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
+: ${MODIFIED_FILES:=$(git diff --name-only origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}...HEAD)}
 # Filter rules for generic windows tests
 : ${WINDOWS_AGENTS:='{"queue": "windows"}'}
 # Filter rules for generic linux tests



More information about the llvm-branch-commits mailing list