Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/release-verification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

name: "CI: Verify release"

on:
workflow_run:
workflows: ["CI: Release"]
types: [completed]
workflow_dispatch:
inputs:
git-tag:
description: "Public release tag to audit, for example v12.9.11"
required: true
type: string

permissions: {}

jobs:
verify:
name: Verify public release
if: >-
github.repository == 'NVIDIA/cuda-python' && (
github.event_name == 'workflow_dispatch' ||
(
github.event.workflow_run.event == 'workflow_dispatch' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_repository.full_name == github.repository
)
)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: read
steps:
# workflow_run uses the default branch's verifier, not the producer's head.
- name: Checkout verifier
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Python
uses: ./.github/actions/setup-hardened-python

- name: Install CI tool dependencies
run: python -m pip install -e ./ci

- name: Download release verification metadata
id: release-metadata
if: github.event_name == 'workflow_run'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}
name: release-verification-${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
path: ${{ runner.temp }}/release-verification

- name: Explain unavailable release metadata
if: failure() && steps.release-metadata.outcome == 'failure'
run: |
echo "::error::Could not download staged wheel metadata for this release attempt."
echo "A failed-jobs rerun may reuse preparation from an earlier attempt."
echo "Once the GitHub release is public, dispatch this workflow with its tag for a public audit."

- name: Verify component from completed release
if: github.event_name == 'workflow_run'
run: python -m ci.tools.verify_release verify --manifest "$RUNNER_TEMP/release-verification/release-verification.json"

- name: Audit a public release tag
if: github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.git-tag }}
run: python -m ci.tools.verify_release verify --tag="$RELEASE_TAG"
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,28 @@ jobs:
if-no-files-found: error
retention-days: 3

# A reporting failure belongs to the separate verification workflow.
- name: Record release verification metadata
id: record-verification
continue-on-error: true
env:
RELEASE_MODE: ${{ inputs.release-action }}
run: |
python -m ci.tools.verify_release make-manifest \
--tag="$RELEASE_GIT_TAG" --component "$RELEASE_COMPONENT" \
--mode "$RELEASE_MODE" --wheel-dir release/wheels \
> "$RUNNER_TEMP/release-verification.json"

- name: Upload release verification metadata
if: steps.record-verification.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-verification-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/release-verification.json
if-no-files-found: error
retention-days: 3

test-cuda-python-dependencies:
name: Test cuda-python${{ matrix.extra }} dependencies (${{ matrix.os }}, Python ${{ matrix.python-version }})
if: ${{ inputs.component == 'cuda-python' }}
Expand Down
14 changes: 14 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,20 @@ workflow. Publication mode checks the requested component in the tagged
source, retains the existing nonempty-note and post-release policies, and
exports the version for downstream release jobs.

## Verify Public Releases

[CI: Verify release](../.github/workflows/release-verification.yml) follows
successful **CI: Release** runs. For a full release it checks versioned docs
and compares the component's public PyPI wheels with the staged wheel names
and hashes. A dry run verifies the metadata handoff and skips the public
checks.

After publishing the GitHub release, dispatch **CI: Verify release** with the
release tag to audit the public result. For a shared bindings tag such as
`v12.9.11`, it checks both bindings and metapackage wheels and docs. It also
checks the GitHub release wheels against PyPI and verifies the published source
archive checksum. The workflow summary lists any missing or mismatched results.

## Nightly Artifact Sources

`ci-nightly.yml` downloads wheels from the latest successful main CI run and
Expand Down
159 changes: 159 additions & 0 deletions ci/tools/tests/test_verify_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

import hashlib
import io
import json
from urllib.error import HTTPError

import pytest

from ci.tools import verify_release

TAG = "v12.9.11"
VERSION = "12.9.11"
BINDINGS = "cuda_bindings-12.9.11-cp311-cp311-win_amd64.whl"
METAPACKAGE = "cuda_python-12.9.11-py3-none-any.whl"
DIGEST = hashlib.sha256(b"staged wheel").hexdigest()
ARCHIVE = f"cuda-python-{TAG}.tar.gz"
RELEASE_API = f"https://api.github.com/repos/NVIDIA/cuda-python/releases/tags/{TAG}"
DOWNLOAD = f"https://github.com/NVIDIA/cuda-python/releases/download/{TAG}"


def _pypi_url(component):
return f"https://pypi.org/pypi/{component}/{VERSION}/json"


def _pypi_response(name, digest=DIGEST):
return {
"urls": [
{"filename": name, "digests": {"sha256": digest}, "packagetype": "bdist_wheel", "yanked": False},
],
}


@pytest.fixture
def public_server(monkeypatch):
responses = {
_pypi_url("cuda-bindings"): _pypi_response(BINDINGS),
_pypi_url("cuda-python"): _pypi_response(METAPACKAGE),
RELEASE_API: {
"draft": False,
"tag_name": TAG,
"assets": [
{"name": BINDINGS, "digest": f"sha256:{DIGEST}"},
{"name": METAPACKAGE, "digest": f"sha256:{DIGEST}"},
{"name": ARCHIVE},
{"name": f"{ARCHIVE}.sha256sum"},
],
},
f"{DOWNLOAD}/{ARCHIVE}": b"archive content",
f"{DOWNLOAD}/{ARCHIVE}.sha256sum": hashlib.sha256(b"archive content").hexdigest().encode(),
}
requested = []

def urlopen(request, *, timeout):
url = request.full_url
requested.append(url)
if url.startswith("https://nvidia.github.io/"):
return io.BytesIO()
payload = responses.get(url)
if payload is None:
raise HTTPError(url, 404, "Not found", {}, None)
if isinstance(payload, list):
payload = payload.pop(0)
return io.BytesIO(payload if isinstance(payload, bytes) else json.dumps(payload).encode())

monkeypatch.setattr(verify_release, "urlopen", urlopen)
monkeypatch.setattr(verify_release.time, "sleep", lambda _: None)
return responses, requested


@pytest.mark.agent_authored(model="GPT-6")
def test_dry_run_does_not_probe_public_surfaces(public_server, tmp_path):
(tmp_path / BINDINGS).write_bytes(b"staged wheel")
manifest = verify_release.make_manifest(TAG, "cuda-bindings", "dry-run", tmp_path)

assert manifest["wheels"] == {BINDINGS: DIGEST}
_, errors = verify_release.verify_manifest(manifest)
assert errors == []
assert public_server[1] == []


@pytest.mark.agent_authored(model="GPT-6")
@pytest.mark.parametrize("digest", [DIGEST, "a" * 64])
def test_automatic_report_compares_selected_release_to_staged_wheels(public_server, digest):
manifest = {"tag": TAG, "component": "cuda-bindings", "mode": "full-release", "wheels": {BINDINGS: DIGEST}}
responses, requested = public_server
responses[_pypi_url("cuda-bindings")] = _pypi_response(BINDINGS, digest)

_, errors = verify_release.verify_manifest(manifest)
if digest == DIGEST:
assert errors == []
else:
assert errors == [f"PyPI cuda-bindings {VERSION}: SHA-256 mismatch for {BINDINGS}"]
assert requested == [
_pypi_url("cuda-bindings"),
f"https://nvidia.github.io/cuda-python/cuda-bindings/{VERSION}/",
f"https://nvidia.github.io/cuda-python/cuda-bindings/{VERSION}/release/{VERSION}-notes.html",
]


@pytest.mark.agent_authored(model="GPT-6")
def test_automatic_report_retries_missing_wheels_and_fails_if_still_missing(public_server):
manifest = {"tag": TAG, "component": "cuda-bindings", "mode": "full-release", "wheels": {BINDINGS: DIGEST}}
responses, requested = public_server
url = _pypi_url("cuda-bindings")
responses[url] = [{"urls": []}, _pypi_response(BINDINGS)]

_, errors = verify_release.verify_manifest(manifest)
assert errors == []
assert requested.count(url) == 2

responses[url] = {"urls": []}
_, errors = verify_release.verify_manifest(manifest)
assert len(errors) == 1
assert f"missing non-yanked wheels: {BINDINGS}" in errors[0]


@pytest.mark.agent_authored(model="GPT-6")
def test_manual_report_checks_both_components_and_downloaded_archive(public_server):
_, requested = public_server
passed, errors = verify_release.verify_tag(TAG)
assert errors == []
assert _pypi_url("cuda-bindings") in requested
assert _pypi_url("cuda-python") in requested
assert f"{DOWNLOAD}/{ARCHIVE}" in requested
assert f"{DOWNLOAD}/{ARCHIVE}.sha256sum" in requested
assert f"GitHub release {TAG}: 2 wheels match PyPI" in passed


@pytest.mark.agent_authored(model="GPT-6")
def test_manual_report_fails_for_partial_publication_and_corrupt_archive(public_server):
responses, _ = public_server
del responses[_pypi_url("cuda-python")]
responses[f"{DOWNLOAD}/{ARCHIVE}"] = b"wrong archive content"

_, errors = verify_release.verify_tag(TAG)
assert len(errors) == 2
assert any("PyPI cuda-python" in error and "HTTP 404" in error for error in errors)
assert any("does not match its published SHA-256 checksum" in error for error in errors)


@pytest.mark.agent_authored(model="GPT-6")
def test_pathfinder_post_release_uses_its_versioned_landing_page(public_server):
filename = "cuda_pathfinder-1.9.1.post1-py3-none-any.whl"
pypi_url = "https://pypi.org/pypi/cuda-pathfinder/1.9.1.post1/json"
manifest = {
"tag": "cuda-pathfinder-v1.9.1.post1",
"component": "cuda-pathfinder",
"mode": "full-release",
"wheels": {filename: DIGEST},
}
responses, requested = public_server
responses[pypi_url] = _pypi_response(filename)

_, errors = verify_release.verify_manifest(manifest)
assert errors == []
assert requested == [pypi_url, "https://nvidia.github.io/cuda-python/cuda-pathfinder/1.9.1/"]
Loading
Loading