mirror of
https://github.com/garrytan/gstack.git
synced 2026-12-03 05:13:49 +01:00
Let a repo keep server-backed Playwright tests out of the local pre-merge run (GST-3553) (#4885)
A repo can list folders as `"local_skip": ["apps/web/e2e/**"]` in `.gstack/pregate.json`, and /gstack-ship leaves the Playwright tests under them out of the run on this machine, prints how many it left out, and still expects them from CI. Why: Playwright suites outside `test/` that need dev servers failed green branches (#4709); only files Playwright plainly owns are ever left out, so a too-wide folder never skips a unit test. Nothing to do unless your repo has such a suite. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: s11/outside-voice#1 reader=outside-voice Review-Finding: s11/outside-voice#2 reader=outside-voice Review-Finding: s11/adversarial-native#1 reader=adversarial-native Review-Finding: s11/adversarial-native#2 reader=adversarial-native
This commit is contained in:
1 parent
adba58aa28
commit
942a12c618
9 files changed
+300
-55
No files matched your search
+2
-1
@@ -92,7 +92,8 @@ the byte-pinned `/gstack-ship` renders in `test/fixtures/golden/`).
|
||||
| Key | Meaning |
|
||||
|---|---|
|
||||
| `runner` | the local test command with `{files}` (gstack: `bun test --timeout=30000 {files}`, the 30 s per-test timeout CI uses); set, the local lane gives it only the selected files its tool runs, judged by extension (JS/TS files for `bun test`, `node --test`, `deno test`, vitest, jest, mocha, ava or playwright; `.py` files for pytest; each matched as a whole word, so `npx vitest run` counts and `tests/node/run.sh` does not; every file for any other command, such as a `node scripts/run-tests.js` dispatcher, or one naming both), and the lanes detail names each file it cannot run as not run and not counted as covered, so a `*_test.py` never reaches a local `bun test` (no Python lane runs beside a declared runner; the remote gate and `test_backend` commands still receive the whole selection, a declared test tree's tests included, since that exclusion is local-only); unset, it is detected (bun, vitest or jest for JS/TS files, pytest when python3 can import it (else `pytest` or `python3` is named missing), `node --test`, and `flutter test`/`dart test` per Dart package root, through fvm when that package or an ancestor pins it with `.fvmrc` or `.fvm/fvm_config.json` and fvm is on PATH; `cargo test -p <name>` per Rust crate, run from the root of the workspace the crate is a member of (Cargo's `members` globs, `exclude` and `package.workspace`), else the crate directory; a JS/TS test whose nearest package.json is a nested package declaring vitest or jest (a dependency or its `test` script) runs from that package, with package-relative paths, through the package manager its `packageManager` field or the nearest lockfile up to the repo root names: `pnpm exec`, `yarn`, `bun x`, else `npx`; a JS/TS test file that imports `@playwright/test` at the start of a line, or takes `test` from a repo module that takes `test` from it (Playwright's fixtures pattern, followed through named and `export *` re-exports and `index` modules up to 8 deep, never outside the repo; only the module `test` comes from), runs as `playwright test --reporter=list` from its nearest package through that same package manager, whatever the unit runner is, a type-only import (`import type …`, or one whose every specifier is `type X`) does not count, file arguments are passed as escaped regexes anchored to the path (Playwright reads them as regexes), and a run where every test fails and Playwright says its browser is not installed is `PREGATE_ENVIRONMENT` (a partial install, where some tests pass, stays the diff's failure); a `.js`, `.mjs` or `.cjs` test that loads `node:test` in a statement starting a line, and loads neither vitest nor `@jest/globals`, runs through `node --test` from the repo root even when the repo or its package declares vitest or jest (which find no suite in such a file), while a bun repo keeps `bun test` for it; every other test keeps the root detection, split by language when no one runner fits them all, so `.mjs` and `.py` root tests each get their own runner); nothing detected, a Dart SDK, cargo or package manager missing from PATH, a `.dart` file with no `pubspec.yaml` above it, a `.rs` file outside any crate, or one in a crate whose name Cargo would reject (anything but letters, digits, `_` and `-`), is `incomplete` (the runnable groups still run, so a real failure still fails) |
|
||||
| `dependencies` | glob → test files for subprocess targets, runtime reads and generated inputs the import graph cannot see; `[]` declares "no lane needed" (docs, licences). A `[]` on a folder inside a test directory (`test/`, `tests/`, `spec/` or `__tests__/`, as in `"tests/live/**": []`; never the whole directory, so `"test/**": []` changes nothing) is the repo's statement that the tests under it run in their own tier, not in /gstack-ship's local lane: pregate keeps every selected test under that glob out of the local lane, whether touched or picked through an import (a test `.gstack/always-run.json` names still runs; the remote side is unchanged: the remote gate, `test_backend` and any remote platform lane that selects the test still owe it; and only a base-branch or user-owned policy's `[]` counts, never a bootstrap head file read under `--policy-from` head when neither exists), and prints `declared test tree <glob>: N test file(s) not run in the local lane` in the `lanes` lines it records; tests outside the glob still run, and a `[]` on any other glob never skips a test. A `[]` that matches a deleted test does not skip it: the deleted test still runs its owning suite, and a file naming it that `[]` covers (a durations list) counts as covered. With this key present, even empty, the policy [declares lanes](#lane-requirements) |
|
||||
| `dependencies` | glob → test files for subprocess targets, runtime reads and generated inputs the import graph cannot see; `[]` declares "no lane needed" (docs, licences). A `[]` on a folder inside a test directory (`test/`, `tests/`, `spec/` or `__tests__/`, as in `"tests/live/**": []`; never the whole directory, so `"test/**": []` changes nothing) is the repo's statement that the tests under it run in their own tier, not in /gstack-ship's local lane: pregate keeps every selected test under that glob out of the local lane, whether touched or picked through an import (a test `.gstack/always-run.json` names still runs; the remote side is unchanged: the remote gate, `test_backend` and any remote platform lane that selects the test still owe it; and only a base-branch or user-owned policy's `[]` counts, never a bootstrap head file read under `--policy-from` head when neither exists), and prints `declared test tree <glob>: N test file(s) not run in the local lane` in the `lanes` lines it records; tests outside the glob still run, and a `[]` on any other glob never skips a test. A `[]` that matches a deleted test does not skip it: the deleted test still runs its owning suite, and a file naming it that `[]` covers (a durations list) counts as covered. With this key present, even empty, the policy [declares lanes](#lane-requirements). For a test tree outside those four folders, such as a Playwright suite that needs servers, see `local_skip` |
|
||||
| `local_skip` | folder globs whose Playwright specs stay out of the local lane, for an end-to-end tree outside `test/`, `tests/`, `spec/` and `__tests__/` that needs servers only CI starts (as in `"local_skip": ["apps/web/e2e/**"]`; #4709). Each entry ends in `/**` and names at least one literal folder, so `**`, `*/**` and a file glob such as `apps/web/e2e/*.spec.ts` are refused. Only a file Playwright plainly owns is left out: a JS/TS file under a `package.json` whose own `test` comes from `@playwright/test` (an `import`, or a repo fixture module that takes it from there) and that loads no unit runner (vitest, `@jest/globals`, `bun:test`, `node:test`); an import written inside a template string or a comment does not count. Every other test under the glob keeps its runner and is named on a `local_skip <glob>: N selected test file(s) under it are not Playwright specs, so local_skip keeps them in the local lane` line, so an over-wide glob such as `apps/web/**`, or a unit test that borrows a Playwright helper such as `expect`, never skips a unit test, and the key stays Playwright-only (a wider skip would be a new key). A spec that takes `test` through `require` or a tsconfig path alias is not recognised and still runs. Skipped specs print `declared test tree <glob>: N test file(s) not run in the local lane (listed in local_skip in <policy>; …)`; a test `.gstack/always-run.json` names still runs, a glob that is also a `[]` test tree keeps that wording, and `--explain` names a glob matching no test file. The remote side is unchanged: the remote gate, `test_backend` and any remote platform lane that selects the spec still owe it, and with none of those the repo's own CI is what runs it. The key does not [declare lanes](#lane-requirements), and only a base-branch or user-owned policy's `local_skip` counts: under `--policy-from head` a branch that adds or changes it is refused as loosening, and a bootstrap head file's drops nothing. Older gstack refuses the unknown key, so a repo adopting it should set `min_gstack_version` in `.gstack/ship-policy.json` (an older install then says to upgrade) |
|
||||
| `empty_lanes` | extra globs for the docs/no-tests empty lane. Any Markdown file already qualifies with no pin file when no test depends on it (the same import graph as other files: a quoted path, a `join()` of path segments, an import, or a `dependencies` entry). reStructuredText and AsciiDoc count as Markdown here. README, CHANGELOG, CONTRIBUTING, LICENSE, AGENTS and CLAUDE qualify even without `.md`, and so does licence text under any vendored name (`roboto-LICENSE.txt`, `LICENSE-MIT`, `licenses/*.txt`). Source code and files under a test directory never qualify. A test that reads the file still selects that test |
|
||||
| `selection` | `workflow.yml/job` → a command printing the lane's file list, for matrices a planner computes (gstack: `scripts/test-free-shards.ts --list`) |
|
||||
| `warn` | check ids downgraded to warn; `secrets` and required lanes never. `"lanes"` downgrades only a touched file with no lane: the selected tests still run, a red lane stays `fail` (`PREGATE_LANE_FAILED`) and an unfinished one `incomplete`; a green run is `warn` `PREGATE_NO_LANE` naming the unmapped files |
|
||||
|
||||
Reference in new issue
Block a user