From 4680d78b4ce92201777135fb09b9dea37ca45d03 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 26 May 2026 11:25:59 +0200 Subject: [PATCH] test(ci): add live smoke test for `ci scopes` select-all path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pin the contract before porting `ci scopes` to Rust. The new test exercises the "no base provided" branch — pass `--head HEAD` without `--base` and the command must list every configured scope as touched. This is the one execution path through `ci scopes` that doesn't shell out to `git diff`, so the test stays hermetic inside the tmp dir the `cli` fixture runs in (no git init, no remote fetch, no Mergify API). The Python implementation passes today. The follow-up port lands on top and the same smoke test exercises the Rust binary, catching any wire-format or exit-code drift between the two implementations. Co-Authored-By: Claude Opus 4.7 Change-Id: I14468b7046c449104675aea0a07a273eab479316 --- func-tests/test_live_smoke.py | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/func-tests/test_live_smoke.py b/func-tests/test_live_smoke.py index a2e5404a..7d7d07dd 100644 --- a/func-tests/test_live_smoke.py +++ b/func-tests/test_live_smoke.py @@ -432,6 +432,52 @@ def test_scopes_send( assert result.returncode == 0, f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" +def test_ci_scopes_select_all_when_no_base( + tmp_path: pathlib.Path, + cli: typing.Callable[..., typing.Any], +) -> None: + """`mergify ci scopes` with `--head HEAD` and no `--base` lists + every configured scope as touched. + + Locally evaluated — no Mergify API, no token, no git + operations: the no-base branch is the one path through the + command that doesn't shell out to `git diff`, so the test + stays hermetic in the tmp dir the `cli` fixture runs in. + Passing `--head` (without `--base`) is what forces the + "manual" `References` branch with `base=None`; the detector + fallback would otherwise pick `HEAD^..HEAD` and try to diff + against a non-existent git repo. + + Contract pinned for the upcoming Python → Rust port: both + `backend` and `frontend` from the config below must appear in + the output so the "selecting all scopes" code path stays + intact when the implementation flips. + """ + config = tmp_path / "mergify.yml" + config.write_text( + "scopes:\n" + " source:\n" + " files:\n" + " backend:\n" + " include: ['mergify_cli/**']\n" + " frontend:\n" + " include: ['web/**']\n", + encoding="utf-8", + ) + + result = cli("ci", "scopes", "--config", str(config), "--head", "HEAD") + assert result.returncode == 0, ( + f"expected 0, got {result.returncode}\n" + f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" + ) + combined = result.stdout + result.stderr + for scope in ("backend", "frontend"): + assert scope in combined, ( + f"expected scope '{scope}' in the 'select all' output\n" + f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" + ) + + def test_tests_show_no_match( live_token: str, cli: typing.Callable[..., typing.Any],