Skip to content

Commit 2e775e1

Browse files
committed
CI: simplify driver hash matrix test and clarify nsenter error message
Signed-off-by: Ralf Juengling <[email protected]>
1 parent 08cba07 commit 2e775e1

2 files changed

Lines changed: 22 additions & 97 deletions

File tree

‎ci/tools/install_gpu_driver.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,10 @@ if [ -z "${_NVDRV_NSENTERED:-}" ] && in_container; then
202202
# ours lives in the GH workspace mount (container-only), so we pipe the
203203
# script body in via stdin instead -- the `< "$0"` fd is opened before
204204
# nsenter and stays valid across the namespace switch. Env vars (DRIVER,
205-
# GPU_TYPE, _NVDRV_NSENTERED) are inherited by the host-side bash.
205+
# DRIVER_SHA256, GPU_TYPE, _NVDRV_NSENTERED) are inherited by the
206+
# host-side bash.
206207
_NVDRV_NSENTERED=1 nsenter -t 1 -m -p -n -i -u -- bash -s < "$0" \
207-
|| { echo "::error::container needs 'options: --privileged --pid=host'" >&2; exit 1; }
208+
|| { echo "::error::host-side driver install failed (see output above; also check container has 'options: --privileged --pid=host')" >&2; exit 1; }
208209
refresh_container_libs
209210

210211
# Re-bind /run/nvidia-persistenced from the host. The container's
Lines changed: 19 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
"""Ensure custom DRIVER entries in ci/test-matrix.yml carry verified SHA-256 hashes."""
4+
"""Ensure custom DRIVER entries in ci/test-matrix.yml carry valid, consistent SHA-256 hashes."""
55

66
from __future__ import annotations
77

@@ -11,104 +11,28 @@
1111
import pytest
1212
import yaml
1313

14-
REPO_ROOT = Path(__file__).resolve().parents[3]
15-
MATRIX_PATH = REPO_ROOT / "ci" / "test-matrix.yml"
14+
MATRIX_PATH = Path(__file__).resolve().parents[2] / "test-matrix.yml"
1615
SHA256_RE = re.compile(r"^[0-9a-f]{64}$")
1716
PREINSTALLED_DRIVERS = {"latest", "earliest"}
18-
WINDOWS_DATA_CENTER_GPUS = {"a100", "h100", "l4", "t4", "v100", "rtxa6000", "rtx6000ada"}
19-
WINDOWS_DESKTOP_GPUS = {"rtx2080", "rtx4090", "rtxpro6000"}
20-
21-
22-
def _load_matrix() -> dict[str, object]:
23-
return yaml.safe_load(MATRIX_PATH.read_text(encoding="utf-8"))
24-
25-
26-
def _iter_rows(matrix: dict[str, object]):
27-
for platform in ("linux", "windows"):
28-
sections = matrix.get(platform, {})
29-
assert isinstance(sections, dict)
30-
for section_name, rows in sections.items():
31-
assert isinstance(rows, list)
32-
for index, row in enumerate(rows):
33-
assert isinstance(row, dict)
34-
yield platform, section_name, index, row
35-
36-
37-
def _installer_identity(platform: str, row: dict[str, object]) -> tuple[str, str, str]:
38-
arch = str(row["ARCH"])
39-
driver = str(row["DRIVER"])
40-
if platform == "linux":
41-
return (platform, arch, driver)
42-
gpu = str(row["GPU"])
43-
if gpu in WINDOWS_DATA_CENTER_GPUS:
44-
variant = "data-center"
45-
elif gpu in WINDOWS_DESKTOP_GPUS:
46-
variant = "desktop"
47-
else:
48-
raise AssertionError(f"Unknown Windows GPU '{gpu}' in ci/test-matrix.yml")
49-
return (f"{platform}-{variant}", arch, driver)
50-
51-
52-
def validate_matrix_driver_hashes(matrix: dict[str, object]) -> None:
53-
seen_hashes: dict[tuple[str, str, str], str] = {}
54-
custom_rows = 0
55-
56-
for platform, section_name, index, row in _iter_rows(matrix):
57-
driver = row.get("DRIVER")
58-
assert isinstance(driver, str) and driver, f"{platform}.{section_name}[{index}] is missing a non-empty DRIVER"
59-
if driver in PREINSTALLED_DRIVERS:
60-
assert "DRIVER_SHA256" not in row, (
61-
f"{platform}.{section_name}[{index}] sets DRIVER={driver!r} and must not set DRIVER_SHA256"
62-
)
63-
continue
64-
65-
custom_rows += 1
66-
sha256 = row.get("DRIVER_SHA256")
67-
assert isinstance(sha256, str) and SHA256_RE.match(sha256), (
68-
f"{platform}.{section_name}[{index}] (DRIVER={driver!r}) must set "
69-
"DRIVER_SHA256 to a 64-character lowercase hex SHA-256 digest"
70-
)
71-
72-
identity = _installer_identity(platform, row)
73-
previous = seen_hashes.setdefault(identity, sha256)
74-
assert sha256 == previous, f"Inconsistent DRIVER_SHA256 for {identity}: {sha256!r} != {previous!r}"
75-
76-
assert custom_rows > 0, "Expected at least one custom DRIVER row in ci/test-matrix.yml"
7717

7818

7919
@pytest.mark.agent_authored(model="gemini-4-argon")
8020
def test_test_matrix_custom_drivers_have_valid_consistent_sha256() -> None:
81-
validate_matrix_driver_hashes(_load_matrix())
82-
83-
84-
@pytest.mark.agent_authored(model="gemini-4-argon")
85-
def test_missing_or_invalid_driver_sha256_is_rejected() -> None:
86-
matrix = _load_matrix()
87-
for _platform, _section_name, _index, row in _iter_rows(matrix):
88-
if row["DRIVER"] not in PREINSTALLED_DRIVERS:
89-
target_row = row
90-
break
91-
else:
92-
pytest.fail("No custom DRIVER row found in ci/test-matrix.yml")
93-
94-
original = target_row.pop("DRIVER_SHA256")
95-
with pytest.raises(AssertionError, match="must set DRIVER_SHA256"):
96-
validate_matrix_driver_hashes(matrix)
97-
98-
target_row["DRIVER_SHA256"] = "UPPERCASE" + ("0" * 55)
99-
with pytest.raises(AssertionError, match="64-character lowercase hex"):
100-
validate_matrix_driver_hashes(matrix)
101-
102-
target_row["DRIVER_SHA256"] = original
103-
104-
105-
@pytest.mark.agent_authored(model="gemini-4-argon")
106-
def test_conflicting_driver_sha256_for_same_installer_is_rejected() -> None:
107-
matrix = _load_matrix()
108-
linux_pr_rows = matrix["linux"]["pull-request"]
109-
custom_rows = [row for row in linux_pr_rows if row["DRIVER"] == "610.43.02"]
110-
assert len(custom_rows) >= 2
21+
matrix = yaml.safe_load(MATRIX_PATH.read_text(encoding="utf-8"))
22+
seen_hashes: dict[tuple[str, str, str, str], str] = {}
23+
custom_rows = 0
11124

112-
custom_rows[1]["DRIVER_SHA256"] = "0" * 64
113-
with pytest.raises(AssertionError, match="Inconsistent DRIVER_SHA256"):
114-
validate_matrix_driver_hashes(matrix)
25+
for platform in ("linux", "windows"):
26+
for section_name, rows in matrix[platform].items():
27+
for index, row in enumerate(rows):
28+
driver = row["DRIVER"]
29+
if driver in PREINSTALLED_DRIVERS:
30+
assert "DRIVER_SHA256" not in row, f"{platform}.{section_name}[{index}] sets DRIVER_SHA256"
31+
continue
32+
custom_rows += 1
33+
sha256 = row.get("DRIVER_SHA256", "")
34+
assert SHA256_RE.match(sha256), f"{platform}.{section_name}[{index}] has invalid DRIVER_SHA256"
35+
key = (platform, str(row["ARCH"]), str(row["GPU"]), str(driver))
36+
assert seen_hashes.setdefault(key, sha256) == sha256, f"Conflicting DRIVER_SHA256 for {key}"
37+
38+
assert custom_rows > 0

0 commit comments

Comments
 (0)