mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
* ci(os-image): build FDE and non-FDE images in parallel on ARC KVM runners Move the amd64 bake to the new arc-amd64-kvm scale set and add a variant axis to the build matrix, so every (arch, Ubuntu flavor, variant) builds in its own job instead of one job baking FDE then non-FDE back to back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> * test(os-image): follow the one-image-per-job workflow in the static checks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> * test(os-image): stop the wrong-TPM FDE check at the LUKS prompt The moved-to-different-tpm-fails scenario waited out the full 360s BOOT_TIMEOUT for SSH that never comes, making it ~6 of the ~8 minutes demo-fde.sh adds to every FDE job. Watch the serial console instead: pass once the guest has sat at cryptroot's passphrase prompt for LOCKED_GRACE seconds, fail if it reaches systemd in the real root or SSH. The old timeout pass stays as a fallback if the prompt never shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): restore installer ISOs from the S3 build cache The four Ubuntu installer ISOs are 2 to 3 GiB each, too large together for the 10 GiB GitHub cache, and arm64's comes from cdimage.ubuntu.com at a couple of MB/s. The bake now assumes the cache's read role, installs a pinned s5cmd, and restores the ISO into os-image/packer/iso-cache/ before Packer runs. prepare-installer-iso.sh still checks it against Ubuntu's SHA256SUMS, so the cache cannot change what gets baked. Every cache step is best-effort: a miss or an AWS failure falls back to Ubuntu's mirror. os-image-cache.yml is the only writer. It runs on main (push, weekly, and dispatch), because the write role trusts only refs/heads/main. It refreshes any object older than two weeks, so nothing reaches the bucket's 30-day expiry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(os-image): check the wrong-TPM grace against a real unlock moved-to-different-tpm-fails passes once the guest has sat at the LUKS prompt for LOCKED_GRACE seconds. A Clevis unlock that arrived later than that would read as a pass. The same-TPM boot that follows now goes through wait_locked too, so a genuine unlock that takes longer than the grace fails the run and says the wrong-TPM result proves nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): name the build cache bucket and roles in the workflows A bucket name and role ARNs are not secrets, and keeping them in the workflow's env leaves them in review and history rather than in repository settings. The bake no longer needs a gate for unset variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): report how fast the ISO came back from the build cache Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): run each build on arc-<arch>-kvm with a 90-minute budget Both arches now use the same runner pattern and timeout, so the matrix no longer carries them per arch. One variant per job takes 14 to 27 minutes on a warm ISO cache, and a cold arm64 ISO adds about 25, so 180 minutes only kept a hung bake on a bare-metal KVM runner for three hours. Drops the comments that still described one job baking FDE then non-FDE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> * ci(os-image): stop calling every failed cache restore a miss s5cmd also fails on a 403 or a network error, and the notice said the ISO was not in the cache for all of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> * test(os-image): pass the wrong-TPM check only on a held LUKS prompt A boot that never reached the passphrase prompt still passed moved-to-different-tpm-fails, so a dead QEMU or a firmware hang read as a sealed disk. Only "locked" passes now. wait_locked also reports a QEMU that exited or a kernel panic instead of waiting out BOOT_TIMEOUT. LOCKED_GRACE defaults to 300s under tcg, as the same-TPM control fails if an unlock takes longer than the grace after the prompt. stop_vm now reaps QEMU so the next boot can bind SSH_PORT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> * fix(ci): avoid org ID matches inside checksums Match standalone sixteen-digit tokens instead of numeric substrings in hexadecimal hashes. Exercise the real scanner with checksum, org ID, token-boundary, and placeholder fixtures whenever internal-config-check runs. Co-Authored-By: Codex <noreply@openai.com> Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> * fix(ci): skip pinned checksum lines instead of widening the org id match Restore the digit-only boundaries on the sixteen-digit org id shape, so an id glued to a letter or underscore fails the gate again, and skip *_SHA256* make variable lines instead. The test uses a synthetic checksum and a GIT_*-free environment rather than reading make/tool-versions.mk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): resume the cache refresh download after a reset Match prepare-installer-iso.sh: curl -C - resumes rather than restarting the 2.9 GB arm64 ISO, and only the first SHA256SUMS entry is taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(os-image): tighten what counts as locked or unlocked in the FDE check Match systemd's 'Welcome to Ubuntu' banner rather than any 'Welcome to', which GRUB also prints, and report an initramfs ALERT shell as inconclusive instead of locked. --help prints the whole header comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(os-image): say both architectures build on the ARC KVM runners Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): read the build cache bucket and roles from repository variables This reverts the hardcoding from earlier in this branch, so the account ID, bucket and role ARNs stay out of the public tree, as the S3 publish workflows already do. An unset read role skips the cache rather than assuming ambient credentials. The read role's credentials are now passed to the restore step only instead of being exported to the whole build, and the annotations name the object, not the bucket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): run the os-image tests once per run, not in every build make test and make -C packer test move to validate-packer on ubuntu-latest. The eight bare-metal KVM builds only build nke-os-image-check, which the release assets need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(os-image): pin the build matrix and the per-variant step guards Run the matrix step's own script and check it yields each arch, Ubuntu flavor and variant exactly once, and check every bake and check step is gated on its variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(os-image): bound the wait for qemu to exit in demo-fde.sh Give qemu 30s after SIGTERM, then SIGKILL, so one stuck on shutdown cannot hang the job until its timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ci): tell org ids from hex digests by their hex neighbours Replace the *_SHA256* line skip with hex-digit boundaries. A digest's sixteen-digit run always borders hex, however it is written (export, YAML, JSON, upper case), while an id next to an underscore or a non-hex letter still fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(os-image): see systemd's coloured banner in the wrong-TPM check systemd colours the OS name, so an escape sequence sits between 'Welcome to ' and 'Ubuntu' and the previous match never fired, leaving SSH as the only unlocked signal. Match across it. The doc comment now describes what wait_locked checks, and stop_vm only sends SIGKILL to a qemu still running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): actually resume the cache refresh download curl's --retry truncates back to where the transfer started, so -C - under it never resumed. Retry in a loop that resumes from what the last attempt wrote, and fail before the download if the bucket variable is unset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(os-image): build nke-os-image-check only where the release uses it Only the amd64 default-flavor non-FDE build ships the binary. Also say plainly that id-token: write stays job-wide, so the credential scoping is limited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(os-image): pin each build's tag suffix and time budget Compare whole matrix entries, not just their (arch, release, variant) tuple. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Signed-off-by: Cullen McDermott <9535761+cullenmcdermott@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Codex <noreply@openai.com>
72 lines
2.6 KiB
Python
72 lines
2.6 KiB
Python
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""Exercise internal identifier detection against isolated repository fixtures."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
SCRIPT = Path(__file__).with_name("internal-config-check.sh")
|
|
ORG_ID = "12345678" + "90123456"
|
|
# 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 InternalConfigCheckTest(unittest.TestCase):
|
|
def scan(self, content):
|
|
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()
|
|
script = root / "hack" / SCRIPT.name
|
|
shutil.copyfile(SCRIPT, script)
|
|
(root / "fixture.txt").write_text(content, encoding="utf-8")
|
|
return subprocess.run(
|
|
["bash", str(script)], capture_output=True, text=True, check=False, env=ENV
|
|
)
|
|
|
|
def test_hex_digest_is_not_an_org_id(self):
|
|
checksum = f"de0f{ORG_ID}" + "ab" * 22
|
|
for content in (
|
|
f"TOOL_SHA256_AMD64 ?= {checksum}",
|
|
f"export TOOL_SHA256={checksum}",
|
|
f'sha256: "{checksum.upper()}"',
|
|
f'{{"digest": "sha256:{checksum}"}}',
|
|
):
|
|
with self.subTest(content=content):
|
|
result = self.scan(content)
|
|
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
|
|
|
def test_org_ids_are_rejected_without_printing_values(self):
|
|
for content in (
|
|
ORG_ID,
|
|
f'org: "{ORG_ID}"',
|
|
f"org={ORG_ID}, next",
|
|
f"org_{ORG_ID}",
|
|
f"ORG{ORG_ID}x",
|
|
f"sha256 of {ORG_ID}",
|
|
):
|
|
with self.subTest(content=content):
|
|
result = self.scan(content)
|
|
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
|
|
self.assertIn("sixteen-digit NGC or Forge org id", result.stdout)
|
|
self.assertNotIn(ORG_ID, result.stdout + result.stderr)
|
|
|
|
def test_longer_digit_runs_and_placeholder_pass(self):
|
|
for content in (f"9{ORG_ID}9", "0" * 16):
|
|
with self.subTest(content=content):
|
|
result = self.scan(content)
|
|
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|