diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index b27f956e8f1..49a0dbec942 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -316,12 +316,6 @@ jobs: ./build_all_docs.sh latest-only else ./build_all_docs.sh - # At release time, we don't want to update the latest docs - rm -rf build/html/latest - # Nor the shared version-switcher file at the docs root: the theme - # fetches it from one URL for every version, and main deploys own it. - # A release built from a branch would overwrite it with a stale list. - rm -f build/html/nv-versions.json build/html/versions.json fi ls -l build popd @@ -346,12 +340,6 @@ jobs: ./build_docs.sh latest-only else ./build_docs.sh - # At release time, we don't want to update the latest docs - rm -rf build/html/latest - # Nor the shared version-switcher file at the docs root: the theme - # fetches it from one URL for every version, and main deploys own it. - # A release built from a branch would overwrite it with a stale list. - rm -f build/html/nv-versions.json build/html/versions.json fi ls -l build popd @@ -363,6 +351,10 @@ jobs: fi mv "${COMPONENT}"/docs/build/html/* "artifacts/docs/${TARGET}" + - name: Remove shared files from release docs + if: ${{ inputs.is-release }} + run: bash .ci-control/ci/tools/remove_shared_release_docs.sh artifacts/docs + # Check links and anchors in the rendered HTML built above. # Links in authored Markdown and reST files are checked separately by the # ordinary Linux/Windows pre-commit jobs. diff --git a/ci/tools/remove_shared_release_docs.sh b/ci/tools/remove_shared_release_docs.sh new file mode 100644 index 00000000000..1d1d015a3e9 --- /dev/null +++ b/ci/tools/remove_shared_release_docs.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +payload=$1 +# The main docs build owns these paths at each component root. +for root in "$payload" "$payload"/cuda-{bindings,core,pathfinder}; do + rm -rf -- "$root/latest" + rm -f -- "$root"/{nv-versions.json,versions.json,objects.inv} +done diff --git a/ci/tools/tests/test_release_docs_payload.py b/ci/tools/tests/test_release_docs_payload.py new file mode 100644 index 00000000000..c121390532a --- /dev/null +++ b/ci/tools/tests/test_release_docs_payload.py @@ -0,0 +1,43 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +import shutil +import subprocess +from pathlib import Path + +import pytest + + +@pytest.mark.parametrize( + "components", + [("cuda-bindings",), ("", "cuda-bindings", "cuda-core", "cuda-pathfinder")], + ids=["bindings", "all"], +) +@pytest.mark.agent_authored(model="GPT-6") +def test_release_docs_preserve_shared_files(tmp_path, components): + payload = tmp_path / "payload" + pages = tmp_path / "pages" + shared = ("objects.inv", "nv-versions.json", "versions.json", "latest/index.html") + versioned = ("12.9.11/objects.inv", "12.9.11/release/12.9.11-notes.html") + + for component in components: + for name in shared: + path = pages / component / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("main", encoding="utf-8") + for name in (*shared, *versioned): + path = payload / component / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("release", encoding="utf-8") + + tool = Path(__file__).resolve().parents[1] / "remove_shared_release_docs.sh" + subprocess.run(["bash", str(tool), str(payload)], check=True) # noqa: S603, S607 + + # Simulate the Pages deploy's overlay of the staged files. + shutil.copytree(payload, pages, dirs_exist_ok=True) + for component in components: + for name in shared: + path = pages / component / name + assert path.read_text(encoding="utf-8") == "main", path.relative_to(pages) + for name in versioned: + assert (pages / component / name).read_text(encoding="utf-8") == "release"