Skip to content

Commit e03d295

Browse files
committed
Use github.event.repository.default_branch per review
1 parent e183b15 commit e03d295

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

.github/workflows/reusable-change-detection.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ jobs:
9999
- name: Compute changed files
100100
id: changes
101101
run: python Tools/build/compute-changes.py
102+
env:
103+
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
102104

103105
- name: Compute hash for config cache key
104106
id: config-hash

Tools/build/compute-changes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
if TYPE_CHECKING:
1919
from collections.abc import Set
2020

21+
GITHUB_DEFAULT_BRANCH = os.environ.get("GITHUB_DEFAULT_BRANCH", "")
2122
GITHUB_CODEOWNERS_PATH = Path(".github/CODEOWNERS")
2223
GITHUB_WORKFLOWS_PATH = Path(".github/workflows")
2324
CONFIGURATION_FILE_NAMES = frozenset({
@@ -80,7 +81,9 @@ def git_branches() -> tuple[str, str]:
8081
return target_branch, head_branch
8182

8283

83-
def get_changed_files(ref_a: str = "main", ref_b: str = "HEAD") -> Set[Path]:
84+
def get_changed_files(
85+
ref_a: str = GITHUB_DEFAULT_BRANCH, ref_b: str = "HEAD"
86+
) -> Set[Path]:
8487
"""List the files changed between two Git refs, filtered by change type."""
8588
args = ("git", "diff", "--name-only", f"{ref_a}...{ref_b}", "--")
8689
print(*args)
@@ -147,11 +150,8 @@ def process_target_branch(outputs: Outputs, git_branch: str) -> Outputs:
147150
if not git_branch:
148151
outputs.run_tests = True
149152

150-
# OSS-Fuzz maintains a configuration for fuzzing the main branch of
151-
# CPython, so CIFuzz should be run only for code that is likely to be
152-
# merged into the main branch; compatibility with older branches may
153-
# be broken.
154-
if git_branch != "main":
153+
# CIFuzz / OSS-Fuzz compatibility with older branches may be broken.
154+
if git_branch != GITHUB_DEFAULT_BRANCH:
155155
outputs.run_ci_fuzz = False
156156

157157
if os.environ.get("GITHUB_EVENT_NAME", "").lower() == "workflow_dispatch":

0 commit comments

Comments
 (0)