Repository navigation
[WoA] Add manual cross-repository broker #3025
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
Open
isVoid
wants to merge
2
commits into
main
Choose a base branch
from
codex/woa-xrepo-public-manual-broker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name: "WoA cross-repository transport smoke" | ||
| run-name: "WoA transport smoke for PR #${{ inputs.pr_number }}" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: Open same-repository PR to receive the smoke Check Run | ||
| required: true | ||
| type: number | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| resolve-public-pr: | ||
| if: ${{ github.repository == 'NVIDIA/cuda-python' }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| pull-requests: read | ||
| outputs: | ||
| correlation-id: ${{ steps.resolve.outputs.correlation_id }} | ||
| public-sha: ${{ steps.resolve.outputs.public_sha }} | ||
| steps: | ||
| - name: Resolve exact same-repository PR head | ||
| id: resolve | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ inputs.pr_number }} | ||
| run: | | ||
| set -euo pipefail | ||
| [[ "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]] | ||
| pr=$(gh api \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA/cuda-python/pulls/$PR_NUMBER") | ||
| jq -e ' | ||
| .state == "open" and | ||
| .base.ref == "main" and | ||
| .head.repo.full_name == "NVIDIA/cuda-python" and | ||
| (.head.sha | test("^[0-9a-f]{40}$")) | ||
| ' <<< "$pr" >/dev/null | ||
| public_sha=$(jq -r .head.sha <<< "$pr") | ||
| correlation_id="smoke:381173759:$PR_NUMBER:$public_sha:${GITHUB_RUN_ID}:${GITHUB_RUN_ATTEMPT}" | ||
| echo "public_sha=$public_sha" >> "$GITHUB_OUTPUT" | ||
| echo "correlation_id=$correlation_id" >> "$GITHUB_OUTPUT" | ||
|
|
||
| dispatch-private-smoke: | ||
| needs: resolve-public-pr | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| permissions: {} | ||
| steps: | ||
| - name: Create private dispatch token | ||
| id: private-app-token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 | ||
| with: | ||
| client-id: ${{ vars.CUDA_PYTHON_WOA_XREPO_CI_PRIVATE_APP_CLIENT_ID }} | ||
| private-key: ${{ secrets.CUDA_PYTHON_WOA_XREPO_CI_PRIVATE_APP_PRIVATE_KEY }} | ||
| owner: NVIDIA-dev | ||
| repositories: cuda-python-private | ||
| permission-actions: write | ||
|
|
||
| - name: Dispatch and verify private smoke workflow | ||
| env: | ||
| CORRELATION_ID: ${{ needs.resolve-public-pr.outputs.correlation-id }} | ||
| GH_TOKEN: ${{ steps.private-app-token.outputs.token }} | ||
| PR_NUMBER: ${{ inputs.pr_number }} | ||
| PUBLIC_SHA: ${{ needs.resolve-public-pr.outputs.public-sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| payload=$(jq -n \ | ||
| --arg correlation_id "$CORRELATION_ID" \ | ||
| --arg pr_number "$PR_NUMBER" \ | ||
| --arg public_sha "$PUBLIC_SHA" \ | ||
| '{ | ||
| ref: "ctk-next", | ||
| return_run_details: true, | ||
| inputs: { | ||
| schema_version: "1", | ||
| public_repository: "NVIDIA/cuda-python", | ||
| public_repository_id: "381173759", | ||
| public_pr_number: $pr_number, | ||
| public_sha: $public_sha, | ||
| correlation_id: $correlation_id | ||
| } | ||
| }') | ||
| response=$(gh api \ | ||
| --method POST \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| repos/NVIDIA-dev/cuda-python-private/actions/workflows/woa-crossrepo-smoke.yml/dispatches \ | ||
| --input - <<< "$payload") | ||
| private_run_id=$(jq -er '.workflow_run_id | tostring' <<< "$response") | ||
| run=$(gh api \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA-dev/cuda-python-private/actions/runs/$private_run_id") | ||
| jq -e ' | ||
| .repository.id == 809898190 and | ||
| .path == ".github/workflows/woa-crossrepo-smoke.yml" and | ||
| .event == "workflow_dispatch" and | ||
| .head_branch == "ctk-next" | ||
| ' <<< "$run" >/dev/null | ||
| echo "Private transport-smoke workflow accepted the exact dispatch." >> "$GITHUB_STEP_SUMMARY" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name: "WoA exact public-main dispatch" | ||
| run-name: "WoA exact dispatch for public run ${{ inputs.public_run_id }}" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| public_run_id: | ||
| description: Successful public main CI run containing the exact WoA artifacts | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| resolve-public-build: | ||
| if: ${{ github.repository == 'NVIDIA/cuda-python' }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| checks: read | ||
| outputs: | ||
| artifacts-json: ${{ steps.resolve.outputs.artifacts_json }} | ||
| correlation-id: ${{ steps.resolve.outputs.correlation_id }} | ||
| public-producer-job-id: ${{ steps.resolve.outputs.public_producer_job_id }} | ||
| public-run-attempt: ${{ steps.resolve.outputs.public_run_attempt }} | ||
| public-sha: ${{ steps.resolve.outputs.public_sha }} | ||
| steps: | ||
| - name: Resolve exact successful public build | ||
| id: resolve | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PUBLIC_RUN_ID: ${{ inputs.public_run_id }} | ||
| run: | | ||
| set -euo pipefail | ||
| [[ "$PUBLIC_RUN_ID" =~ ^[1-9][0-9]*$ ]] | ||
| run=$(gh api \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA/cuda-python/actions/runs/$PUBLIC_RUN_ID") | ||
| jq -e ' | ||
| .repository.id == 381173759 and | ||
| .workflow_id == 155304118 and | ||
| .path == ".github/workflows/ci.yml" and | ||
| .event == "push" and | ||
| .head_branch == "main" and | ||
| .status == "completed" and | ||
| .conclusion == "success" and | ||
| (.head_sha | test("^[0-9a-f]{40}$")) | ||
| ' <<< "$run" >/dev/null | ||
| public_sha=$(jq -r .head_sha <<< "$run") | ||
| public_run_attempt=$(jq -r '.run_attempt | tostring' <<< "$run") | ||
|
|
||
| comparison=$(gh api \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA/cuda-python/compare/$public_sha...main") | ||
| jq -e '.status == "ahead" or .status == "identical"' <<< "$comparison" >/dev/null | ||
|
|
||
| jobs=$(gh api --paginate \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA/cuda-python/actions/runs/$PUBLIC_RUN_ID/attempts/$public_run_attempt/jobs?per_page=100" \ | ||
| --jq '.jobs') | ||
| producer_jobs=$(jq -s -c ' | ||
| add | ||
| | map(select(.name == "Build win-arm64, CUDA 13.4.2 / py3.13")) | ||
| ' <<< "$jobs") | ||
| jq -e ' | ||
| length == 1 and | ||
| .[0].status == "completed" and | ||
| .[0].conclusion == "success" | ||
| ' <<< "$producer_jobs" >/dev/null | ||
| public_producer_job_id=$(jq -r '.[0].id | tostring' <<< "$producer_jobs") | ||
|
|
||
| expected_names=$(jq -n \ | ||
| --arg sha "$public_sha" '[ | ||
| "cuda-pathfinder-wheel", | ||
| ("cuda-bindings-python313-cuda13.4.2-win-arm64-" + $sha), | ||
| ("cuda-core-python313-win-arm64-" + $sha) | ||
| ]') | ||
| artifacts_json='[]' | ||
| while IFS= read -r artifact_name; do | ||
| response=$(gh api --method GET \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA/cuda-python/actions/runs/$PUBLIC_RUN_ID/artifacts" \ | ||
| -f name="$artifact_name" \ | ||
| -F per_page=100) | ||
| artifact=$(jq -c -e \ | ||
| --arg name "$artifact_name" ' | ||
| if .total_count == 1 and | ||
| (.artifacts | length) == 1 and | ||
| .artifacts[0].name == $name and | ||
| .artifacts[0].expired == false | ||
| then .artifacts[0] | {id, name, digest} | ||
| else error("expected exactly one unexpired artifact named " + $name) | ||
| end | ||
| ' <<< "$response") | ||
| artifacts_json=$(jq -c \ | ||
| --argjson artifact "$artifact" \ | ||
| '. + [$artifact] | sort_by(.name)' <<< "$artifacts_json") | ||
| done < <(jq -r '.[]' <<< "$expected_names") | ||
| jq -e ' | ||
| length == 3 and | ||
| all(.[ ]; | ||
| (.id | type == "number") and | ||
| (.digest | test("^sha256:[0-9a-f]{64}$"))) | ||
| ' <<< "$artifacts_json" >/dev/null | ||
|
|
||
| correlation_id="v1:381173759:$PUBLIC_RUN_ID:$public_run_attempt:$public_sha" | ||
| echo "artifacts_json=$artifacts_json" >> "$GITHUB_OUTPUT" | ||
| echo "correlation_id=$correlation_id" >> "$GITHUB_OUTPUT" | ||
| echo "public_producer_job_id=$public_producer_job_id" >> "$GITHUB_OUTPUT" | ||
| echo "public_run_attempt=$public_run_attempt" >> "$GITHUB_OUTPUT" | ||
| echo "public_sha=$public_sha" >> "$GITHUB_OUTPUT" | ||
| { | ||
| echo "Resolved public run \`$PUBLIC_RUN_ID\` attempt \`$public_run_attempt\` and producer job \`$public_producer_job_id\`." | ||
| echo "" | ||
| echo "Exact Windows Arm64 artifacts:" | ||
| jq -r '.[] | "- `\(.name)` (`\(.digest)`)"' <<< "$artifacts_json" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| dispatch-private-validation: | ||
| needs: resolve-public-build | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| permissions: {} | ||
| steps: | ||
| - name: Create private dispatch token | ||
| id: private-app-token | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 | ||
| with: | ||
| client-id: ${{ vars.CUDA_PYTHON_WOA_XREPO_CI_PRIVATE_APP_CLIENT_ID }} | ||
| private-key: ${{ secrets.CUDA_PYTHON_WOA_XREPO_CI_PRIVATE_APP_PRIVATE_KEY }} | ||
| owner: NVIDIA-dev | ||
| repositories: cuda-python-private | ||
| permission-actions: write | ||
|
|
||
| - name: Dispatch and verify exact private validation | ||
| env: | ||
| ARTIFACTS_JSON: ${{ needs.resolve-public-build.outputs.artifacts-json }} | ||
| CORRELATION_ID: ${{ needs.resolve-public-build.outputs.correlation-id }} | ||
| GH_TOKEN: ${{ steps.private-app-token.outputs.token }} | ||
| PUBLIC_RUN_ATTEMPT: ${{ needs.resolve-public-build.outputs.public-run-attempt }} | ||
| PUBLIC_RUN_ID: ${{ inputs.public_run_id }} | ||
| PUBLIC_PRODUCER_JOB_ID: ${{ needs.resolve-public-build.outputs.public-producer-job-id }} | ||
| PUBLIC_SHA: ${{ needs.resolve-public-build.outputs.public-sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| payload=$(jq -n \ | ||
| --arg artifacts_json "$ARTIFACTS_JSON" \ | ||
| --arg correlation_id "$CORRELATION_ID" \ | ||
| --arg producer_job_id "$PUBLIC_PRODUCER_JOB_ID" \ | ||
| --arg run_attempt "$PUBLIC_RUN_ATTEMPT" \ | ||
| --arg run_id "$PUBLIC_RUN_ID" \ | ||
| --arg sha "$PUBLIC_SHA" \ | ||
| '{ | ||
| ref: "ctk-next", | ||
| return_run_details: true, | ||
| inputs: { | ||
| schema_version: "1", | ||
| public_repository: "NVIDIA/cuda-python", | ||
| public_repository_id: "381173759", | ||
| public_workflow_id: "155304118", | ||
| public_producer_job_id: $producer_job_id, | ||
| public_run_id: $run_id, | ||
| public_run_attempt: $run_attempt, | ||
| public_sha: $sha, | ||
| artifacts_json: $artifacts_json, | ||
| baseline_sha: "", | ||
| commit_count: "1", | ||
| correlation_id: $correlation_id | ||
| } | ||
| }') | ||
| response=$(gh api \ | ||
| --method POST \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| repos/NVIDIA-dev/cuda-python-private/actions/workflows/woa-main-validation.yml/dispatches \ | ||
| --input - <<< "$payload") | ||
| private_run_id=$(jq -er '.workflow_run_id | tostring' <<< "$response") | ||
| run=$(gh api \ | ||
| -H 'X-GitHub-Api-Version: 2026-03-10' \ | ||
| "repos/NVIDIA-dev/cuda-python-private/actions/runs/$private_run_id") | ||
| jq -e ' | ||
| .repository.id == 809898190 and | ||
| .path == ".github/workflows/woa-main-validation.yml" and | ||
| .event == "workflow_dispatch" and | ||
| .head_branch == "ctk-next" | ||
| ' <<< "$run" >/dev/null | ||
| echo "Private validation workflow accepted the exact dispatch." >> "$GITHUB_STEP_SUMMARY" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
important: Put the private-dispatch App key behind a protected environment.
dispatch-private-validationhas noenvironment:. As a result,CUDA_PYTHON_WOA_XREPO_CI_PRIVATE_APP_PRIVATE_KEYis a repository-level or organization-level secret. A user with write access can push a branch that changes this workflow and dispatch it from that branch.The modified workflow can then mint an
actions: writetoken forNVIDIA-dev/cuda-python-private. That token can:All checks in
resolve-public-buildrun from the dispatched ref, so a modified branch can bypass all of them. Anif: github.ref == 'refs/heads/main'guard does not help for the same reason.Fix:
mainonly.dispatch-private-validation: needs: resolve-public-build runs-on: ubuntu-latest timeout-minutes: 10 + environment: woa-private-dispatch permissions: {}Apply the same change to the dispatch job in
woa-crossrepo-smoke.yml. That job uses the same credential pattern.📝 Committable suggestion
Source: Path instructions