Skip to content

Commit 0bdbf88

Browse files
committed
Find latest successful main CI run when WoA run ID is omitted
1 parent 9ed8032 commit 0bdbf88

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

‎.github/workflows/woa-validation-dispatch.yml‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
name: "WoA validation dispatch"
6-
run-name: "WoA exact dispatch for public run ${{ inputs.public_run_id }}"
6+
run-name: "WoA exact dispatch for ${{ inputs.public_run_id || 'latest successful public main CI run' }}"
77

88
on:
99
workflow_dispatch:
1010
inputs:
1111
public_run_id:
12-
description: Successful public main CI run containing the exact WoA artifacts
13-
required: true
12+
description: Successful public main CI run; leave empty to find the latest successful main CI run
13+
required: false
1414
type: string
1515

1616
permissions: {}
@@ -29,30 +29,52 @@ jobs:
2929
correlation-id: ${{ steps.resolve.outputs.correlation_id }}
3030
public-producer-job-id: ${{ steps.resolve.outputs.public_producer_job_id }}
3131
public-run-attempt: ${{ steps.resolve.outputs.public_run_attempt }}
32+
public-run-id: ${{ steps.resolve.outputs.public_run_id }}
3233
public-sha: ${{ steps.resolve.outputs.public_sha }}
3334
steps:
35+
- name: Checkout main run lookup helper
36+
if: ${{ inputs.public_run_id == '' }}
37+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
38+
with:
39+
ref: main
40+
persist-credentials: false
41+
sparse-checkout: ci/tools/lookup-run-id
42+
sparse-checkout-cone-mode: false
43+
3444
- name: Resolve exact successful public build
3545
id: resolve
3646
env:
3747
GH_TOKEN: ${{ github.token }}
3848
PUBLIC_RUN_ID: ${{ inputs.public_run_id }}
3949
run: |
4050
set -euo pipefail
51+
public_sha=''
52+
if [[ -z "$PUBLIC_RUN_ID" ]]; then
53+
lookup_output=$(./ci/tools/lookup-run-id --branch main --head-sha NVIDIA/cuda-python CI)
54+
mapfile -t lookup_result <<< "$lookup_output"
55+
[[ ${#lookup_result[@]} == 2 ]]
56+
PUBLIC_RUN_ID=${lookup_result[0]}
57+
public_sha=${lookup_result[1]}
58+
[[ "$public_sha" =~ ^[0-9a-f]{40}$ ]]
59+
fi
4160
[[ "$PUBLIC_RUN_ID" =~ ^[1-9][0-9]*$ ]]
4261
run=$(gh api \
4362
-H 'X-GitHub-Api-Version: 2026-03-10' \
4463
"repos/NVIDIA/cuda-python/actions/runs/$PUBLIC_RUN_ID")
45-
jq -e '
64+
jq -e --arg sha "$public_sha" '
4665
.repository.full_name == "NVIDIA/cuda-python" and
4766
.workflow_id == 155304118 and
4867
.path == ".github/workflows/ci.yml" and
4968
.event == "push" and
5069
.head_branch == "main" and
5170
.status == "completed" and
5271
.conclusion == "success" and
72+
($sha == "" or .head_sha == $sha) and
5373
(.head_sha | test("^[0-9a-f]{40}$"))
5474
' <<< "$run" >/dev/null
55-
public_sha=$(jq -r .head_sha <<< "$run")
75+
if [[ -z "$public_sha" ]]; then
76+
public_sha=$(jq -r .head_sha <<< "$run")
77+
fi
5678
public_run_attempt=$(jq -r '.run_attempt | tostring' <<< "$run")
5779
5880
comparison=$(gh api \
@@ -114,6 +136,7 @@ jobs:
114136
echo "correlation_id=$correlation_id" >> "$GITHUB_OUTPUT"
115137
echo "public_producer_job_id=$public_producer_job_id" >> "$GITHUB_OUTPUT"
116138
echo "public_run_attempt=$public_run_attempt" >> "$GITHUB_OUTPUT"
139+
echo "public_run_id=$PUBLIC_RUN_ID" >> "$GITHUB_OUTPUT"
117140
echo "public_sha=$public_sha" >> "$GITHUB_OUTPUT"
118141
{
119142
echo "Resolved public run \`$PUBLIC_RUN_ID\` attempt \`$public_run_attempt\` and producer job \`$public_producer_job_id\`."
@@ -144,7 +167,7 @@ jobs:
144167
CORRELATION_ID: ${{ needs.resolve-public-build.outputs.correlation-id }}
145168
GH_TOKEN: ${{ steps.private-app-token.outputs.token }}
146169
PUBLIC_RUN_ATTEMPT: ${{ needs.resolve-public-build.outputs.public-run-attempt }}
147-
PUBLIC_RUN_ID: ${{ inputs.public_run_id }}
170+
PUBLIC_RUN_ID: ${{ needs.resolve-public-build.outputs.public-run-id }}
148171
PUBLIC_PRODUCER_JOB_ID: ${{ needs.resolve-public-build.outputs.public-producer-job-id }}
149172
PUBLIC_SHA: ${{ needs.resolve-public-build.outputs.public-sha }}
150173
run: |

0 commit comments

Comments
 (0)