Skip to content

gh-133410: Fix PR detection in build workflow #133671

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
May 15, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/reusable-context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
run: python Tools/build/compute-changes.py
env:
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
CCF_TARGET_REF: ${{ github.base_ref || github.event.repository.default_branch }}
CCF_HEAD_REF: ${{ github.event.pull_request.head.sha || github.sha }}

Expand Down
2 changes: 1 addition & 1 deletion Tools/build/compute-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Outputs:

def compute_changes() -> None:
target_branch, head_ref = git_refs()
if target_branch and head_ref:
if os.environ.get("GITHUB_EVENT_NAME", "") == "pull_request":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this should be and

Suggested change
if os.environ.get("GITHUB_EVENT_NAME", "") == "pull_request":
if (
target_branch
and head_ref
and os.environ.get("GITHUB_EVENT_NAME", "") == "pull_request"
):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #133410 (comment), the original problem is that target_branch and head_ref are always be truthy, so I don't think we need to check them.

# Getting changed files only makes sense on a pull request
files = get_changed_files(target_branch, head_ref)
outputs = process_changed_files(files)
Expand Down
Loading