diff --git a/.github/justfile b/.github/justfile index 672f070e042..74ccdc82ee8 100644 --- a/.github/justfile +++ b/.github/justfile @@ -42,6 +42,7 @@ test: python3 sh/size/release.test.py python3 sh/size/nightly.test.py python3 bench/compare.test.py + bash sh/local.sh python3 bench/build.test.py python3 bench/summary.test.py python3 bench/profile.test.py python3 bench/fanout.test.py diff --git a/README.md b/README.md index dd354ed643f..70ca49a14de 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ Local nextest runs default to at most four test workers; set `NEXTEST_TEST_THREADS` to override it. Bun workspace scripts run sequentially locally, preserving dependency order, while CI keeps its workspace parallelism. Selection and an empty JS selection do not wait for admission. For a build -outside these entrypoints, use `quest gate COMMAND [ARGS...]`; gate thresholds +outside these entrypoints, use `bash sh/quest.sh gate COMMAND [ARGS...]`; gate thresholds come from the host and have no configuration. Run `just ci` before pushing. Ready PRs into `main` also run Check as a signal; only GitHub's merge queue gates landing. `just ci` runs what the merge queue runs, the same ground as `just check`, plus two settings: `CI_STRICT=1`, which turns a missing tool into an error instead of a skipped check, and `NEXTEST_PROFILE=ci`, which allows a longer hang timeout. diff --git a/bench/README.md b/bench/README.md index 6566fa19ad9..8e0bd0b7151 100644 --- a/bench/README.md +++ b/bench/README.md @@ -902,7 +902,8 @@ nix develop --command just gh benchmark-report gate target/bench/nightly/rust-be Each run's evidence directory keeps both builds' estimates (`criterion` and `criterion-base`), the confirmation rounds under `confirm/`, and the run's -`paired.json`. +`paired.json`. The base build streams its diagnostics and retains them in +`base-build.log`, including when it fails. ### CodSpeed diff --git a/bench/build.test.py b/bench/build.test.py new file mode 100644 index 00000000000..077f2716525 --- /dev/null +++ b/bench/build.test.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +"""Exercise paired builds with real Cargo diagnostics and target discovery.""" + +import json +import os +import shutil +import subprocess +import tempfile +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +class Builds(unittest.TestCase): + def test_base_builds_report_errors_and_distinguish_new_targets(self): + (ROOT / ".tmp").mkdir(exist_ok=True) + for base in ("broken", "existing", "new", "log-failure"): + with self.subTest(base=base), tempfile.TemporaryDirectory(dir=ROOT / ".tmp") as directory: + repo = Path(directory) / "repo" + repo.mkdir() + shutil.copytree(ROOT / "bench", repo / "bench", ignore=shutil.ignore_patterns("__pycache__")) + (repo / ".cargo").mkdir() + (repo / ".cargo/config.toml").touch() + (repo / ".gitignore").write_text(".tmp/\ntarget/\n") + (repo / "Cargo.toml").write_text('[workspace]\nmembers=["rs/moq-relay"]\nresolver="3"\n') + package = repo / "rs/moq-relay" + (package / "src").mkdir(parents=True) + (package / "benches").mkdir() + (package / "src/lib.rs").touch() + manifest = '[package]\nname="moq-relay"\nversion="0.0.0"\nedition="2024"\n' + target = '[[bench]]\nname="catalog"\nharness=false\n' + (package / "Cargo.toml").write_text(manifest + (target if base != "new" else "")) + bench = package / "benches/catalog.rs" + if base != "new": + bench.write_text( + 'compile_error!("base catalog source failed");\n' + if base == "broken" + else 'fn main() { println!("base catalog ran"); }\n' + ) + env = dict(os.environ, CARGO_TARGET_DIR=str(repo / "target"), BENCH_BASE="HEAD") + for key in ("BENCH_ARTIFACTS", "BENCH_RUNS", "RUSTC_WRAPPER", "RUSTC_WORKSPACE_WRAPPER"): + env.pop(key, None) + + def run(*args): + result = subprocess.run(args, cwd=repo, env=env, text=True, capture_output=True) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + return result + + run("cargo", "generate-lockfile") + run("git", "init", "-q", "-b", "main") + run("git", "add", ".") + run( + "git", + "-c", + "user.name=Test", + "-c", + "user.email=test@example.com", + "-c", + "commit.gpgsign=false", + "commit", + "-qm", + "base", + ) + (package / "Cargo.toml").write_text(manifest + target) + bench.write_text('fn main() { println!("current catalog ran"); }\n') + if base == "log-failure": + tools = repo / ".tmp/tools" + tools.mkdir(parents=True) + tee = tools / "tee" + tee.write_text( + "#!/usr/bin/env bash\n" + "if [[ $1 == */base-build.log ]]; then cat; exit 1; fi\n" + f'exec {shutil.which("tee")} "$@"\n' + ) + tee.chmod(0o755) + env["PATH"] = str(tools) + os.pathsep + env["PATH"] + result = run("bash", "bench/run.sh", "--criterion", "-p", "moq-relay", "--bench", "catalog") + (evidence,) = (repo / ".tmp/bench").glob("run.*") + log = (evidence / "base-build.log").read_text() if base != "log-failure" else "" + report = json.loads((evidence / "paired.json").read_text()) + self.assertIn("current catalog ran", result.stdout) + self.assertIn(str(evidence / "base-build.log"), result.stdout) + if base == "broken": + self.assertIn("base catalog source failed", result.stderr) + self.assertIn("base catalog source failed", log) + self.assertEqual( + report["unavailable"], [{"target": "moq-relay/catalog", "reason": "base build failed"}] + ) + self.assertEqual((evidence / "criterion-base.targets").read_text(), "") + else: + self.assertEqual(report["unavailable"], []) + self.assertEqual("base catalog ran" in result.stdout, base in ("existing", "log-failure")) + if base == "log-failure": + self.assertIn("Failed to write base build log:", result.stderr) + self.assertNotEqual((evidence / "criterion-base.targets").read_text(), "") + self.assertEqual(len(run("git", "worktree", "list", "--porcelain").stdout.split("worktree ")) - 1, 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/bench/run.sh b/bench/run.sh index 356c7282b8a..9801633c148 100755 --- a/bench/run.sh +++ b/bench/run.sh @@ -460,7 +460,13 @@ measure_criterion() { mkdir -p "$RUN/base-context" (cd "$WORKTREE" && python3 "$ROOT/bench/metadata.py" "$RUN/base-context" "$BASE" comparison-base) printf 'Criterion paired with base %s\n' "$BASE" - if ! criterion_build_base "$base"; then + printf 'Base build log: %s/base-build.log\n' "$RUN" + local build_status=(0 0) + criterion_build_base "$base" 2>&1 | tee "$RUN/base-build.log" >&2 || build_status=("${PIPESTATUS[@]}") + if ((build_status[1] != 0)); then + printf 'Failed to write base build log: %s/base-build.log\n' "$RUN" >&2 + fi + if ((build_status[0] != 0)); then : >"$base" for key in "${targets[@]}"; do unavailable "$key" "base build failed"; done fi diff --git a/doc/setup/dev.md b/doc/setup/dev.md index d4df72d94a1..4fb925ab3ad 100644 --- a/doc/setup/dev.md +++ b/doc/setup/dev.md @@ -51,6 +51,14 @@ module as skipped; `just ci` still requires the full flake check. contains the module selection, with package selection delegated to the language runners. +Repository gates and quest checks use the dev shell’s quest executable through +`sh/quest.sh`, reporting its path. Enter this checkout’s dev shell to use its pin. Use +`bash sh/quest.sh review --base origin/main` for a local review with that build, +or `bash sh/quest.sh gate COMMAND [ARGS...]` to admit a standalone build. +Outside the dev shell, explicit host toolchains (`ALLOW_HOST_TOOLCHAIN=1`, or Windows without Nix) +report the selected quest executable and version alongside the repository pin; +their build identity is unverified. + | What you changed or need to measure | Start here | | --- | --- | | Ordinary source changes | `just check`; [Rust instructions](https://github.com/moq-dev/moq/blob/main/rs/AGENTS.md) and [TypeScript instructions](https://github.com/moq-dev/moq/blob/main/js/AGENTS.md) describe focused test commands and conventions | diff --git a/flake.nix b/flake.nix index 347a3b3d641..97ae360d413 100644 --- a/flake.nix +++ b/flake.nix @@ -679,6 +679,9 @@ export PATH="$(dirname "$shim"):$PATH" fi + # Skills also invoke quest directly, so keep it ahead of host installs. + export PATH="${quest-cli}/bin:$PATH" + # Each nested shell (direnv, then `nix develop`, then another # inside a gate) prepends this shell's ~160 store paths again, # about 10 KB. mbx copies PATH into two variables at ~3.6 times @@ -693,6 +696,9 @@ # fix`. IN_NIX_SHELL would also pass inside another project's shell. IN_MOQ_DEV_SHELL = "1"; + # Local launchers need the exact build without evaluating the flake again. + MOQ_QUEST = "${quest-cli}/bin/quest"; + PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}"; PLAYWRIGHT_VERSION = pkgs.playwright-driver.version; PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = "true"; diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 6b84f40ebd1..77e60caba9f 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -182,7 +182,6 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Unify dependency features](/quest/m0/ci/hakari.md) - align the FFI builds' features and record the hosted platform jobs' hits once the workspace-hack lands - [Drop main from the publish Environment](/quest/m0/ci/publish-release-only.md) - the maintainer narrows `publish` to `release` and release tags once no job naming it runs as `main` - [Binary release publishers run on their tag](/quest/m0/ci/release-tag-publishers.md) - brew, Go and Swift releases stop running through `workflow_run` on main -- [The bench comparison builds moq-gst's catalog bench on its base](/quest/m0/ci/bench-base-build.md) - A paired bench comparison that selects `rust/gst/moq-gst/catalog` against `origin/main` builds the base side and reports a comparison, instead of marking it unavailable with "base build failed" - [Measure the Linux cache effect of native media exclusions](/quest/m0/ci/hakari-followups.md) - scheduled Linux jobs measure cache reuse after unrelated tests stop compiling PipeWire and libclang - [A release merge opens no stale release PR](/quest/m0/ci/release-pr-after-release.md) - `just rs release` publishes before it proposes, so a merged release isn't re-proposed - [Build two queue entries at once if it helps](/quest/m0/ci/queue-concurrency.md) - a measured trial of `maximumEntriesToBuild: 2` against the serial lane's burst latency diff --git a/quest/m0/ci/bench-base-build.md b/quest/m0/ci/bench-base-build.md deleted file mode 100644 index 97fe607b218..00000000000 --- a/quest/m0/ci/bench-base-build.md +++ /dev/null @@ -1,44 +0,0 @@ -# [S] The bench comparison builds moq-gst's catalog bench on its base - -## Goal - -A paired bench comparison that selects `rust/gst/moq-gst/catalog` against -`origin/main` builds the base side and reports a comparison, instead of -marking it unavailable with "base build failed". Local reviews and gates -that run `quest` use the build `flake.nix` pins, or say which they ran. - -## Plan - -Decided 2026-10-31 (user, /quest-plan of the follow-ups from the 2026-10-31 /quest-complete run), from [moq-dev/moq#7347](https://github.com/moq-dev/moq/pull/7347). Milestone: ✅ m0 (user, "all recommended" for quests 1-8). - -- **Base build**: #7347's `just ci` bench comparison reported "base build - failed" for `rust/gst/moq-gst/catalog` against `origin/main`, from a - change that doesn't touch moq-gst. `bench/run.sh:396-405` (at - be39188000) builds the base in a detached `git worktree` through - `criterion_build_base` (`:330`), and any failure there marks every - selected target unavailable without showing why. The bench target - (`rs/moq-gst/Cargo.toml:48`, `benches/catalog.rs`) has existed since - 2026-10-14, so a missing target is not the cause. Check first whether - it was the nested-checkout Cargo alias merge Nightly hit: #7347's run - predates both [moq-dev/moq#7245](https://github.com/moq-dev/moq/pull/7245), - which made those aliases strings, and - [moq-dev/moq#7445](https://github.com/moq-dev/moq/pull/7445) (merged), - which moved the base worktree out of the checkout to - `${TMPDIR:-/tmp}/moq-bench-base.*` (`checkout_base`, `:226`). Nightly's - baseline has built since - ([moq-dev/moq#7592](https://github.com/moq-dev/moq/pull/7592)). If a - comparison on current main builds the base, only the logging below is - left. Otherwise look for what the fresh worktree lacks that the checkout - has (GStreamer's build environment, a generated or untracked input, - submodules), reproducing with the bench command #7347's `just ci` ran, - and fix the cause. Either way, have the base build log its error into - the run's output. -- **quest version**: in the same run, the `quest` on the host's PATH was - not the build `flake.nix` pinned (then `github:moq-dev/quest/1ef2ca7`, - `5e66075` at be39188000, served by the dev shell); the review was rerun - with the pinned one. Check which scripts or recipes call `quest` (the - gate and `quest review` paths) and make them resolve the pinned build, - or fail with a message naming both versions when they differ. Settle on - whichever is simpler; the quest binary's own behavior is out of scope. - -Public API: none. Wire: none. diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index e7afd407ea3..346f8fe7454 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -25,7 +25,7 @@ def setUp(self): self.root = Path(self.temp.name) self.repo = self.root / "repo" (self.repo / "sh").mkdir(parents=True) - for script in ("dispatch.sh", "changed.sh", "local.sh"): + for script in ("dispatch.sh", "changed.sh", "local.sh", "quest.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") @@ -84,6 +84,11 @@ def test_quest_only_has_no_tests_but_keeps_repository_lints(self): self.change("quest/m1/example.md") self.expect(True, rust=False) + def test_quest_check_uses_the_checkout_pin(self): + self.change("quest/m1/example.md") + calls = self.run_ci() + self.assertIn("pinned quest check", calls) + def test_biome_checks_files_outside_the_js_impact_map(self): for path in ("cpp/obs/buildspec.json", "sh/gh/setup.test.ts", ".github/ci-selection-audit.json"): with self.subTest(path=path): @@ -281,7 +286,9 @@ def stub_ci(self, just=""): nix = self.bin / "nix" nix.write_text('#!/usr/bin/env bash\nprintf "nix %s\\n" "$*" >>"$CALLS"\n') nix.chmod(0o755) - self.env.update(IN_MOQ_DEV_SHELL="1", CALLS=str(self.root / "calls")) + quest = self.bin / "quest" + quest.write_text('#!/usr/bin/env bash\nprintf "pinned quest %s\\n" "$*" >>"$CALLS"\n') + self.env.update(IN_MOQ_DEV_SHELL="1", MOQ_QUEST=str(quest), CALLS=str(self.root / "calls")) (self.root / "calls").unlink(missing_ok=True) for script in ("markdown.sh", "shell.sh", "large-files.sh", "text.sh"): path = self.repo / "sh" / script diff --git a/sh/dispatch.sh b/sh/dispatch.sh index c68c4bb0c40..5e231e0ece9 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -176,7 +176,7 @@ module moq_sh '^infra/moq-sh/' \ tools='dash' # Quest documents form one graph, so any change validates the whole tree, # as does a bump of the flake-pinned validator. -module quest '^(quest/|flake\.lock$)' \ +module quest '^(quest/|flake\.lock$|sh/quest\.sh$)' \ tools='quest' # `obs check` compares the OBS pinned in buildspec.json, flake.nix, and # nixpkgs, and the last moves on a flake.lock bump alone. @@ -337,7 +337,7 @@ step() { python3 bench/compare.test.py bash sh/local.sh cargo check --locked --package moq-relay --package moq-bench --features moq-relay/io-uring ;; - check:quest) quest check ;; + check:quest) bash sh/quest.sh check ;; check:drill) just test drill-sensitivity --apply-only ;; check:obs_compile) just obs compile ;; check:flake) diff --git a/sh/js/workspace.test.py b/sh/js/workspace.test.py index 281fbeec173..cdae09e53c9 100644 --- a/sh/js/workspace.test.py +++ b/sh/js/workspace.test.py @@ -53,6 +53,7 @@ def plan(self, paths): def test_dispatcher_passes_only_js_impact_paths(self): sh = self.root / "sh" shutil.copy(selector.ROOT / "sh/dispatch.sh", sh / "dispatch.sh") + shutil.copy(selector.ROOT / "sh/quest.sh", sh / "quest.sh") changed = sh / "changed.sh" changed.write_text("#!/bin/sh\nprintf '%s\\n' js/auth/src/token.ts demo/pub/worker.ts quest/unrelated.md\n") changed.chmod(0o755) @@ -75,7 +76,12 @@ def test_dispatcher_passes_only_js_impact_paths(self): GITHUB_BASE_REF="missing", GITHUB_STEP_SUMMARY=str(summary), ): - env = dispatch_env(PATH=f"{tools}:{os.environ['PATH']}", ALLOW_HOST_TOOLCHAIN="1", SELECT_CALLS=str(calls)) + env = dispatch_env( + PATH=f"{tools}:{os.environ['PATH']}", + ALLOW_HOST_TOOLCHAIN="1", + MOQ_QUEST=str(tools / "quest"), + SELECT_CALLS=str(calls), + ) for script in ("markdown.sh", "shell.sh", "large-files.sh", "text.sh"): path = sh / script path.write_text("#!/bin/sh\nexit 0\n") diff --git a/sh/local.sh b/sh/local.sh index 6b065d8d648..c45e55373a2 100755 --- a/sh/local.sh +++ b/sh/local.sh @@ -16,4 +16,4 @@ fi if [[ "${QUEST_GATE_ADMITTED:-}" == 1 ]]; then exec bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" fi -exec quest gate bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" +exec bash "${BASH_SOURCE[0]%/*}/quest.sh" gate bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" diff --git a/sh/local.test.py b/sh/local.test.py index d496b1a36b9..b2cdb5a7ff4 100644 --- a/sh/local.test.py +++ b/sh/local.test.py @@ -1,5 +1,6 @@ """Admission must preserve failures and own the entire admitted command tree.""" +import json import os import shutil import signal @@ -19,7 +20,15 @@ class LocalGate(unittest.TestCase): def env(self, **changes): env = dict(os.environ) - for key in ("QUEST_GATE_ADMITTED", "LOCAL_SUPERVISED", "GITHUB_ACTIONS", "NEXTEST_TEST_THREADS"): + for key in ( + "QUEST_GATE_ADMITTED", + "LOCAL_SUPERVISED", + "GITHUB_ACTIONS", + "NEXTEST_TEST_THREADS", + "MOQ_QUEST", + "ALLOW_HOST_TOOLCHAIN", + "BASH_ENV", + ): env.pop(key, None) env.update(changes) return env @@ -53,7 +62,8 @@ def test_nested_admission_preserves_failures_and_worker_override(self): def test_admission_precedes_launch_and_nested_calls_skip_it(self): with tempfile.TemporaryDirectory() as directory: (Path(directory) / "bun").symlink_to(BUN) - quest = Path(directory) / "quest" + (Path(directory) / "bash").symlink_to(BASH) + quest = Path(directory) / "pinned-quest" quest.write_text( f"#!{sys.executable}\n" "import os, sys\n" @@ -68,10 +78,101 @@ def test_admission_precedes_launch_and_nested_calls_skip_it(self): f"sys.exit(subprocess.call([{BASH!r}, {str(LAUNCHER)!r}, " 'sys.executable, "-c", "print(\'inner\'); exit(11)"]))' ) - result = self.run_command(script, PATH=directory) + result = self.run_command(script, PATH=directory, MOQ_QUEST=str(quest)) self.assertEqual(result.returncode, 11, result.stderr) self.assertEqual(result.stdout.splitlines(), ["admitted", "outer", "inner"]) + def test_pinned_review_preserves_arguments_cwd_and_failure_without_host_fallback(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + quest = root / "pinned-quest" + quest.write_text( + f"#!{sys.executable}\n" + "import os, sys\n" + 'assert sys.argv[1:] == ["review", "--base", "origin/main", "--responses", "a file.json"]\n' + f"assert os.getcwd() == os.path.realpath({directory!r})\n" + 'print("pinned build failed", file=sys.stderr)\n' + "sys.exit(7)\n" + ) + quest.chmod(0o755) + host = root / "quest" + host.write_text(f"#!{sys.executable}\nraise RuntimeError('host quest must not run')\n") + host.chmod(0o755) + result = subprocess.run( + [BASH, str(ROOT / "sh/quest.sh"), "review", "--base", "origin/main", "--responses", "a file.json"], + cwd=directory, + env=self.env(PATH=directory, MOQ_QUEST=str(quest)), + capture_output=True, + text=True, + ) + self.assertEqual(result.returncode, 7, result.stderr) + self.assertEqual(result.stderr.splitlines(), [f"Dev-shell quest: {quest}", "pinned build failed"]) + + @unittest.skipIf(sys.platform in ("win32", "cygwin"), "quest.sh selects the host toolchain on msys and cygwin") + def test_outside_shell_resolves_the_checkout_pin(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + nix = root / "nix" + nix.write_text( + f"#!{sys.executable}\n" + "import sys\n" + f'assert sys.argv[1:] == ["run", "--no-update-lock-file", "{ROOT}#quest", "--", "review"]\n' + 'print("pinned input failed", file=sys.stderr)\n' + "sys.exit(7)\n" + ) + nix.chmod(0o755) + result = subprocess.run( + [BASH, str(ROOT / "sh/quest.sh"), "review"], + env=self.env(PATH=directory), + capture_output=True, + text=True, + ) + self.assertEqual(result.returncode, 7, result.stderr) + self.assertEqual(result.stderr.strip(), "pinned input failed") + nix.unlink() + result = subprocess.run( + [BASH, str(ROOT / "sh/quest.sh"), "review"], + env=self.env(PATH=directory), + capture_output=True, + text=True, + ) + self.assertEqual(result.returncode, 127, result.stderr) + self.assertIn("run nix develop", result.stderr) + self.assertIn("ALLOW_HOST_TOOLCHAIN=1", result.stderr) + + def test_explicit_host_toolchain_reports_its_unverified_build(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + (root / "bun").symlink_to(BUN) + quest = root / "quest" + quest.write_text( + f"#!{sys.executable}\n" + "import sys\n" + 'if sys.argv[1:] == ["--version"]: print("quest host-test"); sys.exit(0)\n' + 'assert sys.argv[1:] == ["check"]\n' + "sys.exit(9)\n" + ) + quest.chmod(0o755) + result = subprocess.run( + [BASH, str(ROOT / "sh/quest.sh"), "check"], + env=self.env(PATH=directory, ALLOW_HOST_TOOLCHAIN="1"), + capture_output=True, + text=True, + ) + self.assertEqual(result.returncode, 9, result.stderr) + self.assertIn(f"quest host-test at {quest}", result.stderr) + pin = json.loads((ROOT / "flake.lock").read_text())["nodes"]["quest"]["locked"]["rev"] + self.assertIn(f"repository pin: {pin} (build identity unverified)", result.stderr) + quest.unlink() + result = subprocess.run( + [BASH, str(ROOT / "sh/quest.sh"), "check"], + env=self.env(PATH=directory, ALLOW_HOST_TOOLCHAIN="1"), + capture_output=True, + text=True, + ) + self.assertEqual(result.returncode, 127, result.stderr) + self.assertIn(f"quest not found on PATH for the host toolchain; repository pin: {pin}", result.stderr) + def test_external_admission_keeps_descendant_supervision(self): with tempfile.TemporaryDirectory() as directory: (Path(directory) / "bun").symlink_to(BUN) diff --git a/sh/quest.sh b/sh/quest.sh new file mode 100644 index 00000000000..e211493fe8f --- /dev/null +++ b/sh/quest.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Resolve quest for repository gates and local reviews. +set -euo pipefail + +root=$(cd "${BASH_SOURCE[0]%/*}/.." && pwd) +if [[ -n ${MOQ_QUEST:-} ]]; then + printf 'Dev-shell quest: %s\n' "$MOQ_QUEST" >&2 + exec "$MOQ_QUEST" "$@" +fi + +if [[ -n ${ALLOW_HOST_TOOLCHAIN:-} || $OSTYPE == msys || $OSTYPE == cygwin ]]; then + pin=$(bun -e 'console.log((await Bun.file(process.argv[1]).json()).nodes.quest.locked.rev)' "$root/flake.lock") || pin=unavailable + if ! executable=$(command -v quest); then + printf 'quest not found on PATH for the host toolchain; repository pin: %s\n' "$pin" >&2 + exit 127 + fi + version=$(quest --version) || version=unavailable + printf 'Host quest: %s at %s; repository pin: %s (build identity unverified)\n' "$version" "$executable" "$pin" >&2 + exec quest "$@" +fi +if ! command -v nix >/dev/null 2>&1; then + echo 'quest requires the repository dev shell: run nix develop, or set ALLOW_HOST_TOOLCHAIN=1 to use host tools' >&2 + exit 127 +fi +exec nix run --no-update-lock-file "$root#quest" -- "$@" diff --git a/sh/rs/test-lints.test.py b/sh/rs/test-lints.test.py index 47fd5f4d86b..76b1996d678 100644 --- a/sh/rs/test-lints.test.py +++ b/sh/rs/test-lints.test.py @@ -21,6 +21,7 @@ def test_fail_fast_environment_reaches_nextest(self): (root / "src").mkdir() shutil.copy(ROOT / "sh" / "local.sh", root / "sh" / "local.sh") shutil.copy(ROOT / "sh" / "local.ts", root / "sh" / "local.ts") + shutil.copy(ROOT / "sh" / "quest.sh", root / "sh" / "quest.sh") (root / "justfile").write_text("mod rs\n") shutil.copy(ROOT / "rs" / "justfile", root / "rs" / "justfile") shutil.copy(ROOT / "sh" / "rs" / "nextest.sh", root / "sh" / "rs" / "nextest.sh")