Skip to content

Commit 6c76734

Browse files
committed
[CI] Clean up CI scope detection workflow and script
1 parent a9f25d0 commit 6c76734

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
task_scoped: ${{ steps.detect.outputs.task_scoped }}
2424
steps:
2525
- uses: actions/checkout@v7
26-
if: ${{ github.event_name == 'pull_request' }}
2726
with:
2827
fetch-depth: 0
2928
- name: Detect CI task scope
@@ -33,14 +32,8 @@ jobs:
3332
BASE_SHA: ${{ github.event.pull_request.base.sha }}
3433
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
3534
run: |
36-
if [ "$EVENT_NAME" != "pull_request" ]; then
37-
echo "ppc_tasks=all" >> "$GITHUB_OUTPUT"
38-
echo "task_scoped=false" >> "$GITHUB_OUTPUT"
39-
echo "PPC_TASKS=all"
40-
exit 0
41-
fi
42-
4335
python3 scripts/detect_ci_task_scope.py \
36+
--event-name "$EVENT_NAME" \
4437
--base-sha "$BASE_SHA" \
4538
--head-sha "$HEAD_SHA" \
4639
--github-output "$GITHUB_OUTPUT"

scripts/detect_ci_task_scope.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ def _write_github_output(github_output: Path, scope: str, task_scoped: bool) ->
5252

5353
def _parse_args() -> argparse.Namespace:
5454
parser = argparse.ArgumentParser(
55-
description="Detect the PPC_TASKS value for CI from changed PR paths.",
55+
description="Detect the PPC_TASKS value for CI.",
5656
)
5757
parser.add_argument(
58-
"--base-sha", required=True, help="Base commit for the PR diff."
59-
)
60-
parser.add_argument(
61-
"--head-sha", required=True, help="Head commit for the PR diff."
58+
"--event-name",
59+
default="pull_request",
60+
help="GitHub event name. Non-PR events always run the full suite.",
6261
)
62+
parser.add_argument("--base-sha", help="Base commit for the PR diff.")
63+
parser.add_argument("--head-sha", help="Head commit for the PR diff.")
6364
parser.add_argument(
6465
"--tasks-root", default="tasks", type=Path, help="Path to the tasks directory."
6566
)
@@ -73,9 +74,15 @@ def _parse_args() -> argparse.Namespace:
7374

7475
def main() -> None:
7576
args = _parse_args()
76-
scope, task_scoped = detect_scope(
77-
_changed_files(args.base_sha, args.head_sha), args.tasks_root
78-
)
77+
if args.event_name != "pull_request":
78+
scope, task_scoped = FULL_SUITE, False
79+
else:
80+
if args.base_sha is None or args.head_sha is None:
81+
msg = "--base-sha and --head-sha are required for pull_request events"
82+
raise SystemExit(msg)
83+
scope, task_scoped = detect_scope(
84+
_changed_files(args.base_sha, args.head_sha), args.tasks_root
85+
)
7986

8087
print(f"PPC_TASKS={scope}")
8188
if args.github_output is not None:

0 commit comments

Comments
 (0)