Skip to content

Commit b02e415

Browse files
authored
Merge branch 'main' into fix/coverage-build-hooks-test-mode
2 parents 4e3d5a9 + 4010017 commit b02e415

1 file changed

Lines changed: 38 additions & 13 deletions

File tree

‎.github/workflows/woa-main-ci.yml‎

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
contents: read
3838
checks: read
3939
outputs:
40-
dispatch: ${{ steps.select.outputs.dispatch }}
40+
dispatch: ${{ steps.select.outputs.dispatch || 'false' }}
4141
correlation-id: ${{ steps.resolve.outputs.correlation_id }}
4242
public-run-id: ${{ steps.resolve.outputs.public_run_id }}
4343
public-sha: ${{ steps.resolve.outputs.public_sha }}
@@ -59,6 +59,15 @@ jobs:
5959
PUBLIC_RUN_ID: ${{ inputs.public_run_id }}
6060
run: |
6161
set -euo pipefail
62+
trap 'status=$?; echo "::error::Public build resolution failed at line $LINENO (exit $status)."; exit "$status"' ERR
63+
skip_resolution() {
64+
echo "::notice::Skipping WoA dispatch: $1"
65+
echo "Skipping WoA dispatch: $1" >> "$GITHUB_STEP_SUMMARY"
66+
echo "eligible=false" >> "$GITHUB_OUTPUT"
67+
exit 0
68+
}
69+
70+
echo "Resolving public CI run: ${PUBLIC_RUN_ID:-latest successful main push}."
6271
public_sha=''
6372
if [[ -z "$PUBLIC_RUN_ID" ]]; then
6473
lookup_output=$(./ci/tools/lookup-run-id --branch main --event push --head-sha NVIDIA/cuda-python CI)
@@ -72,35 +81,51 @@ jobs:
7281
run=$(gh api \
7382
-H 'X-GitHub-Api-Version: 2026-03-10' \
7483
"repos/NVIDIA/cuda-python/actions/runs/$PUBLIC_RUN_ID")
75-
jq -e --arg sha "$public_sha" '
76-
.repository.full_name == "NVIDIA/cuda-python" and
77-
.workflow_id == 155304118 and
78-
.path == ".github/workflows/ci.yml" and
79-
.event == "push" and
80-
.head_branch == "main" and
81-
((.status == "in_progress" and .conclusion == null) or
82-
(.status == "completed" and .conclusion == "success")) and
83-
($sha == "" or .head_sha == $sha) and
84-
(.head_sha | test("^[0-9a-f]{40}$"))
85-
' <<< "$run" >/dev/null
84+
echo "Public run metadata:"
85+
jq '{id, repository: .repository.full_name, workflow_id, path, event,
86+
head_branch, head_sha, status, conclusion, run_attempt, created_at, updated_at}' <<< "$run"
87+
checks=$(jq --arg sha "$public_sha" '
88+
{
89+
repository: (.repository.full_name == "NVIDIA/cuda-python"),
90+
workflow_id: (.workflow_id == 155304118),
91+
workflow_path: (.path == ".github/workflows/ci.yml"),
92+
event: (.event == "push"),
93+
branch: (.head_branch == "main"),
94+
status_and_conclusion: ((.status == "in_progress" and .conclusion == null) or
95+
(.status == "completed" and .conclusion == "success")),
96+
expected_sha: ($sha == "" or .head_sha == $sha),
97+
sha_format: ((.head_sha // "") | test("^[0-9a-f]{40}$"))
98+
}
99+
' <<< "$run")
100+
echo "Public run eligibility checks (all must be true): $checks"
101+
failed_checks=$(jq -r 'to_entries | map(select(.value == false) | .key) | join(", ")' <<< "$checks")
102+
if [[ -n "$failed_checks" ]]; then
103+
skip_resolution "Run $PUBLIC_RUN_ID is outside the eligible scope: $failed_checks."
104+
fi
86105
if [[ -z "$public_sha" ]]; then
87106
public_sha=$(jq -r .head_sha <<< "$run")
88107
fi
89108
90109
comparison=$(gh api \
91110
-H 'X-GitHub-Api-Version: 2026-03-10' \
92111
"repos/NVIDIA/cuda-python/compare/$public_sha...main")
93-
jq -e '.status == "ahead" or .status == "identical"' <<< "$comparison" >/dev/null
112+
echo "Public commit comparison ($public_sha...main):"
113+
jq '{status, ahead_by, behind_by, total_commits}' <<< "$comparison"
114+
if ! jq -e '.status == "ahead" or .status == "identical"' <<< "$comparison" >/dev/null; then
115+
skip_resolution "Commit $public_sha is not on main (comparison: $(jq -r .status <<< "$comparison"))."
116+
fi
94117
95118
correlation_id="v1:NVIDIA/cuda-python:$PUBLIC_RUN_ID:$public_sha"
96119
echo "correlation_id=$correlation_id" >> "$GITHUB_OUTPUT"
97120
echo "public_run_id=$PUBLIC_RUN_ID" >> "$GITHUB_OUTPUT"
98121
echo "public_sha=$public_sha" >> "$GITHUB_OUTPUT"
122+
echo "eligible=true" >> "$GITHUB_OUTPUT"
99123
{
100124
echo "Resolved public run \`$PUBLIC_RUN_ID\` at commit \`$public_sha\`."
101125
} >> "$GITHUB_STEP_SUMMARY"
102126
103127
- name: Select public batch
128+
if: ${{ steps.resolve.outputs.eligible == 'true' }}
104129
id: select
105130
env:
106131
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)