Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
if: inputs.phase == 'Validate release'
runs-on: ubuntu-24.04
timeout-minutes: 35
defaults:
run:
working-directory: source
permissions:
actions: read
contents: read
Expand All @@ -90,6 +93,7 @@ jobs:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ needs.preflight.outputs.source_sha }}
path: source
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
Expand Down Expand Up @@ -121,6 +125,16 @@ jobs:
--archive "$wheel" --archive "$sdist"
uvx --from twine==6.2.0 twine check --strict "$wheel" "$sdist"
printf 'manifest_sha256=%s\n' "$manifest_sha256" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.workflow_sha }}
path: release-control
persist-credentials: false
- name: Verify the dated changelog and public GHCR digest
run: |
# Run the current check against the reviewed source, which may predate the command.
python3 ../release-control/ci/github_release.py verify-release-metadata --version "$VERSION" \
--source-sha "$SOURCE_SHA" --assets "$RUNNER_TEMP/product-release"
- name: Check that the package indexes can accept these release bytes
run: |
python3 ci/product_release.py inspect-indexes --version "$VERSION" --assets "$RUNNER_TEMP/product-release"
Expand Down
10 changes: 6 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ image and consumer qualification details.

1. Open the workflow in the GitHub UI again, choose **Validate release**, and
enter the version and product release SHA from the bundle PR. Review the
source, wheel, sdist, and CI bundle checks. On the successful run's
**Summary** page, copy `validation_run` (the run ID and attempt, such as
`123-1`) and `validation_manifest_sha256` from **Publish release inputs**.
source, wheel, sdist, and CI bundle checks. Validation checks for a dated
changelog entry and confirms the live public GHCR digest against the reviewed
bundle. On the successful run's **Summary** page, copy both values from
**Publish release inputs**. `validation_run` includes the run ID and attempt
(such as `123-1`), and `validation_manifest_sha256` is the manifest hash.
2. Choose **Publish release** with the same version and product SHA, enter the
two values from the summary, and approve the `release-github` job. The
publish run verifies the selected validation attempt and uses its exact
wheel, sdist, CI ZIP, manifest, and checksums. If the retained validation
artifact has expired or is missing before the first draft is staged, run
**Validate release** again and use both values from the new summary.
Before creating `vVERSION` at the reviewed product SHA, the workflow
checks the release notes, the official GHCR digest, and both package
rechecks the release notes and official GHCR digest and checks both package
indexes for version conflicts. It verifies the staged bytes before
publishing and verifies anonymous downloads afterward. The notes show that
package publication is pending. Release runs execute one at a time across
Expand Down
32 changes: 26 additions & 6 deletions ci/github_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,30 @@ def acquire_publication(version: str, source_sha: str, output: Path, run_ref: st
return True


def verify_local(version: str, source_sha: str, assets: Path) -> dict:
product_release.verify_assets(version, source_sha, assets)
manifest = json.loads((assets / product_release.MANIFEST).read_text(encoding="utf-8"))
def verify_public_image(manifest: dict) -> None:
image = manifest["image"]
published = release_image.resolve_digest(image.partition("@")[0], manifest["image_source_commit"])
Comment thread
rng1995 marked this conversation as resolved.
Resolved
if published != image:
raise ValueError("The official public image revision does not match the reviewed release digest.")


def verify_local(version: str, source_sha: str, assets: Path) -> dict:
product_release.verify_assets(version, source_sha, assets)
manifest = json.loads((assets / product_release.MANIFEST).read_text(encoding="utf-8"))
verify_public_image(manifest)
return {asset["filename"]: asset for asset in manifest["artifacts"]}


def release_notes(version: str, assets: Path) -> str:
def changelog_entry(version: str) -> str:
changelog = Path("CHANGELOG.md").read_text(encoding="utf-8")
title = re.search(rf"^## {re.escape(version)} - \d{{4}}-\d{{2}}-\d{{2}}\s*$", changelog, re.MULTILINE)
if title is None:
raise ValueError(f"CHANGELOG.md has no dated entry for {version}.")
changes = re.split(r"^## ", changelog[title.end() :], maxsplit=1, flags=re.MULTILINE)[0].strip()
return re.split(r"^## ", changelog[title.end() :], maxsplit=1, flags=re.MULTILINE)[0].strip()


def release_notes(version: str, assets: Path) -> str:
changes = changelog_entry(version)
tag = f"v{version}"
manifest = json.loads((assets / "artifact-manifest.json").read_text(encoding="utf-8"))
bundle = f"ci/bundles/{version}"
Expand All @@ -328,6 +336,14 @@ def release_notes(version: str, assets: Path) -> str:
)


def verify_release_metadata(version: str, source_sha: str, assets: Path) -> None:
manifest, _ = product_release.checked_manifest(version, assets)
if manifest.get("source_commit") != source_sha:
raise ValueError("The artifact manifest does not match the reviewed source commit.")
changelog_entry(version)
Comment thread
rng1995 marked this conversation as resolved.
Resolved
verify_public_image(manifest)


def empty_upload(asset: dict) -> bool:
return asset["state"] == "starter" and asset["size"] == 0

Expand Down Expand Up @@ -434,7 +450,10 @@ def finalize(version: str, source_sha: str, assets: Path) -> None:

def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("command", choices=("preflight", "restore", "acquire", "stage", "verify-public", "finalize"))
parser.add_argument(
"command",
choices=("preflight", "restore", "acquire", "verify-release-metadata", "stage", "verify-public", "finalize"),
)
parser.add_argument("--version", required=True)
parser.add_argument("--source-sha", required=True)
parser.add_argument("--assets", type=Path)
Expand All @@ -446,6 +465,7 @@ def main() -> int:
args = parser.parse_args()
commands = {
"restore": restore,
"verify-release-metadata": verify_release_metadata,
"verify-public": verify_public,
"finalize": finalize,
}
Expand Down
51 changes: 48 additions & 3 deletions tests/ci/test_manual_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ def test_release_is_only_dispatched_manually_and_defaults_to_validation():
assert any("inspect-indexes" in step.get("run", "") for step in jobs["prepare"]["steps"])


def test_validate_checks_release_metadata_with_the_current_workflow_from_the_reviewed_checkout():
workflow = yaml.load((ROOT / ".github/workflows/release.yml").read_text(), Loader=yaml.BaseLoader)
job = workflow["jobs"]["prepare"]
steps = job["steps"]
metadata = [i for i, step in enumerate(steps) if "github_release.py verify-release-metadata" in step.get("run", "")]
assert len(metadata) == 1
(metadata_index,) = metadata
assert "../release-control/ci/github_release.py" in steps[metadata_index]["run"]
assert job["defaults"]["run"]["working-directory"] == "source"
assert job["permissions"] == {"actions": "read", "contents": "read"}
checkout_refs = {
step["with"]["path"]: step["with"]["ref"]
for step in steps[:metadata_index]
if step.get("uses", "").startswith("actions/checkout@")
}
assert checkout_refs == {
"release-control": "${{ github.workflow_sha }}",
"source": "${{ needs.preflight.outputs.source_sha }}",
}
verify = next(i for i, step in enumerate(steps) if "product_release.py verify-assets" in step.get("run", ""))
retain = next(i for i, step in enumerate(steps) if "upload-artifact@" in step.get("uses", ""))
assert verify < metadata_index < retain


@pytest.mark.parametrize("name", ["release", "release-tier1-image", "release-kitmaker"])
def test_release_workflows_scope_permissions_and_credentials(name):
source = (ROOT / ".github" / "workflows" / f"{name}.yml").read_text(encoding="utf-8")
Expand Down Expand Up @@ -113,17 +137,22 @@ def test_public_verification_rejects_a_mutable_release(release, monkeypatch, tmp
download.assert_not_called()


def test_registry_revision_must_match_the_reviewed_digest(release, monkeypatch, tmp_path):
def test_publish_rechecks_the_public_image_before_tagging(release, monkeypatch, tmp_path):
repository = "ghcr.io/nvidia/skillevaluator-tier1"
(tmp_path / "artifact-manifest.json").write_text(
json.dumps({"image": f"{repository}@sha256:{'a' * 64}", "image_source_commit": SHA})
)
monkeypatch.setattr(release, "tag_target", lambda _: None)
monkeypatch.setattr(release, "get_release", lambda _: None)
monkeypatch.setattr(release.product_release, "verify_assets", Mock())
resolve = Mock(return_value=f"{repository}@sha256:{'b' * 64}")
monkeypatch.setattr(release.release_image, "resolve_digest", resolve)
writes = Mock()
monkeypatch.setattr(release, "api", writes)
with pytest.raises(ValueError, match="does not match the reviewed release digest"):
release.verify_local(VERSION, SHA, tmp_path)
release.stage(VERSION, SHA, tmp_path, "123-2")
resolve.assert_called_once_with(repository, SHA)
writes.assert_not_called()


def release_run(**overrides):
Expand Down Expand Up @@ -370,13 +399,29 @@ def test_initial_publication_checks_package_conflicts_before_tagging(release, mo
writes.assert_not_called()


def test_publish_rechecks_the_dated_changelog_before_tagging(release, monkeypatch, tmp_path):
(tmp_path / "CHANGELOG.md").write_text(f"## {VERSION}\n\nPublished changes.\n", encoding="utf-8")
monkeypatch.chdir(tmp_path)
monkeypatch.setattr(release, "tag_target", lambda _: None)
monkeypatch.setattr(release, "get_release", lambda _: None)
monkeypatch.setattr(release, "verify_local", Mock(return_value={}))
monkeypatch.setattr(release.product_release, "inspect_public_indexes", Mock())
writes = Mock()
monkeypatch.setattr(release, "api", writes)
with pytest.raises(ValueError, match="no dated entry"):
release.stage(VERSION, SHA, tmp_path, "123-2")
writes.assert_not_called()


def test_immutable_resume_reaches_kitmaker_even_when_an_index_is_pending(release, monkeypatch, tmp_path):
monkeypatch.setattr(release, "tag_target", lambda _: SHA)
monkeypatch.setattr(release, "get_release", lambda _: {"draft": False, "immutable": True})
monkeypatch.setattr(release, "verify_local", Mock(return_value={}))
monkeypatch.setattr(release, "verify_staged", Mock())
monkeypatch.setattr(release, "release_notes", lambda *_: "Frozen release notes")
notes = Mock(side_effect=ValueError("CHANGELOG.md has no dated release entry."))
monkeypatch.setattr(release, "release_notes", notes)
inspect_indexes = Mock(side_effect=ValueError("An artifact is present on only one index"))
monkeypatch.setattr(release.product_release, "inspect_public_indexes", inspect_indexes)
release.stage(VERSION, SHA, tmp_path, "123-2")
notes.assert_not_called()
inspect_indexes.assert_not_called()
54 changes: 54 additions & 0 deletions tests/ci/test_product_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,60 @@ def test_assembles_generated_bundle_and_verifies_exact_assets(release):
assert "manifest" in verified.stderr


@pytest.mark.parametrize(
("invalid", "error"),
[
(None, ""),
("changelog", "no dated entry"),
("digest", "does not match the reviewed release digest"),
("missing-image", "does not match the reviewed release digest"),
("source", "does not match the reviewed source"),
],
)
def test_validate_checks_the_reviewed_changelog_and_live_public_image(release, monkeypatch, capsys, invalid, error):
repo, source, dist, assets, candidate = release
result = release_command(repo, source, "assemble", "--dist", dist, "--output", assets)
assert result.returncode == 0, result.stderr
title = f"## {VERSION}" if invalid == "changelog" else f"## {VERSION} - 2026-11-20"
(repo / "CHANGELOG.md").write_text(f"# Changelog\n\n{title}\n\nPublished changes.\n", encoding="utf-8")
repository = "ghcr.io/nvidia/skillevaluator-tier1"
published = {"digest": f"{repository}@sha256:{'b' * 64}", "missing-image": None}.get(invalid, IMAGE)
lookups = []

def resolve_image(repo_name, source_revision):
lookups.append((repo_name, source_revision))
return published

def unexpected_write(*_, **__):
pytest.fail("Release validation must avoid GitHub writes")

monkeypatch.chdir(repo)
monkeypatch.setattr(github_release.release_image, "resolve_digest", resolve_image)
monkeypatch.setattr(github_release, "api", unexpected_write)
monkeypatch.setattr(
sys,
"argv",
[
"github_release.py",
"verify-release-metadata",
"--version",
VERSION,
"--source-sha",
candidate if invalid == "source" else source,
"--assets",
str(assets),
],
)
assert github_release.main() == (1 if error else 0)
stderr = capsys.readouterr().err
if error:
assert error in stderr
else:
assert not stderr
if invalid in (None, "digest", "missing-image"):
assert lookups == [(repository, candidate)]


@pytest.mark.parametrize(
"artifact_change",
[
Expand Down
Loading