[ci] fix determine_tests_to_run.py by finding merge base (#26790)

We previously found all differences between origin/master and the PR branch, which includes forward changes if origin/master is ahead of the branch. By finding file differences with respect to the merge base we will only include actually changed files.

See https://matthew-brett.github.io/pydagogue/git_diff_dots.html

Signed-off-by: Kai Fricke <kai@anyscale.com>
This commit is contained in:
Kai Fricke 2022-07-20 19:39:22 +01:00 committed by GitHub
parent c29a754526
commit 7cf4f8e069
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,9 +54,9 @@ def get_commit_range():
with open(os.environ["GITHUB_EVENT_PATH"], "rb") as f:
event = json.loads(f.read())
base = event["pull_request"]["base"]["sha"]
commit_range = "{}...{}".format(base, event.get("after", ""))
commit_range = "{}..{}".format(base, event.get("after", ""))
elif os.environ.get("BUILDKITE"):
commit_range = "origin/{}...{}".format(
commit_range = "origin/{}..{}".format(
os.environ["BUILDKITE_PULL_REQUEST_BASE_BRANCH"],
os.environ["BUILDKITE_COMMIT"],
)