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

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 13:19:36 PST 2024


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/79503

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

>From edf87f4c9cb5c8657c5fc4062378f2a6786419f4 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 25 Jan 2024 16:18:09 -0500
Subject: [PATCH] [ci] Fix the base branch we use to determine changes

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`.
---
 .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 34d914696018d61..3d5e86f25feb18c 100755
--- a/.ci/generate-buildkite-pipeline-premerge
+++ b/.ci/generate-buildkite-pipeline-premerge
@@ -22,17 +22,18 @@ 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"}'}
-# 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



More information about the llvm-commits mailing list