Files
nvke/hack/test_removed_settings_check.py
Alex Pelavin b594eaf4b7 ci: deprecate GitHub releases for subcomponents (#2112)
* ci: stop creating GitHub releases and remove the changelog

Publishing to GHCR, NVCR, S3 and the apt intake is unchanged. release.yml
now only builds nvkectl for the cli publishers. The agent, NKTP and os-image
release-page jobs, their checksums and attestations, verify-release-assets,
malware-backfill.yml, CHANGELOG.md and cliff.toml are removed, and the docs
no longer point at release downloads.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: remove what the GitHub release removal orphaned

ORAS_SHA256_AMD64 was read only by malware-backfill.yml, and os-image's
agent_version step output only fed the release body. Two comments still
described release-page behavior.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: rename release.yml to tag-publish.yml

It no longer creates releases. It gates every tag on the license checks,
builds nvkectl for the cli publishers and records which workflow
publishes each component tag.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: drop the CHANGELOG.md exclusion from removed-settings-check

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

#2114 added the check while CHANGELOG.md still existed. It no longer does.

* docs: correct publication destinations, fork-tag behavior and stale download notes

- os-image tags put only the qcow2s on NVCR; the SBOMs, checksums and the
  checker go to S3.
- A fork tag publishes nothing: every publisher checks the repository ID.
- The custom-base-os cloud-init example does not install nvkectl.
- SECURITY.md and plan-installation.md still described GitHub release
  checksums and release pages.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

---------

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>
2026-11-05 09:02:56 -08:00

80 lines
3.5 KiB
Python

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Exercise the removed-settings scan against isolated repository fixtures."""
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
SCRIPT = Path(__file__).with_name("removed-settings-check.py")
# A hook can export GIT_DIR and friends, which would point git at the outer
# repository instead of the fixture.
ENV = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
class RemovedSettingsCheckTest(unittest.TestCase):
def run_check(self, files):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
subprocess.run(["git", "init", "--quiet", str(root)], check=True, capture_output=True, env=ENV)
(root / "hack").mkdir()
shutil.copyfile(SCRIPT, root / "hack" / SCRIPT.name)
for name, content in files.items():
path = root / name
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(content, encoding="utf-8")
subprocess.run(["git", "-C", str(root), "add", "-A"], check=True, capture_output=True, env=ENV)
return subprocess.run(
["python3", "-B", f"hack/{SCRIPT.name}"], cwd=root, capture_output=True, text=True, check=False, env=ENV,
)
def test_removed_names_fail(self):
for line in (
'port := os.Getenv("CWE_HTTP_PORT")',
"NVKE_CONTROLLER_HTTP_PORT=${NVKE_CONTROLLER_HTTP_PORT:-${NKE_CONTROLLER_HTTP_PORT:-8080}}",
"image: ${{ vars.CWE_NAMESPACE }}",
"CWE_IMAGE ?= controller:latest",
"export NKE_CONTROLLER_GOFAIL_E2E_WORKER_BINARY=bin/worker",
"prefix = \"NKE_CONTROLLER_GOFAIL_E2E_\"",
'cfg.get("cwe_image", "")',
"LOCAL_CWE_IMAGE=controller:dev make test-e2e-capd-local",
"--cwe-api) API=$2 ;;",
" cwe-name:",
'export CWE_API="http://localhost:8080/api"',
):
with self.subTest(line=line):
result = self.run_check({"fixture.sh": line + "\n"})
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
self.assertIn("fixture.sh:1:", result.stdout)
def test_current_names_pass(self):
result = self.run_check({"fixture.sh": "\n".join((
"NVKE_CONTROLLER_HTTP_PORT=${NVKE_CONTROLLER_HTTP_PORT:-8080}",
"CONTROLLER_IMAGE ?= controller:latest",
"LOCAL_NVKE_CONTROLLER_IMAGE=controller:dev",
'cfg.get("nvke_controller_image", "")',
"--controller-api) API=$2 ;;",
" controller-name:",
"--cwe-api-url) URL=$2 ;;",
"LOCAL_CWE_IMAGE_TAG=x MY_CWE_IMAGE=y CWE_IMAGES=z",
"See CWE-79 and CWE_79.",
)) + "\n"})
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("removed-settings-check: clean", result.stdout)
def test_allowed_token_passes_only_in_its_file(self):
line = 'CWE_API_URL="${2%/}"\n'
allowed = self.run_check({"controller/scripts/cwe-to-platform-crs.sh": line})
self.assertEqual(allowed.returncode, 0, allowed.stdout + allowed.stderr)
elsewhere = self.run_check({"controller/scripts/other.sh": line})
self.assertEqual(elsewhere.returncode, 1, elsewhere.stdout + elsewhere.stderr)
if __name__ == "__main__":
unittest.main()