Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m0/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,3 @@ The historical samples locate candidates; they are not controlled benchmarks.
- [Release credentials off main](/quest/m0/ci/publish-release-only.md) - `publish` admits only `release` and release tags once its `workflow_run` publishers run on their tag
- [The queue host keeps the queue's disk](/quest/m0/ci/queue-host-disk.md) - agent sessions can't starve the queue runner of disk, and a crashed runner restarts
- [Biome checks every file it can parse](/quest/m0/ci/biome-whole-repo.md) - Biome runs over the whole repository and main is clean under it
- [dispatch.sh's tests pass without KVM](/quest/m0/ci/dispatch-test-kvm.md) - `sh/dispatch-query.test.py` fakes the KVM probe instead of failing 20 tests on hosts without `/dev/kvm`
22 changes: 0 additions & 22 deletions quest/m0/ci/dispatch-test-kvm.md

This file was deleted.

36 changes: 33 additions & 3 deletions sh/dispatch-query.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def setUp(self):
(self.repo / "sh").mkdir(parents=True)
for script in ("dispatch.sh", "changed.sh", "local.sh"):
shutil.copy(ROOT / "sh" / script, self.repo / "sh" / script)
# The stub belongs in the base so it does not widen every test's diff.
(self.repo / "sh/kvm.sh").write_text("#!/bin/sh\nexit 0\n")
self.bin = self.root / "bin"
self.bin.mkdir()
for command in ("bash", "git", "sort", "mktemp", "rm", "grep", "cat", "sed", "tr", "xargs", "sleep"):
Expand Down Expand Up @@ -127,9 +129,12 @@ def test_selected_tests_do_not_depend_on_installed_tools(self):
(self.repo / path).unlink()

def test_orchestration_and_all_select_work(self):
self.expect(True, base="--all")
self.expect(True, base="--all", rust=True)
self.change("justfile")
self.expect(True)
self.expect(True, rust=True)
(self.repo / "justfile").unlink()
self.change("sh/kvm.sh")
self.expect(True, rust=True)

def test_working_tree_changes_and_deletions_count(self):
self.change("rs/moq-net/src/lib.rs")
Expand Down Expand Up @@ -484,7 +489,32 @@ def test_local_flake_probe_errors_are_failures_without_cancelling_other_modules(
self.assertNotIn("nix flake check --print-build-logs", calls)
self.assertIn("gh test", calls)

def test_strict_ci_runs_the_full_flake_without_a_probe(self):
@unittest.skipUnless(sys.platform == "linux" and os.uname().machine == "x86_64", "Linux VM checks only")
def test_missing_kvm_refuses_flake_without_skipping_or_cancelling_other_modules(self):
for strict in (False, True):
with self.subTest(strict=strict):
self.stub_ci()
self.change("flake.nix")
(self.repo / "sh/kvm.sh").write_text("#!/bin/sh\nexit 1\n")
env = dict(self.env)
if not strict:
env.pop("CI_STRICT")
result = subprocess.run(
["bash", "sh/dispatch.sh", "ci" if strict else "check", "origin/main"],
cwd=self.repo,
env=env,
text=True,
capture_output=True,
)
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("/dev/kvm is missing", result.stdout + result.stderr)
self.assertRegex(result.stderr, r"\d+ check flake \(failed\)")
self.assertNotIn("(skipped)", result.stderr)
calls = (self.root / "calls").read_text().splitlines()
self.assertNotIn("nix flake check --print-build-logs", calls)
self.assertIn("gh test", calls)

def test_strict_ci_runs_the_full_flake_without_a_namespace_probe(self):
self.change("flake.nix")
calls = self.run_ci()
self.assertIn("nix flake check --print-build-logs", calls)
Expand Down
4 changes: 2 additions & 2 deletions sh/dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ else

# These files hold the map and the recipes that call it, and match no
# module, so a change to them would otherwise validate none of it.
if grep -qE '^(justfile|sh/(dispatch|changed)\.sh|sh/local\.(sh|ts))$' "$changed"; then
if grep -qE '^(justfile|sh/(dispatch|changed|kvm)\.sh|sh/local\.(sh|ts))$' "$changed"; then
echo "$action: root orchestration changed; running everything." >&2
all=1
fi
Expand Down Expand Up @@ -351,7 +351,7 @@ step() {
# Without KVM, QEMU falls back to emulation and the VM tests time
# out long after. Refuse rather than skip, so a local gate never
# reads as passing without them.
if [[ "$OSTYPE" == linux* && "$HOSTTYPE" == x86_64 && ! -e /dev/kvm ]]; then
if [[ "$OSTYPE" == linux* && "$HOSTTYPE" == x86_64 ]] && ! bash sh/kvm.sh; then
echo "$action: flake's NixOS VM tests need KVM, but /dev/kvm is missing; run them on a KVM host, as CI does" >&2
return 1
fi
Expand Down
3 changes: 3 additions & 0 deletions sh/kvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# Keep the host probe separate so dispatcher fixtures can supply its result.
[[ -e /dev/kvm ]]
Loading