[llvm] [ci] Diff against main when determining what files have changed for pre-commit CI (PR #67743)

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 14:39:41 PDT 2023


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

Since we moved to Github PRs, the workflow has changed a bit and folks often merge `main` back into their PR branch. This is fine, except the previous way of determining modified files for pre-commit CI would use the content modified just in the latest commit, whatever it is. This means that in case someone merged main back into their PR branch, we'd think that the files in the merge commit were modified by the PR, and we'd spuriously trigger a CI run. This should fix this issue.

The downside is that the merge target is hardcoded to `main`, which might not always be what we want. I still think this is an improvement over the status quo.

>From 6a6722d7436e3ca776c640b7c2b4e9850c73d655 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 28 Sep 2023 17:36:03 -0400
Subject: [PATCH] [ci] Diff against main when determining what files have
 changed for pre-commit CI

Since we moved to Github PRs, the workflow has changed a bit and folks
often merge `main` back into their PR branch. This is fine, except the
previous way of determining modified files for pre-commit CI would use
the content modified just in the latest commit, whatever it is. This
means that in case someone merged main back into their PR branch, we'd
think that the files in the merge commit were modified by the PR, and
we'd spuriously trigger a CI run. This should fix this issue.

The downside is that the merge target is hardcoded to `main`, which
might not always be what we want. I still think this is an improvement
over the status quo.
---
 .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 e389df431505bd1..f45a4d82150d509 100755
--- a/.ci/generate-buildkite-pipeline-premerge
+++ b/.ci/generate-buildkite-pipeline-premerge
@@ -22,7 +22,7 @@ set -o pipefail
 
 # Environment variables script works with:
 # List of files affected by this commit
-: ${MODIFIED_FILES:=$(git diff --name-only HEAD~1)}
+: ${MODIFIED_FILES:=$(git diff --name-only main...HEAD)}
 # Filter rules for generic windows tests
 : ${WINDOWS_AGENTS:='{"queue": "windows"}'}
 # Filter rules for generic linux tests



More information about the llvm-commits mailing list