Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

CI: new-computer test on every release (O9, draft) (#418)

Oleksandr Ivanchenkoc0159fbe3d58
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 46a84939..45a0575f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -58,6 +58,42 @@ jobs:
- name: Script tests
run: python3 -m unittest discover -s scripts -p 'test_*.py'
+ # O9, the new-computer test on every release: kwnt starts as a brand-new user (empty HOME, `env -i`, a bare PATH
+ # with no AI tools), and the job checks that the Get started card shows, that the one-click Claude Code install
+ # starts and finishes against a stand-in download (the real one is never fetched: the fake curl refuses every
+ # other URL), and that the sign-in starts. scripts/release_required_checks.txt lists it, so the release gate
+ # (the release script reads that list) refuses a release commit where this job isn't green.
+ # The first screen it checks is the Get started card ("Choose your AI", the Claude tile), found by CARD in
+ # scripts/fresh_machine_test.py.
+ fresh-machine:
+ name: fresh-machine
+ runs-on: ubuntu-latest
+ needs: frontend
+ timeout-minutes: 40
+ steps:
+ - uses: actions/checkout@v4
+ # The binary embeds frontend/dist, so the Rust build needs it
+ - uses: actions/download-artifact@v4
+ with:
+ name: frontend-dist
+ path: frontend/dist
+ - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
+ - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
+ with:
+ key: fresh-machine
+ - name: Build kwnt
+ run: cargo build --locked --bin kwnt
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ # Only the driver: the page check uses the runner's own Chrome, no browser download
+ - name: Browser driver
+ run: npm install --no-save --no-audit --no-fund --prefix "$RUNNER_TEMP/pw" playwright-core
+ - name: New computer (empty HOME, bare PATH, no AI tools, stand-in download)
+ env:
+ PW_CORE: ${{ runner.temp }}/pw/node_modules/playwright-core/index.mjs
+ run: python3 scripts/fresh_machine_test.py --kwnt target/debug/kwnt --browser "$(command -v google-chrome || command -v chromium)"
+
rust:
name: rust
runs-on: ubuntu-latest
diff --git a/scripts/fresh_machine_page.mjs b/scripts/fresh_machine_page.mjs
new file mode 100644
index 00000000..9b68cb43
--- /dev/null
+++ b/scripts/fresh_machine_page.mjs
@@ -0,0 +1,46 @@
+// Opens kwnt's first screen in a headless browser and prints what the Get started card and one of its AI tiles show, as JSON:
+// {"found": true, "text": "<the card's visible text>", "tile": true, "tileText": "<the tile's visible text>"}
+// (found/tile: false after the wait, text/tileText: "")
+// node scripts/fresh_machine_page.mjs <url> <css selector of the card> <css selector of the tile> [text the tile should come to show]
+// The card renders before kwnt's engine list arrives, and a tile only says "Installed" or "Signed in" once it has. So this
+// always waits for the page's own GET /api/engines answer (and a moment for React to paint it) before reading, which makes
+// "the tile doesn't say Installed" mean something. With a fourth argument it also waits (up to 25 s) until the tile's
+// text contains it; the text printed is whatever the tile shows at the end.
+// Needs playwright-core (PW_CORE=/path/to/playwright-core/index.mjs; default: the package) and a Chromium or Chrome (CHROMIUM=...).
+// Used by scripts/fresh_machine_test.py. The page keeps live connections open, so a plain "dump the DOM" never finishes.
+const { chromium } = await import(process.env.PW_CORE || 'playwright-core');
+const [url, cardSel, tileSel, expect] = process.argv.slice(2);
+const browser = await chromium.launch({
+ executablePath: process.env.CHROMIUM || undefined,
+ args: ['--no-sandbox', '--disable-dev-shm-usage', '--disable-gpu'],
+});
+const squash = (s) => s.replace(/\s+/g, ' ').trim();
+let out = { found: false, text: '', tile: false, tileText: '' };
+try {
+ const page = await (await browser.newContext({ viewport: { width: 1280, height: 900 } })).newPage();
+ const engines = page
+ .waitForResponse((r) => new URL(r.url()).pathname === '/api/engines' && r.request().method() === 'GET' && r.ok(), { timeout: 30000 })
+ .catch(() => null);
+ await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
+ try {
+ const card = page.locator(cardSel).first();
+ await card.waitFor({ timeout: 25000 });
+ out.found = true;
+ if (await engines) await page.waitForTimeout(750);
+ const tile = card.locator(tileSel).first();
+ try {
+ await tile.waitFor({ timeout: 10000 });
+ if (expect) await tile.filter({ hasText: expect }).waitFor({ timeout: 25000 }).catch(() => {});
+ out.tile = true;
+ out.tileText = squash(await tile.innerText());
+ } catch {
+ /* no such tile */
+ }
+ out.text = squash(await card.innerText());
+ } catch {
+ /* no card */
+ }
+} finally {
+ await browser.close();
+}
+console.log(JSON.stringify(out));
diff --git a/scripts/fresh_machine_test.py b/scripts/fresh_machine_test.py
new file mode 100644
index 00000000..654b3e05
--- /dev/null
+++ b/scripts/fresh_machine_test.py
@@ -0,0 +1,309 @@
+#!/usr/bin/env python3
+"""O9: the new-computer test. Starts kwnt as a brand-new user and checks the first minutes.
+
+The "new computer" is made like this:
+ * HOME and the data folder are empty temp folders.
+ * kwnt runs with `env -i` (nothing from the runner leaks in) and a bare PATH: a folder of symlinks to the few
+ system tools an installer needs (sh, bash, cat, ...), plus a stand-in `curl`. No claude, codex, grok, node,
+ npm, brew, apt, docker.
+ * The one-click install runs for real (kwnt's own `/api/setup/install`), but the download is a stand-in: the
+ fake curl serves a local install.sh for https://claude.ai/install.sh and REFUSES every other URL. The real
+ download is never made. The installer drops a fake `claude` into ~/.local/bin that is signed out and prints a
+ sign-in link when asked to log in.
+
+Checks (each prints PASS or FAIL):
+ 1. the machine is really new: no AI tool is installed, and the Setup list offers to install Claude;
+ 2. the Get started card shows (a headless Chromium opens the page, scripts/fresh_machine_page.mjs) at "Choose your AI",
+ with a Claude tile that says neither "Installed" nor "Signed in";
+ 3. the one-click install starts, finishes, ran only the stand-in download, and kwnt then sees Claude (signed out);
+ on a fresh page load the Claude tile says "Installed · sign in next";
+ 4. the sign-in starts: kwnt asks for a link and returns an allowed claude.ai/claude.com link in the
+ waiting-for-code state (the sign-in is then cancelled).
+
+Usage:
+ python3 scripts/fresh_machine_test.py --kwnt target/debug/kwnt [--browser /usr/bin/chromium] [--keep]
+Exit 0 when every check passes. Needs frontend/dist embedded in the kwnt binary (the CI job builds it first), node, and playwright-core
+(PW_CORE=/path/to/playwright-core/index.mjs, or `npm i playwright-core` somewhere node finds it).
+What it cannot tell you: that claude.ai's real install.sh still works (the stand-in replaces it), that Laya installs
+(`serve --no-laya`: 420 MB), or what a person sees in the Tauri window (it loads the same page this test opens).
+
+The page checks look for Iris's "Get started" card (O2, 0.7.6; GetStarted.tsx), set in CARD below.
+"""
+import argparse
+import json
+import os
+import re
+import shutil
+import socket
+import subprocess
+import sys
+import tempfile
+import time
+import urllib.error
+import urllib.request
+from pathlib import Path
+
+# ---- What the checks look for in the first screen: the Get started card (GetStarted.tsx). ----
+CARD = {
+ # CSS selector of the first-run card (GetStarted.tsx's <section data-get-started>)
+ "selector": "[data-get-started]",
+ # its first step's title, shown while no AI is chosen yet
+ "step_label": "Choose your AI",
+ # the Claude tile inside step 1 (one <button data-ai-tile=...> per AI)
+ "tile": '[data-ai-tile="claude"]',
+ # what a tile must not say on a new machine (Claude isn't installed, nobody is signed in)
+ "not_yet": ("Installed", "Signed in"),
+ # what the Claude tile says once Claude Code is installed but signed out
+ "installed_label": "Installed · sign in next",
+}
+# ------------------------------------------------------------------------------------------------------------
+
+FORBIDDEN_PORTS = {8799, 8800, 8810, 8852, 8931}
+# system tools the stand-in installer and kwnt's own checks use, linked into the bare PATH
+SYSTEM_TOOLS = ["sh", "bash", "cat", "mkdir", "chmod", "sleep", "which", "env", "uname", "dirname", "rm", "cp", "mv", "ls"]
+INSTALL_URL = "https://claude.ai/install.sh"
+ALLOWED_LOGIN_HOSTS = ("claude.ai", "claude.com")
+
+results = []
+
+
+def check(name, ok, detail=""):
+ results.append((name, ok))
+ print(f"{'PASS' if ok else 'FAIL'} {name}" + (f" ({detail})" if detail and not ok else ""), flush=True)
+ return ok
+
+
+def free_port():
+ while True:
+ s = socket.socket()
+ s.bind(("127.0.0.1", 0))
+ port = s.getsockname()[1]
+ s.close()
+ if port not in FORBIDDEN_PORTS:
+ return port
+
+
+def http(base, method, path, body=None, timeout=20):
+ data = json.dumps(body).encode() if body is not None else None
+ req = urllib.request.Request(base + path, data=data, method=method, headers={"Content-Type": "application/json"})
+ try:
+ with urllib.request.urlopen(req, timeout=timeout) as r:
+ raw = r.read()
+ return r.status, (json.loads(raw) if raw[:1] in (b"{", b"[") else raw.decode(errors="replace"))
+ except urllib.error.HTTPError as e:
+ raw = e.read()
+ try:
+ return e.code, json.loads(raw)
+ except ValueError:
+ return e.code, raw.decode(errors="replace")
+
+
+def wait_for(fn, what, seconds):
+ end = time.time() + seconds
+ last = None
+ while time.time() < end:
+ try:
+ last = fn()
+ except Exception as e: # noqa: BLE001 (server still starting)
+ last = e
+ if last and not isinstance(last, Exception):
+ return last
+ time.sleep(0.5)
+ raise TimeoutError(f"timed out after {seconds}s: {what} (last: {last})")
+
+
+def make_machine(root: Path):
+ """The empty home, the bare PATH and the stand-in download."""
+ home, binp, standin, data = root / "home", root / "bin", root / "standin", root / "data"
+ for d in (home, binp, standin, data):
+ d.mkdir(parents=True)
+ for tool in SYSTEM_TOOLS:
+ src = shutil.which(tool)
+ if src:
+ (binp / tool).symlink_to(src)
+ curl_log = root / "curl.log"
+ (standin / "install.sh").write_text(
+ """#!/bin/bash
+set -eu
+echo "stand-in Claude Code installer (fresh-machine test, not the real download)"
+mkdir -p "$HOME/.local/bin"
+cat > "$HOME/.local/bin/claude" <<'CLAUDE'
+#!/bin/sh
+# stand-in Claude Code: signed out; "auth login" prints a link and waits for a code
+case "$1" in
+ --version) echo "2.0.0 (Claude Code)" ;;
+ auth)
+ case "$2" in
+ status) echo '{"loggedIn":false}' ;;
+ login)
+ echo "Opening your browser to sign in..."
+ echo "If it didn't open, visit: https://claude.com/cai/oauth/authorize?code=true&client_id=fresh-machine-test"
+ sleep 60 ;;
+ *) exit 0 ;;
+ esac ;;
+ *) exit 0 ;;
+esac
+CLAUDE
+chmod 755 "$HOME/.local/bin/claude"
+echo "installed claude into $HOME/.local/bin"
+"""
+ )
+ # The stand-in curl: the installer URL gets the local file, anything else is refused (and logged).
+ (binp / "curl").write_text(
+ f"""#!/bin/sh
+for a in "$@"; do url="$a"; done
+echo "$url" >> "{curl_log}"
+if [ "$url" = "{INSTALL_URL}" ]; then cat "{standin}/install.sh"; exit 0; fi
+echo "fresh-machine test: refused to download $url" >&2
+exit 22
+"""
+ )
+ (binp / "curl").chmod(0o755)
+ return home, binp, data, curl_log
+
+
+def first_card(browser, url, expect=None):
+ """{"found": bool, "text": str, "tile": bool, "tileText": str}: the Get started card and its Claude tile,
+ read after the page's engine list arrived."""
+ helper = Path(__file__).with_name("fresh_machine_page.mjs")
+ env = {"HOME": tempfile.gettempdir(), "PATH": os.environ.get("PATH", "/usr/bin:/bin"), "CHROMIUM": browser}
+ if os.environ.get("PW_CORE"):
+ env["PW_CORE"] = os.environ["PW_CORE"]
+ out = subprocess.run(["node", str(helper), url, CARD["selector"], CARD["tile"], *([expect] if expect else [])],
+ capture_output=True, text=True, timeout=120, env=env)
+ try:
+ return json.loads(out.stdout.strip().splitlines()[-1])
+ except (ValueError, IndexError):
+ return {"found": False, "text": "", "error": (out.stderr or out.stdout)[-300:]}
+
+
+def find_browser(explicit):
+ for cand in [explicit, os.environ.get("CHROMIUM"), "google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]:
+ if cand and (shutil.which(cand) or Path(cand).is_file()):
+ return shutil.which(cand) or cand
+ return None
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("--kwnt", required=True, help="path to the kwnt binary (with the web UI embedded)")
+ ap.add_argument("--browser", help="Chromium or Chrome (default: CHROMIUM, google-chrome, chromium)")
+ ap.add_argument("--port", type=int, help="port to serve on (default: a free one)")
+ ap.add_argument("--keep", action="store_true", help="keep the temp folder and print its path")
+ args = ap.parse_args()
+
+ kwnt = Path(args.kwnt).resolve()
+ if not kwnt.is_file():
+ sys.exit(f"no kwnt binary at {kwnt}")
+ browser = find_browser(args.browser)
+ if not browser:
+ sys.exit("no Chromium or Chrome found (use --browser or CHROMIUM)")
+ port = args.port or free_port()
+ if port in FORBIDDEN_PORTS:
+ sys.exit(f"port {port} is reserved")
+
+ root = Path(tempfile.mkdtemp(prefix="fresh-machine-"))
+ home, binp, data, curl_log = make_machine(root)
+ log = root / "kwnt.log"
+ base = f"http://127.0.0.1:{port}"
+ # `env -i`: only these variables exist for kwnt
+ env = {"HOME": str(home), "PATH": str(binp), "KWNT_DATA_DIR": str(data), "KWNT_HOST": "127.0.0.1", "KWNT_PORT": str(port)}
+ proc = subprocess.Popen([str(kwnt), "serve", "--no-laya"], env=env, stdout=open(log, "w"), stderr=subprocess.STDOUT, cwd=str(root))
+ try:
+ try:
+ wait_for(lambda: http(base, "GET", "/api/health")[0] == 200, "kwnt to answer /api/health", 60)
+ except TimeoutError as e:
+ check("kwnt starts on an empty HOME", False, str(e))
+ return finish(root, log, proc, args.keep)
+ check("kwnt starts on an empty HOME", True)
+
+ # 1. A really new machine
+ code, status = http(base, "GET", "/api/setup/status")
+ items = {i["id"]: i for i in status["items"]} if code == 200 and isinstance(status, dict) else {}
+ none_installed = bool(items) and all(items[k].get("state") != "ready" for k in ("claude", "codex", "grok") if k in items)
+ check("new machine: no AI tool is installed", none_installed, f"setup status {code}: {json.dumps(items.get('claude'))[:200]}")
+ check("new machine: Setup offers to install Claude Code by itself", items.get("claude", {}).get("can_install") is True,
+ json.dumps(items.get("claude"))[:300])
+
+ # 2. First screen: the Get started card
+ card = first_card(browser, base + "/")
+ check(f"first run: the Get started card shows ({CARD['selector']})", card["found"], card.get("error", ""))
+ check(f"first run: the card is at \"{CARD['step_label']}\"", CARD["step_label"] in card["text"], card["text"][:200])
+ check(f"first run: the Claude tile is there ({CARD['tile']})", card.get("tile") is True, card["text"][:200])
+ check("first run: the Claude tile says neither \"Installed\" nor \"Signed in\"",
+ card.get("tile") is True and not any(w in card["tileText"] for w in CARD["not_yet"]), card.get("tileText", ""))
+
+ # 3. One-click install against the stand-in download
+ code, started = http(base, "POST", "/api/setup/install", {"item": "claude"})
+ ok_start = code == 202 and isinstance(started, dict) and started.get("job_id")
+ check("install: the one-click install starts (202 with a job)", bool(ok_start), f"{code} {started}")
+ if ok_start:
+ job_id, lines, after, job = started["job_id"], [], 0, {}
+ try:
+ def poll():
+ nonlocal after, job
+ c, j = http(base, "GET", f"/api/setup/jobs/{job_id}?after={after}")
+ if c != 200:
+ return None
+ lines.extend(j.get("lines", []))
+ after, job = j["next"], j
+ return j["state"] in ("done", "failed")
+ wait_for(poll, "the install job to finish", 120)
+ except TimeoutError as e:
+ check("install: it finishes", False, str(e))
+ else:
+ check("install: it finishes without an error", job.get("state") == "done", f"{job.get('state')}: {job.get('error')} | {' / '.join(lines[-4:])}")
+ requested = curl_log.read_text().split() if curl_log.exists() else []
+ check("install: only the stand-in download ran (no other URL was asked for)", requested == [INSTALL_URL], f"asked for: {requested}")
+ claude_bin = home / ".local" / "bin" / "claude"
+ check("install: Claude Code landed in ~/.local/bin", claude_bin.is_file() and os.access(claude_bin, os.X_OK))
+ code, engines = http(base, "GET", "/api/engines")
+ eng = {e.get("id"): e for e in engines} if code == 200 and isinstance(engines, list) else \
+ {e.get("id"): e for e in (engines.get("engines", []) if isinstance(engines, dict) else [])}
+ claude_state = (eng.get("claude") or {}).get("status")
+ check("install: kwnt sees Claude Code at once, signed out", claude_state == "signed_out", f"engine claude = {json.dumps(eng.get('claude'))[:200]}")
+ card = first_card(browser, base + "/", CARD["installed_label"])
+ check(f"install: on a fresh page load the Claude tile says \"{CARD['installed_label']}\"",
+ CARD["installed_label"] in card.get("tileText", ""), card.get("tileText") or card["text"][:200])
+
+ # 4. The sign-in starts
+ code, sess = http(base, "POST", "/api/engines/claude/login")
+ sid = sess.get("session_id") if isinstance(sess, dict) else None
+ check("sign-in: it starts (a session comes back)", code == 200 and bool(sid), f"{code} {sess}")
+ if sid:
+ def link():
+ c, s = http(base, "GET", f"/api/engines/claude/login/{sid}")
+ return s if c == 200 and s.get("state") == "waiting_for_code" and s.get("url") else None
+ try:
+ s = wait_for(link, "the sign-in link", 30)
+ host = re.match(r"https://([^/:]+)/", s["url"])
+ check("sign-in: kwnt shows the sign-in link and waits for the code",
+ bool(host) and host.group(1) in ALLOWED_LOGIN_HOSTS, s["url"])
+ except TimeoutError as e:
+ check("sign-in: kwnt shows the sign-in link and waits for the code", False, str(e))
+ http(base, "DELETE", f"/api/engines/claude/login/{sid}")
+ finally:
+ pass
+ return finish(root, log, proc, args.keep)
+
+
+def finish(root, log, proc, keep):
+ proc.terminate()
+ try:
+ proc.wait(10)
+ except subprocess.TimeoutExpired:
+ proc.kill()
+ failed = [n for n, ok in results if not ok]
+ if failed and log.exists():
+ print("---- kwnt log (last 40 lines) ----")
+ print("\n".join(log.read_text(errors="replace").splitlines()[-40:]).replace(str(root), "<tmp>"))
+ print(f"\nfresh-machine: {len(results) - len(failed)}/{len(results)} checks passed")
+ if keep:
+ print(f"kept {root}")
+ else:
+ shutil.rmtree(root, ignore_errors=True)
+ return 1 if failed else 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/release_required_checks.txt b/scripts/release_required_checks.txt
new file mode 100644
index 00000000..84238e45
--- /dev/null
+++ b/scripts/release_required_checks.txt
@@ -0,0 +1,8 @@
+# CI checks that must be green on a release commit before main moves and the tag is pushed.
+# One check-run name per line (the `name:` of the job in .github/workflows/ci.yml). The release script reads this
+# from the release commit: `git show <release commit>:scripts/release_required_checks.txt`.
+# scripts/test_fresh_machine.py fails if a name here has no job in ci.yml.
+rust
+frontend
+site
+fresh-machine
diff --git a/scripts/test_fresh_machine.py b/scripts/test_fresh_machine.py
new file mode 100644
index 00000000..f609b63a
--- /dev/null
+++ b/scripts/test_fresh_machine.py
@@ -0,0 +1,72 @@
+"""Tests for the new-computer test's pieces that need no kwnt binary (they run in the `site` job's unittest step).
+
+- the stand-in curl serves the installer URL and refuses (and logs) every other URL;
+- the stand-in installer, run the way kwnt runs it (`curl -fsSL URL | bash`, bare PATH, empty HOME), leaves a signed-out
+ `claude` that prints an allowed sign-in link;
+- every check in release_required_checks.txt is a job in ci.yml, so the release gate can't wait for a name that
+ never reports.
+"""
+import re
+import subprocess
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).parent))
+import fresh_machine_test as fm # noqa: E402
+
+ROOT = Path(__file__).resolve().parent.parent
+
+
+class StandInDownload(unittest.TestCase):
+ def setUp(self):
+ self.tmp = tempfile.TemporaryDirectory()
+ self.home, self.bin, _, self.log = fm.make_machine(Path(self.tmp.name) / "m")
+ self.env = {"HOME": str(self.home), "PATH": str(self.bin)}
+
+ def tearDown(self):
+ self.tmp.cleanup()
+
+ def run_sh(self, cmd):
+ return subprocess.run(["sh", "-c", cmd], env=self.env, capture_output=True, text=True, timeout=30)
+
+ def test_other_urls_are_refused_and_logged(self):
+ r = self.run_sh("curl -fsSL https://x.ai/cli/install.sh")
+ self.assertEqual(r.returncode, 22)
+ self.assertIn("refused", r.stderr)
+ self.assertEqual(self.log.read_text().split(), ["https://x.ai/cli/install.sh"])
+
+ def test_install_then_signed_out_claude_with_a_link(self):
+ r = self.run_sh(f"curl -fsSL {fm.INSTALL_URL} | bash")
+ self.assertEqual(r.returncode, 0, r.stderr)
+ claude = self.home / ".local" / "bin" / "claude"
+ self.assertTrue(claude.is_file())
+ status = subprocess.run([str(claude), "auth", "status", "--json"], env=self.env, capture_output=True, text=True)
+ self.assertEqual(status.stdout.strip(), '{"loggedIn":false}')
+ login = subprocess.Popen([str(claude), "auth", "login", "--claudeai"], env=self.env, stdout=subprocess.PIPE, text=True)
+ try:
+ text = "".join(login.stdout.readline() for _ in range(2))
+ finally:
+ login.kill()
+ self.assertRegex(text, r"https://(claude\.ai|claude\.com)/")
+ self.assertEqual(self.log.read_text().split(), [fm.INSTALL_URL])
+
+ def test_no_ai_tools_on_the_bare_path(self):
+ for tool in ("claude", "codex", "grok", "node", "npm", "brew", "apt-get", "docker"):
+ self.assertFalse((self.bin / tool).exists(), tool)
+
+
+class RequiredChecks(unittest.TestCase):
+ def test_every_required_check_is_a_ci_job(self):
+ names = [l.strip() for l in (ROOT / "scripts" / "release_required_checks.txt").read_text().splitlines()
+ if l.strip() and not l.startswith("#")]
+ ci = (ROOT / ".github" / "workflows" / "ci.yml").read_text()
+ jobs = set(re.findall(r"^ name: (\S+)\s*$", ci, re.M))
+ self.assertIn("fresh-machine", names)
+ for n in names:
+ self.assertIn(n, jobs, f"{n} is required for a release but ci.yml has no job named that")
+
+
+if __name__ == "__main__":
+ unittest.main()