test(ci): preserve coverage gate with pinned bootstrap snapshots
Linux / verify (pull_request) Successful in 3m20s
Linux / changed-scope-coverage (pull_request) Skipped
Linux / keyless-cuda (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-cli-container (pull_request) Successful in 2m4s
Linux / linux-static-cli (pull_request) Successful in 9m16s
Linux / release-cli (pull_request) Skipped

This commit is contained in:
Pavlo Ratushnyi
2026-10-08 09:07:47 +02:00
parent ac070fe2fa
commit 0b33cdeb77
+30 -1
View File
@@ -10,7 +10,9 @@ import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
EXISTING_JOBS_SHA256 = "26cf64e51e207b9f81cef306e4ec31f3ed817334699e0b0fe7c7a031cb848a25"
# Reviewed snapshots from frozen infrastructure commit ac070fe2fa8bf0db9aa4f5fe627736c465e6e3e1.
EXISTING_JOBS_SHA256 = "4072554cb17e5afc49aba44a1ecbb5b71fa2d0bbf417512a432e3d519f16496b"
COVERAGE_JOB_SHA256 = "131cd1dc20e77f509137bf5db596466405899d6ed06c702869c46d72b79f38ea"
PUSH_PULL_SHA256 = "cefb2858cd9b21076e171fa764dbf2df1472b911cc0743caa6fac7d09a216c89"
SPEC = importlib.util.spec_from_file_location("changed_scope", ROOT / "scripts/check-changed-scope-coverage.py")
COVERAGE = importlib.util.module_from_spec(SPEC)
@@ -145,6 +147,9 @@ pub fn with_test_only_block() {
current = (ROOT / ".github/workflows/linux.yml").read_text()
original = subprocess.run(["git", "show", "HEAD:.github/workflows/linux.yml"],
cwd=ROOT, capture_output=True, text=True, check=True).stdout
self._assert_workflow_contract(current, original)
def _assert_workflow_contract(self, current: str, original: str) -> None:
job_names = ("verify", "keyless-cuda", "hosted-cuda-package", "linux-static-cli",
"linux-cli-container", "release-cli")
self.assertEqual(_digest("".join(_job_block(current, name) for name in job_names)),
@@ -156,6 +161,7 @@ pub fn with_test_only_block() {
self.assertIn("changed_scope_coverage:\n description:", current)
self.assertIn("type: boolean\n default: false", current)
job = _job_block(current, "changed-scope-coverage")
self.assertEqual(_digest(job), COVERAGE_JOB_SHA256)
self.assertIn("needs: verify", job)
self.assertIn("runs-on: ubuntu-latest", job)
self.assertNotIn("self-hosted", job)
@@ -166,6 +172,29 @@ pub fn with_test_only_block() {
self.assertNotIn("actions/upload-artifact", job)
self.assertNotIn("download-artifact", job)
def test_workflow_rejects_restored_unchecked_installer_in_every_bootstrap_job(self) -> None:
current = (ROOT / ".github/workflows/linux.yml").read_text()
self._assert_workflow_contract(current, current)
unchecked_bootstrap = (
" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs "
"| sh -s -- -y --profile minimal --default-toolchain none\n"
' echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"\n'
' export PATH="$HOME/.cargo/bin:$PATH"\n'
" "
)
for name in ("verify", "changed-scope-coverage", "hosted-cuda-package",
"linux-static-cli", "release-cli"):
with self.subTest(job=name):
block = _job_block(current, name)
self.assertEqual(block.count(" scripts/install-pinned-rustup.sh "), 1)
restored = block.replace(" scripts/install-pinned-rustup.sh ",
unchecked_bootstrap, 1)
mutated = current.replace(block, restored, 1)
# Matching HEAD cannot rescue a committed insecure bootstrap: the fixed
# reviewed snapshots must refuse it independently of that comparison.
with self.assertRaises(AssertionError):
self._assert_workflow_contract(mutated, mutated)
def _digest(value: str) -> str:
import hashlib