Skip to content

fix: use the right base branch to detect changed files #4441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .buildkite/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import argparse
import json
import os
import subprocess
from pathlib import Path

Expand Down Expand Up @@ -88,11 +89,13 @@ def pipeline_to_json(pipeline):
return json.dumps(pipeline, indent=4, sort_keys=True, ensure_ascii=False)


def get_changed_files(branch):
def get_changed_files():
"""
Get all files changed since `branch`
"""
stdout = subprocess.check_output(["git", "diff", "--name-only", branch])
branch = os.environ.get("BUILDKITE_PULL_REQUEST_BASE_BRANCH", "main")
stdout = subprocess.check_output(f"git diff --name-only origin/{branch}".split(" "))

return [Path(line) for line in stdout.decode().splitlines()]


Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipeline_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
step["label"] = "🔍 Kani"

steps = [step_style]
changed_files = get_changed_files("main")
changed_files = get_changed_files()

# run sanity build of devtool if Dockerfile is changed
if any(x.name == "Dockerfile" for x in changed_files):
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipeline_pr_no_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
**defaults,
)

changed_files = get_changed_files("main")
changed_files = get_changed_files()
pipeline = {"steps": [optional_grp]} if run_all_tests(changed_files) else {"steps": []}
print(pipeline_to_json(pipeline))