Skip to content

The agent that grows with you

ci: run the slow lanes on a PR only when it touches their paths

emozilla5c08ad68f7ec
diff --git a/.github/actions/detect-changes/action.yml b/.github/actions/detect-changes/action.yml
index c3aaee4061b..d53b47fffdc 100644
--- a/.github/actions/detect-changes/action.yml
+++ b/.github/actions/detect-changes/action.yml
@@ -16,7 +16,7 @@ outputs:
description: Run Python tests / ruff / ty / windows-footguns.
value: ${{ steps.classify.outputs.python }}
python_prod:
- description: Python changes outside tests/ — gates product jobs (Desktop E2E, Docker).
+ description: Python changes outside tests/.
value: ${{ steps.classify.outputs.python_prod }}
frontend:
description: Run the TypeScript testing matrix + desktop build.
@@ -25,11 +25,23 @@ outputs:
description: Docker setup and meta files have changed.
value: ${{ steps.classify.outputs.docker_meta }}
docker:
- description: Files included in the docker image have changed.
+ description: Build and test the Docker image (docker meta, dependency manifests, PM, tests/docker).
value: ${{ steps.classify.outputs.docker }}
nix:
- description: Run `nix flake check` (flake inputs, or any product Python change).
+ description: Run `nix flake check` (flake files and dependency manifests).
value: ${{ steps.classify.outputs.nix }}
+ e2e:
+ description: Run the Python end-to-end suites (tests/e2e, except upgrade).
+ value: ${{ steps.classify.outputs.e2e }}
+ e2e_upgrade:
+ description: Run the N-1 to HEAD `hermes update` suites (tests/e2e/core/upgrade).
+ value: ${{ steps.classify.outputs.e2e_upgrade }}
+ e2e_desktop_core:
+ description: Run the Desktop core Electron suite (apps/desktop/e2e/core).
+ value: ${{ steps.classify.outputs.e2e_desktop_core }}
+ e2e_desktop_update:
+ description: Run the Desktop install/update Electron suite (apps/desktop/e2e/update).
+ value: ${{ steps.classify.outputs.e2e_desktop_update }}
site:
description: Build the Docusaurus docs site.
value: ${{ steps.classify.outputs.site }}
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index a9a641b0a34..d537f8947be 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -77,6 +77,10 @@ jobs:
rust: ${{ steps.gate-lanes.outputs.rust }}
docker_meta: ${{ steps.gate-lanes.outputs.docker_meta }}
mcp_catalog: ${{ steps.gate-lanes.outputs.mcp_catalog }}
+ e2e: ${{ steps.gate-lanes.outputs.e2e }}
+ e2e_upgrade: ${{ steps.gate-lanes.outputs.e2e_upgrade }}
+ e2e_desktop_core: ${{ steps.gate-lanes.outputs.e2e_desktop_core }}
+ e2e_desktop_update: ${{ steps.gate-lanes.outputs.e2e_desktop_update }}
ci_review: ${{ steps.classify.outputs.ci_review }}
ci_review_files: ${{ steps.classify.outputs.ci_review_files }}
event_name: ${{ github.event_name }}
@@ -110,12 +114,23 @@ jobs:
# ─────────────────────────────────────────────────────────────────────
# Lane-gated sub-workflows. Each runs in parallel after detect finishes.
# Skipped workflows (if condition is false) don't spin up runners.
+ #
+ # The E2E suites (e2e, e2e-upgrade, both Desktop suites, and the two
+ # Windows journeys in tests-os) take most of the larger-runner minutes.
+ # On a pull request each runs only when the diff touches that suite or the
+ # code it guards, or the PR carries the `run-e2e` label
+ # (scripts/ci/classify_changes.py::_E2E_LANES). Every push to main runs
+ # all of them, so a regression the path lists miss turns main red after
+ # the merge.
# ─────────────────────────────────────────────────────────────────────
tests:
name: Python tests
needs: detect
if: needs.detect.outputs.python == 'true'
uses: ./.github/workflows/tests.yml
+ with:
+ e2e: ${{ needs.detect.outputs.e2e == 'true' }}
+ e2e_upgrade: ${{ needs.detect.outputs.e2e_upgrade == 'true' }}
# macOS + Windows lanes. The main `tests` lane above is Linux-only, and
# the OS-marked tests it collects are skipped there by design (see the
@@ -131,6 +146,8 @@ jobs:
# (tests/test_desktop_update_windows_*.py) only when that surface
# changed; unit-level platforms("windows") tests always run.
desktop_updater: ${{ needs.detect.outputs.desktop_updater == 'true' }}
+ e2e: ${{ needs.detect.outputs.e2e == 'true' }}
+ e2e_upgrade: ${{ needs.detect.outputs.e2e_upgrade == 'true' }}
lint:
name: Python lints
@@ -186,7 +203,7 @@ jobs:
needs: detect
# The deterministic core suite (apps/desktop/e2e/core): transcript
# integrity, boot/respawn/orphans, clarify+approval. Required; retries 0.
- if: ${{ needs.detect.outputs.python_prod == 'true' || needs.detect.outputs.frontend == 'true' }}
+ if: needs.detect.outputs.e2e_desktop_core == 'true'
uses: ./.github/workflows/e2e-desktop-core.yml
e2e-desktop-update:
@@ -196,7 +213,7 @@ jobs:
# first run, "Update now" hand-off/relaunch, concurrent-update refusal.
# Advisory until it has proven stable on CI: its shards run with continue-on-error, so a
# red shard shows on the PR but does not fail all-checks-pass.
- if: ${{ needs.detect.outputs.python_prod == 'true' || needs.detect.outputs.frontend == 'true' }}
+ if: needs.detect.outputs.e2e_desktop_update == 'true'
uses: ./.github/workflows/e2e-desktop-update.yml
docs-site:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 0be8e700863..0193b577bd5 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -110,10 +110,10 @@ jobs:
- name: Decide whether to build
id: gate
env:
- # The docker lane derives from python_prod (not python: the image
- # copies installed code, never tests/, so tests-only PRs skip the
- # build), frontend and docker_meta. classify_changes.py owns the
- # formula so this gate and the nix lane cannot drift apart.
+ # The docker lane is a slow lane: on a pull request it runs only
+ # for docker meta, the dependency manifests, PM and tests/docker
+ # (or the run-e2e label). Every push to main builds the image.
+ # classify_changes.py owns the formula.
DOCKER: ${{ steps.classify.outputs.docker }}
run: |
set -euo pipefail
diff --git a/.github/workflows/label-rerun.yml b/.github/workflows/label-rerun.yml
index 6eb1a4445e7..a09e0b375e4 100644
--- a/.github/workflows/label-rerun.yml
+++ b/.github/workflows/label-rerun.yml
@@ -4,6 +4,11 @@ name: Label rerun
# the latest CI run. This re-evaluates ``review-labels`` (which now sees the
# label) and GitHub reruns the dependent ``all-checks-pass`` gate.
#
+# When the ``run-e2e`` label is added, rerun the head commit's CI, Docker and
+# Nix runs in full. Their ``detect`` job reads the PR's labels through the API
+# (a rerun replays the original event payload), so the rerun turns every slow
+# lane on (scripts/ci/classify_changes.py).
+#
# ``gh run rerun`` only works on a completed run. Thus this waits when the
# run is still in progress. The wait is now short. The two slowest jobs are
# the 40-minute comment poller and the 45-minute image build. Each one moved
@@ -21,8 +26,9 @@ permissions:
actions: write
pull-requests: read
+# Keyed by label so one label's job does not cancel the other's.
concurrency:
- group: label-rerun-${{ github.event.pull_request.number }}
+ group: label-rerun-${{ github.event.pull_request.number }}-${{ github.event.label.name }}
cancel-in-progress: true
jobs:
@@ -85,3 +91,41 @@ jobs:
echo "Run completed. Rerunning all failed jobs..."
gh run rerun "$RUN_ID" --repo "$REPO" --failed || true
echo "Done. GitHub will rerun review-labels and all dependent jobs."
+
+ rerun-with-e2e:
+ name: Rerun CI with every E2E lane
+ if: github.event.label.name == 'run-e2e'
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - name: Cancel and rerun the head commit's CI, Docker and Nix runs
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ REPO: ${{ github.repository }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: |
+ set -uo pipefail
+ for workflow in ci.yaml docker.yml nix.yml; do
+ RUN_ID=$(gh run list --repo "$REPO" --commit "$HEAD_SHA" --workflow "$workflow" \
+ --event pull_request --limit 1 --json databaseId --jq '.[0].databaseId // empty' || true)
+ if [ -z "$RUN_ID" ]; then
+ echo "$workflow: no run for $HEAD_SHA"
+ continue
+ fi
+ # A run in progress was classified without the label: stop it,
+ # then rerun it once GitHub marks it completed.
+ STATUS=$(gh run view "$RUN_ID" --repo "$REPO" --json status --jq .status || echo unknown)
+ if [ "$STATUS" != completed ]; then
+ gh run cancel "$RUN_ID" --repo "$REPO" || true
+ for _ in $(seq 60); do
+ STATUS=$(gh run view "$RUN_ID" --repo "$REPO" --json status --jq .status || echo unknown)
+ [ "$STATUS" = completed ] && break
+ sleep 5
+ done
+ fi
+ if gh run rerun "$RUN_ID" --repo "$REPO"; then
+ echo "$workflow: rerunning $RUN_ID"
+ else
+ echo "::warning::$workflow: could not rerun $RUN_ID (status $STATUS)"
+ fi
+ done
diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml
index 5dc68c84aba..614d865ce8e 100644
--- a/.github/workflows/nix.yml
+++ b/.github/workflows/nix.yml
@@ -40,11 +40,13 @@ concurrency:
cancel-in-progress: ${{ inputs.release != true && github.event_name == 'pull_request' }}
jobs:
- # A `paths:` filter cannot gate this workflow correctly. The flake packages
- # the product, and nine of the checks then run the built binary, so a change
- # to hermes_cli/ alone can fail `nix flake check` without touching one file
- # under nix/. The `nix` lane therefore follows python_prod as well as the
- # flake inputs. On push the classifier fails open and every lane is true.
+ # A `paths:` filter cannot gate this workflow: a push to main must run it
+ # whatever changed, because the flake packages the product and nine of the
+ # checks run the built binary. The `nix` lane is a slow lane
+ # (classify_changes.py): on a pull request it runs for the flake files and
+ # the dependency manifests, or the run-e2e label. On push the classifier
+ # fails open and every lane is true, so a product change that breaks the
+ # flake turns main red after the merge.
detect:
name: Detect affected areas
runs-on: ubuntu-latest
diff --git a/.github/workflows/tests-os.yml b/.github/workflows/tests-os.yml
index 854c9f56ee0..c853a443a92 100644
--- a/.github/workflows/tests-os.yml
+++ b/.github/workflows/tests-os.yml
@@ -41,6 +41,20 @@ on:
type: boolean
required: false
default: true
+ e2e:
+ description: >-
+ Run the Windows E2E job (tests/e2e/core/windows). A slow lane
+ (scripts/ci/classify_changes.py); a caller that passes nothing gets it.
+ type: boolean
+ required: false
+ default: true
+ e2e_upgrade:
+ description: >-
+ Run the Windows install + update journey (tests/e2e/core/windows_update).
+ A slow lane; a caller that passes nothing gets it.
+ type: boolean
+ required: false
+ default: true
permissions:
contents: read
@@ -173,6 +187,7 @@ jobs:
# interpreter selection, non-ASCII profile paths and tool ACLs, partial-clone fetch and
# venv holders. Its own workflow so wine2e-install/** pushes can run it alone.
name: Windows install + update E2E
+ if: inputs.e2e_upgrade
uses: ./.github/workflows/windows-install-update-e2e.yml
e2e-windows:
@@ -189,6 +204,7 @@ jobs:
# Windows race that passes on retry is still a race. Tracked Windows bugs are strict
# xfails (per-file KNOWN tables), so a fix turns this job red until the entry goes.
name: Windows E2E (real processes)
+ if: inputs.e2e
# 32-core like os-tests' Windows row: seven files run in parallel and each spawns
# process trees; on the 4-vCPU image the suite step took 153-171 s (job 4.7-5.6 min),
# here 124 s (job 3.1 min), with headroom against scheduling-starved timeouts.
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index ea3e6154012..49d5f614b6f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -2,6 +2,20 @@ name: Tests
on:
workflow_call:
+ inputs:
+ # The E2E jobs below are slow lanes (scripts/ci/classify_changes.py).
+ # ci.yaml passes the classifier's answer; a caller that passes nothing
+ # gets every job.
+ e2e:
+ description: Run the e2e job (tests/e2e except the upgrade suite).
+ type: boolean
+ required: false
+ default: true
+ e2e_upgrade:
+ description: Run the e2e-upgrade shards (tests/e2e/core/upgrade).
+ type: boolean
+ required: false
+ default: true
permissions:
contents: read
@@ -96,6 +110,7 @@ jobs:
e2e:
# The core suites spawn real serve / gateway / tui_gateway / MCP / SQLite
# writer processes per test; a 4-vCPU runner serialises them into timeouts.
+ if: inputs.e2e
runs-on: ubuntu-latest-32-core
timeout-minutes: 30
steps:
@@ -181,6 +196,8 @@ jobs:
# test_*.py (pm, git, handoff, network, hosts, ...). A new suite
# directory gets its own shard without editing this file, and no shard
# carries the whole tree's wall time against the 60-minute timeout.
+ # Skipping this job skips every e2e-upgrade shard with it.
+ if: inputs.e2e_upgrade
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
diff --git a/.github/workflows/windows-install-update-e2e.yml b/.github/workflows/windows-install-update-e2e.yml
index 3280513331f..5cb9abb3e6c 100644
--- a/.github/workflows/windows-install-update-e2e.yml
+++ b/.github/workflows/windows-install-update-e2e.yml
@@ -7,8 +7,10 @@ name: Windows install + update E2E
# Each file walks one journey (one install) and asserts several user-visible cells;
# tracked bugs are message-gated xfails (tests/e2e/core/_pending_fixes.py).
#
-# Called from tests-os.yml on every Python PR. Pushes to wine2e-install/** run it alone,
-# for sabotage proofs and iteration without the rest of CI.
+# Called from tests-os.yml when a Python PR touches the install/update code
+# (the classifier's e2e_upgrade lane) and on every push to main. Pushes to
+# wine2e-install/** run it alone, for sabotage proofs and iteration without the
+# rest of CI.
on:
workflow_call:
diff --git a/scripts/ci/classify_changes.py b/scripts/ci/classify_changes.py
index b0f0ee0c2bd..dc0360c687f 100644
--- a/scripts/ci/classify_changes.py
+++ b/scripts/ci/classify_changes.py
@@ -9,13 +9,17 @@ booleans (one per lane) to ``$GITHUB_OUTPUT`` and stdout. The
Lanes:
* ``python`` — pytest / ruff / ty / footguns.
-* ``python_prod`` — Python changes OUTSIDE tests/ — gates jobs that ship or
- run the product (Desktop E2E backend, Docker image) but never import the
- test suite. A tests-only PR keeps ``python`` (pytest must run) while
- skipping those product jobs.
+* ``python_prod`` — Python changes OUTSIDE tests/. A tests-only PR keeps
+ ``python`` (pytest must run) while this stays off.
* ``docker_meta`` — Dockerfiles etc.
-* ``docker`` — any product change + docker meta
-* ``nix`` — ``nix flake check``: the flake inputs and any product change.
+* ``docker`` — the image build: docker meta, the dependency manifests, PM,
+ and the image's own tests.
+* ``nix`` — ``nix flake check``: the flake files and the dependency
+ manifests.
+* ``e2e``, ``e2e_upgrade``, ``e2e_desktop_core``, ``e2e_desktop_update`` —
+ the end-to-end suites. Each runs on a pull request only when the PR edits
+ that suite or the code the suite exists to guard (``_E2E_LANES``), or
+ carries the ``run-e2e`` label.
* ``frontend`` — TS typecheck matrix + desktop build.
* ``site`` — Docusaurus + generated skill docs.
* ``scan`` — supply-chain scan (Python files, .pth, setup hooks).
@@ -37,12 +41,18 @@ Lanes:
and only the TypeScript matrix ran.
* ``mcp_catalog`` — bundled MCP catalog / installer review.
-Docker is not a lane — it builds on push-to-main and release only,
-never per-PR.
+``docker``, ``nix`` and the E2E lanes take most of the larger-runner minutes.
+An ordinary product change does not start them on a pull request. Every push
+to main runs them all (a push has no diff, so every lane is on), so a
+regression they catch shows up on main after the merge. A stable-release run
+forces every lane on.
Contract — *fail open, never closed*. We may run a lane we didn't need, but
must never skip one a change could break:
+* The slow lanes above are the one deliberate exception. On a pull request
+ they skip changes that could still break them, and main is where those
+ changes meet the suite. Their path lists decide which PRs run them early.
* An empty diff, or any ``.github/`` change, runs everything.
* ``python`` is a denylist: skipped only when *every* file is provably prose
or a frontend-only package; an unrecognized path keeps it on.
@@ -71,7 +81,7 @@ _FRONTEND = ("ui-tui/", "web/", "apps/") # TS typecheck-matrix packages
# Shipped page outside those packages, exercised by the desktop Electron suite.
_FRONTEND_FILES = {"scripts/desktop-update/ui.html"}
_ROOT_NPM = {"package.json", "package-lock.json"} # shifts every package's tree
-_DOCKER_META = ("docker/", ".hadolint.yml", "Dockerfile") # docker setup
+_DOCKER_META = ("docker/", ".hadolint.yaml", "Dockerfile", ".dockerignore") # docker setup
_NIX_PATHS = ("nix/",) # nix files
_NIX_FILES = {"flake.nix", "flake.lock"} # base nix files
_SITE = ("website/", "skills/", "optional-skills/") # docs site + skill pages
@@ -152,6 +162,97 @@ _DESKTOP_UPDATER_FILES = {
_RUST_PATHS = ("apps/bootstrap-installer/src-tauri/",)
_RUST_FILENAMES = {"Cargo.toml", "Cargo.lock"}
+# The slow lanes and the paths that start each one on a pull request. A path
+# belongs here when the lane is the only CI that exercises it for real: the
+# suite itself, its harness, and the product code the suite exists to guard.
+# Everything else reaches these lanes on the next push to main.
+_DEP_MANIFESTS = ("pyproject.toml", "uv.lock", "setup.py")
+_NPM_MANIFESTS = ("package.json", "package-lock.json")
+# Shared pytest harness: a bad edit here can break every Python E2E suite.
+_PY_TEST_HARNESS = (
+ "tests/conftest.py",
+ "tests/_fixtures/",
+ "tests/fakes/",
+ "tests/e2e/conftest.py",
+ "tests/e2e/core/_",
+ "scripts/run_tests.sh",
+ "scripts/run_tests_parallel.py",
+)
+# Both Desktop suites package the app and share this harness (the update
+# suite imports the core suite's harness and provider).
+_DESKTOP_E2E_SHARED = (
+ "apps/desktop/package.json",
+ "apps/desktop/electron-builder.config.cjs",
+ "apps/desktop/scripts/",
+ "apps/desktop/e2e/core/harness",
+ "apps/desktop/e2e/core/provider",
+ "apps/desktop/e2e/electron-binary",
+ "apps/desktop/e2e/fix-electron-tracing",
+ "apps/desktop/e2e/run-tmp",
+)
+_E2E_LANES: dict[str, tuple[str, ...]] = {
+ "e2e": (
+ *_PY_TEST_HARNESS,
+ "tests/e2e/",
+ # The state.db torture chamber and the compaction/exactly-once
+ # suites are the only tests that run real concurrent writers.
+ "hermes_state",
+ ),
+ "e2e_upgrade": (
+ *_PY_TEST_HARNESS,
+ *_DEP_MANIFESTS,
+ "tests/e2e/core/upgrade/",
+ "tests/e2e/core/windows_update/",
+ "tests/compat/",
+ "pm/",
+ "scripts/install.",
+ "setup-hermes.sh",
+ "hermes_cli/update_",
+ "hermes_cli/_update_",
+ "hermes_cli/old_updater",
+ "hermes_cli/_old_updater",
+ "hermes_cli/post_update",
+ "hermes_cli/config_migrations",
+ "hermes_cli/subcommands/update",
+ "hermes_cli/install_",
+ "hermes_cli/_install_",
+ "hermes_cli/main_install",
+ ),
+ "e2e_desktop_core": (
+ *_DESKTOP_E2E_SHARED,
+ "apps/desktop/e2e/",
+ "apps/desktop/electron/backend-",
+ "apps/shared/src/",
+ "apps/desktop/src/store/session",
+ "apps/desktop/src/store/transcript",
+ ),
+ "e2e_desktop_update": (
+ *_DESKTOP_E2E_SHARED,
+ "apps/desktop/e2e/update/",
+ "apps/desktop/electron/updater",
+ "apps/desktop/electron/update-",
+ "apps/desktop/electron/app-updater",
+ "apps/desktop/electron/gateway-stop-before-update",
+ "apps/desktop/electron/pre-update-",
+ "apps/desktop/electron/install-stamp",
+ "scripts/desktop-update/",
+ "scripts/install.sh",
+ "hermes_cli/desktop_update",
+ "hermes_cli/update_",
+ ),
+}
+# The upgrade journeys are their own lane; editing one does not start ``e2e``.
+# The update suite shares apps/desktop/e2e/ with the core suite but not its specs.
+_E2E_LANE_EXCLUDES = {
+ "e2e": ("tests/e2e/core/upgrade/", "tests/e2e/core/windows_update/"),
+ "e2e_desktop_core": ("apps/desktop/e2e/update/",),
+}
+_DOCKER_PATHS = (*_DOCKER_META, *_DEP_MANIFESTS, *_NPM_MANIFESTS, "pm/", "tests/docker/")
+_NIX_LANE_PATHS = (*_NIX_PATHS, *_NIX_FILES, *_DEP_MANIFESTS, *_NPM_MANIFESTS)
+
+# A pull request with this label runs every slow lane, whatever it touches.
+RUN_E2E_LABEL = "run-e2e"
+
def _is_docs(p: str) -> bool:
if p.startswith(("skills/", "optional-skills/")):
return False
@@ -223,8 +324,26 @@ def ci_review_files(files: list[str]) -> list[str]:
return sorted({f.strip() for f in files if f.strip() and _is_ci_review(f.strip())})
-def classify(files: list[str]) -> dict[str, bool]:
- """Map changed paths to ``{lane: should_run}``."""
+def _slow_lanes(files: list[str]) -> dict[str, bool]:
+ """The slow lanes a pull request with this diff runs; see ``_E2E_LANES``."""
+ lanes = {
+ lane: any(
+ f.startswith(paths) and not f.startswith(_E2E_LANE_EXCLUDES.get(lane, ()))
+ for f in files
+ )
+ for lane, paths in _E2E_LANES.items()
+ }
+ lanes["docker"] = any(f.startswith(_DOCKER_PATHS) for f in files)
+ lanes["nix"] = any(f.startswith(_NIX_LANE_PATHS) for f in files)
+ return lanes
+
+
+def classify(files: list[str], run_e2e: bool = False) -> dict[str, bool]:
+ """Map changed paths to ``{lane: should_run}``.
+
+ ``run_e2e`` is the pull request's ``run-e2e`` label: it turns every slow
+ lane on.
+ """
files = [f.strip() for f in files if f.strip()]
python = any(not _py_irrelevant(f) for f in files)
python_prod = any(not _py_irrelevant(f) and not _py_test_only(f) for f in files)
@@ -241,7 +360,6 @@ def classify(files: list[str]) -> dict[str, bool]:
ret = {
"python": python,
"python_prod": python_prod,
- "docker": docker_meta or python_prod or frontend,
"docker_meta": docker_meta,
"frontend": frontend,
"site": any(f.startswith(_SITE) for f in files),
@@ -256,12 +374,11 @@ def classify(files: list[str]) -> dict[str, bool]:
"rust": any(_is_rust(f) for f in files),
"mcp_catalog": any(_is_mcp_catalog(f) for f in files),
"ci_review": any(_is_ci_review(f) for f in files),
- "nix": python_prod or frontend or any(_is_nix(f) for f in files)
+ **{lane: run_e2e or on for lane, on in _slow_lanes(files).items()},
}
if not files or any(f.startswith(".github/") for f in files):
ret["python"] = True
ret["python_prod"] = True
- ret["docker"] = True
ret["docker_meta"] = True
ret["frontend"] = True
ret["site"] = True
@@ -272,27 +389,49 @@ def classify(files: list[str]) -> dict[str, bool]:
ret["bootstrap"] = True
ret["desktop_updater"] = True
ret["rust"] = True
- ret["nix"] = True
ret["ci_review"] = True
+ ret.update(dict.fromkeys(_slow_lanes([]), True))
# explicitly skip mcp catalog here. it's not needed unless those files are modified.
return ret
-def _pull_request_number() -> str | None:
- """Read the PR number from the Actions event payload, if present."""
+def _event_payload() -> dict:
+ """The Actions event payload, or ``{}`` when it is absent or unreadable."""
event_path = os.environ.get("GITHUB_EVENT_PATH")
if not event_path:
- return None
+ return {}
try:
with open(event_path, encoding="utf-8-sig") as fh:
payload = json.load(fh)
except (OSError, json.JSONDecodeError):
- return None
- number = (payload.get("pull_request") or {}).get("number")
+ return {}
+ return payload if isinstance(payload, dict) else {}
+
+
+def _pull_request_number() -> str | None:
+ """Read the PR number from the Actions event payload, if present."""
+ number = (_event_payload().get("pull_request") or {}).get("number")
return str(number) if number else None
+def _gh_lines(*args: str) -> list[str] | None:
+ """Run ``gh`` and return its stdout lines, or ``None`` when it fails."""
+ try:
+ completed = subprocess.run(
+ ["gh", *args],
+ check=False,
+ capture_output=True,
+ text=True,
+ timeout=30,
+ )
+ except (OSError, subprocess.TimeoutExpired):
+ return None
+ if completed.returncode != 0:
+ return None
+ return [line.strip() for line in completed.stdout.splitlines() if line.strip()]
+
+
def pull_request_changed_files() -> list[str]:
"""Recover the PR file list when the compare API returned nothing.
@@ -312,26 +451,26 @@ def pull_request_changed_files() -> list[str]:
pr = _pull_request_number()
if not repo or not pr:
return []
- try:
- completed = subprocess.run(
- [
- "gh",
- "api",
- "--paginate",
- f"repos/{repo}/pulls/{pr}/files",
- "--jq",
- ".[].filename",
- ],
- check=False,
- capture_output=True,
- text=True,
- timeout=30,
- )
- except (OSError, subprocess.TimeoutExpired):
- return []
- if completed.returncode != 0:
+ return _gh_lines("api", "--paginate", f"repos/{repo}/pulls/{pr}/files", "--jq", ".[].filename") or []
+
+
+def pull_request_labels() -> list[str]:
+ """The pull request's labels as they are now, not as the event saw them.
+
+ A re-run replays the original event payload, so the payload alone would
+ miss a ``run-e2e`` label added after the push. The API answer wins; the
+ payload is the fallback when the API call fails.
+ """
+ if os.environ.get("EVENT_NAME") != "pull_request":
return []
- return [line.strip() for line in completed.stdout.splitlines() if line.strip()]
+ repo = os.environ.get("REPO") or os.environ.get("GITHUB_REPOSITORY") or ""
+ pr = _pull_request_number()
+ if repo and pr:
+ live = _gh_lines("api", f"repos/{repo}/pulls/{pr}", "--jq", ".labels[].name")
+ if live is not None:
+ return live
+ labels = (_event_payload().get("pull_request") or {}).get("labels") or []
+ return [label["name"] for label in labels if isinstance(label, dict) and label.get("name")]
def main() -> int:
@@ -345,7 +484,7 @@ def main() -> int:
file=sys.stderr,
)
files = recovered
- lanes = classify(files)
+ lanes = classify(files, run_e2e=RUN_E2E_LABEL in pull_request_labels())
out = "\n".join([
*(f"{key}={str(value).lower()}" for key, value in lanes.items()),
f"ci_review_files={json.dumps(ci_review_files(files))}",
diff --git a/tests/ci/test_classify_changes.py b/tests/ci/test_classify_changes.py
index 807f04fbcf4..96946f65bea 100644
--- a/tests/ci/test_classify_changes.py
+++ b/tests/ci/test_classify_changes.py
@@ -26,6 +26,7 @@ _spec.loader.exec_module(_mod)
classify = _mod.classify
ci_review_files = _mod.ci_review_files
pull_request_changed_files = _mod.pull_request_changed_files
+pull_request_labels = _mod.pull_request_labels
main = _mod.main
DEFAULT = {
@@ -35,6 +36,10 @@ DEFAULT = {
"docker": True,
"docker_meta": True,
"nix": True,
+ "e2e": True,
+ "e2e_upgrade": True,
+ "e2e_desktop_core": True,
+ "e2e_desktop_update": True,
"site": True,
"scan": True,
"deps": True,
@@ -47,21 +52,27 @@ DEFAULT = {
"ci_review": True,
}
+SLOW_LANES = {"docker", "nix", "e2e", "e2e_upgrade", "e2e_desktop_core", "e2e_desktop_update"}
-def _lanes(python=False, frontend=False, site=False, scan=False, deps=False, uv_lock=False, npm_lock=False, bootstrap=False, desktop_updater=False, rust=False, mcp_catalog=False, docker_meta=False, ci_review=False, python_prod=None, nix=None, docker=None) -> dict[str, bool]:
+
+def _lanes(python=False, frontend=False, site=False, scan=False, deps=False, uv_lock=False, npm_lock=False, bootstrap=False, desktop_updater=False, rust=False, mcp_catalog=False, docker_meta=False, ci_review=False, python_prod=None, nix=False, docker=None, e2e=False, e2e_upgrade=False, e2e_desktop_core=False, e2e_desktop_update=False) -> dict[str, bool]:
# python_prod tracks python except for tests-only diffs; default it to
# python so the majority of cases don't need to spell it out.
#
- # docker and nix are derived: both build the product, so both ride on
- # python_prod and frontend. The image ships the built web assets, and the
- # flake bundles the compiled ui-tui. Pass either explicitly to override.
+ # The slow lanes (docker, nix, the E2E suites) are off unless the case
+ # names them: an ordinary product change reaches them on main, not on
+ # the PR. Docker meta files are docker-lane paths, so docker follows
+ # docker_meta unless the case says otherwise.
_python_prod = python if python_prod is None else python_prod
- _product = _python_prod or frontend
return {
"python": python,
"python_prod": _python_prod,
- "docker": (docker_meta or _product) if docker is None else docker,
- "nix": _product if nix is None else nix,
+ "docker": docker_meta if docker is None else docker,
+ "nix": nix,
+ "e2e": e2e,
+ "e2e_upgrade": e2e_upgrade,
+ "e2e_desktop_core": e2e_desktop_core,
+ "e2e_desktop_update": e2e_desktop_update,
"frontend": frontend,
"docker_meta": docker_meta,
"site": site,
@@ -84,12 +95,17 @@ CASES = {
"python source → python": (["run_agent.py"], _lanes(python=True, scan=True)),
# pyproject.toml declares the pytest markers the OS lanes select on, so it
# also re-arms the desktop_updater integration tests (fail-open).
- "dep manifest → python": (["pyproject.toml"], _lanes(python=True, scan=True, deps=True, uv_lock=True, desktop_updater=True)),
- "uv.lock → python": (["uv.lock"], _lanes(python=True, uv_lock=True)),
+ # The dependency manifests are inputs to the image, the flake and every
+ # install, so they start those slow lanes on the PR itself.
+ "dep manifest → python": (
+ ["pyproject.toml"],
+ _lanes(python=True, scan=True, deps=True, uv_lock=True, desktop_updater=True, docker=True, nix=True, e2e_upgrade=True),
+ ),
+ "uv.lock → python": (["uv.lock"], _lanes(python=True, uv_lock=True, docker=True, nix=True, e2e_upgrade=True)),
"ts package → frontend": (["apps/desktop/src/app.tsx"], _lanes(frontend=True)),
"ui-tui → frontend": (["ui-tui/src/entry.ts"], _lanes(frontend=True)),
# Lockfile bump shifts every TS package's tree, but not the Python suite.
- "root lockfile → frontend, not python": (["package-lock.json"], _lanes(frontend=True, npm_lock=True)),
+ "root lockfile → frontend, not python": (["package-lock.json"], _lanes(frontend=True, npm_lock=True, docker=True, nix=True)),
"nested lockfile → npm_lock": (["website/package-lock.json"], _lanes(site=True, npm_lock=True)),
# A website file the Python suite cannot read stays site-only.
"website config → site": (["website/docusaurus.config.ts"], _lanes(site=True)),
@@ -105,11 +121,11 @@ CASES = {
# the Python side must run even when nothing else in the PR is Python.
"generated gateway contract → python + frontend": (
["apps/shared/src/gateway-contract.generated.ts"],
- _lanes(python=True, frontend=True),
+ _lanes(python=True, frontend=True, e2e_desktop_core=True),
),
"gateway OpenRPC document → python + frontend": (
["apps/shared/src/gateway-contract.openrpc.json"],
- _lanes(python=True, frontend=True),
+ _lanes(python=True, frontend=True, e2e_desktop_core=True),
),
"desktop slash-registry JSON → python + frontend": (
["apps/desktop/src/lib/desktop-slash-registry.json"],
@@ -146,10 +162,10 @@ CASES = {
"flake.nix → nix only": (["flake.nix"], _lanes(nix=True)),
"flake.lock → nix only": (["flake.lock"], _lanes(nix=True)),
# A flake-only file must not mask a Python change beside it.
- "nix + python → both": (["nix/checks.nix", "agent/x.py"], _lanes(python=True, scan=True)),
- # Nine checks run the built binary, so product Python is a nix input even
- # when the diff touches no file under nix/.
- "product python → nix": (["hermes_cli/config.py"], _lanes(python=True, scan=True)),
+ "nix + python → both": (["nix/checks.nix", "agent/x.py"], _lanes(python=True, scan=True, nix=True)),
+ # Product Python can still break the flake (nine checks run the built
+ # binary), but the flake meets it on main, not on the PR.
+ "product python → no nix on the PR": (["hermes_cli/config.py"], _lanes(python=True, scan=True)),
# tests/ is not packaged, so the built binary cannot change.
"tests-only → no nix": (
["tests/agent/test_foo.py"],
@@ -159,7 +175,7 @@ CASES = {
"docs-only → no nix": (["README.md"], _lanes()),
# install.ps1 and its PowerShell suites are exercised by platforms("windows")
# pytest files, so they must turn on python (which gates tests-os).
- "install.ps1 → python": (["scripts/install.ps1"], _lanes(python=True)),
+ "install.ps1 → python + e2e_upgrade": (["scripts/install.ps1"], _lanes(python=True, e2e_upgrade=True)),
"installer suite → python": (["scripts/tests/test-install-ps1-longpath.ps1"], _lanes(python=True)),
# The Windows desktop-update hand-off is a PowerShell integration surface:
# its tests spawn the real script and poll its loopback server. They run
@@ -167,13 +183,13 @@ CASES = {
# files change — not on every hermes_state.py PR.
"windows.ps1 → desktop_updater": (
["scripts/desktop-update/windows.ps1"],
- _lanes(python=True, desktop_updater=True),
+ _lanes(python=True, desktop_updater=True, e2e_desktop_update=True),
),
# The shipped updater page is exercised by the desktop Electron suite;
# a page-only change must run that suite as well as the server tests.
"updater ui.html → frontend + desktop_updater": (
["scripts/desktop-update/ui.html"],
- _lanes(python=True, frontend=True, desktop_updater=True),
+ _lanes(python=True, frontend=True, desktop_updater=True, e2e_desktop_update=True),
),
"desktop-update test → desktop_updater": (
["tests/scripts/desktop_update/test_desktop_update_windows_progress.py"],
@@ -181,9 +197,9 @@ CASES = {
),
"updater-process.ts → desktop_updater": (
["apps/desktop/electron/updater-process.ts"],
- _lanes(frontend=True, desktop_updater=True),
+ _lanes(frontend=True, desktop_updater=True, e2e_desktop_update=True),
),
- "python source alone → no desktop_updater lane": (["hermes_state.py"], _lanes(python=True, scan=True)),
+ "python source alone → no desktop_updater lane": (["gateway/run.py"], _lanes(python=True, scan=True)),
# `.rs` lives under apps/, so it matches `frontend` too. That lane builds
# TypeScript and cannot notice a Rust error — before `rust` existed it was
# the ONLY lane a Rust change ran, and the crate's tests never executed.
@@ -216,13 +232,14 @@ CASES = {
),
# conftest.py owns the _OS_MARKS skip logic, so it re-arms the
# desktop_updater integration tests too (fail-open).
- "conftest → python + desktop_updater": (
+ # The shared harness can break every Python E2E suite.
+ "conftest → python + desktop_updater + python e2e": (
["tests/conftest.py"],
- _lanes(python=True, python_prod=False, scan=True, desktop_updater=True),
+ _lanes(python=True, python_prod=False, scan=True, desktop_updater=True, e2e=True, e2e_upgrade=True),
),
- "conftest fixture module → python + desktop_updater": (
+ "conftest fixture module → python + desktop_updater + python e2e": (
["tests/_fixtures/platform_gating.py"],
- _lanes(python=True, python_prod=False, scan=True, desktop_updater=True),
+ _lanes(python=True, python_prod=False, scan=True, desktop_updater=True, e2e=True, e2e_upgrade=True),
),
"tests + prod source → both lanes": (
["tests/agent/test_foo.py", "agent/x.py"],
@@ -234,11 +251,11 @@ CASES = {
# .py/.pth payloads are what it scans for).
"test runner script → python_prod stays on": (
["scripts/run_tests_parallel.py"],
- _lanes(python=True, scan=True),
+ _lanes(python=True, scan=True, e2e=True, e2e_upgrade=True),
),
# Supply-chain lanes
".pth file → scan": (["evil.pth"], _lanes(python=True, scan=True)),
- "setup.py → scan": (["setup.py"], _lanes(python=True, scan=True)),
+ "setup.py → scan": (["setup.py"], _lanes(python=True, scan=True, docker=True, nix=True, e2e_upgrade=True)),
"mcp catalog manifest → mcp_catalog": (
["optional-mcps/foo/manifest.yaml"],
_lanes(python=True, mcp_catalog=True),
@@ -284,11 +301,11 @@ CASES = {
# and the Tauri app's non-Rust sources.
"install.sh → bootstrap lane": (
["scripts/install.sh"],
- _lanes(python=True, bootstrap=True, python_prod=True),
+ _lanes(python=True, bootstrap=True, python_prod=True, e2e_upgrade=True, e2e_desktop_update=True),
),
"setup-hermes.sh → bootstrap lane": (
["setup-hermes.sh"],
- _lanes(python=True, bootstrap=True, python_prod=True),
+ _lanes(python=True, bootstrap=True, python_prod=True, e2e_upgrade=True),
),
"tauri installer source → bootstrap + rust": (
["apps/bootstrap-installer/src-tauri/src/lib.rs"],
@@ -303,6 +320,45 @@ CASES = {
["apps/desktop/src/app.tsx"],
_lanes(frontend=True),
),
+ # Slow lanes on a pull request: an ordinary product change starts none of
+ # them; the suite, its harness, or the code it guards starts its own.
+ "gateway python → no slow lane": (["gateway/run.py", "agent/x.py"], _lanes(python=True, scan=True)),
+ "desktop renderer → no slow lane": (["apps/desktop/src/app/chat/composer.tsx"], _lanes(frontend=True)),
+ "python e2e suite → e2e only": (
+ ["tests/e2e/core/sqlite/test_torture.py"],
+ _lanes(python=True, python_prod=False, scan=True, e2e=True),
+ ),
+ "state db → e2e": (["hermes_state_wal.py"], _lanes(python=True, scan=True, e2e=True)),
+ "upgrade suite → e2e_upgrade, not e2e": (
+ ["tests/e2e/core/upgrade/pm/test_pm_lifecycle.py"],
+ _lanes(python=True, python_prod=False, scan=True, e2e_upgrade=True),
+ ),
+ "updater → e2e_upgrade + desktop update": (
+ ["hermes_cli/update_cmd_git.py"],
+ _lanes(python=True, scan=True, e2e_upgrade=True, e2e_desktop_update=True),
+ ),
+ "PM → e2e_upgrade + docker": (["pm/environments.py"], _lanes(python=True, scan=True, e2e_upgrade=True, docker=True)),
+ "desktop backend spawn → desktop core": (
+ ["apps/desktop/electron/backend-child.ts"],
+ _lanes(frontend=True, e2e_desktop_core=True),
+ ),
+ "desktop core spec → desktop core": (
+ ["apps/desktop/e2e/core/transcript-integrity.spec.ts"],
+ _lanes(frontend=True, e2e_desktop_core=True),
+ ),
+ "desktop update spec → desktop update, not core": (
+ ["apps/desktop/e2e/update/app-update.spec.ts"],
+ _lanes(frontend=True, e2e_desktop_update=True),
+ ),
+ # The update suite runs on the core suite's harness.
+ "desktop core harness → both desktop suites": (
+ ["apps/desktop/e2e/core/harness.ts"],
+ _lanes(frontend=True, e2e_desktop_core=True, e2e_desktop_update=True),
+ ),
+ "image tests → docker": (
+ ["tests/docker/test_image_smoke.py"],
+ _lanes(python=True, python_prod=False, scan=True, docker=True),
+ ),
# Fail open: CI-config / empty / blank diffs run everything.
".github change → all": ([".github/workflows/tests.yml"], DEFAULT),
"action change → all": ([".github/actions/detect-changes/action.yml"], DEFAULT),
@@ -316,6 +372,37 @@ def test_classify(files, expected):
assert classify(files) == expected
[email protected]("files", [["README.md"], ["gateway/run.py"], ["apps/desktop/src/app.tsx"]])
+def test_run_e2e_label_turns_every_slow_lane_on_and_nothing_else(files):
+ labelled = classify(files, run_e2e=True)
+ assert {lane for lane in SLOW_LANES if labelled[lane]} == SLOW_LANES
+ unlabelled = classify(files)
+ assert {k: v for k, v in labelled.items() if k not in SLOW_LANES} == \
+ {k: v for k, v in unlabelled.items() if k not in SLOW_LANES}
+
+
+def test_every_slow_lane_path_matches_a_tracked_file():
+ """A renamed file silently stops starting its lane on pull requests.
+
+ Every prefix in the slow-lane tables must still match something in the
+ tree, or the lane only ever runs on main.
+ """
+ tracked = subprocess.run(
+ ["git", "ls-files"], cwd=_REPO, capture_output=True, text=True, check=False,
+ )
+ if tracked.returncode != 0:
+ pytest.skip("not a git checkout")
+ files = tracked.stdout.splitlines()
+ tables = {**_mod._E2E_LANES, "docker": _mod._DOCKER_PATHS, "nix": _mod._NIX_LANE_PATHS}
+ dead = {
+ (lane, prefix)
+ for lane, prefixes in tables.items()
+ for prefix in prefixes
+ if not any(f.startswith(prefix) for f in files)
+ }
+ assert dead == set()
+
+
_REPO = Path(__file__).resolve().parents[2]
@@ -355,11 +442,16 @@ def test_ci_jobs_only_gate_on_detect_outputs_that_detect_actually_declares():
def _iter_if_expressions(job: object):
- """Yield every ``if:`` string in a job, including inside its steps."""
+ """Yield every ``if:`` string in a job, including inside its steps, plus
+ every reusable-workflow ``with:`` value (an undeclared output passed as an
+ input is the same silent "")."""
if not isinstance(job, dict):
return
if isinstance(cond := job.get("if"), str):
yield cond
+ for value in (job.get("with") or {}).values():
+ if isinstance(value, str):
+ yield value
for step in job.get("steps", []) or []:
if isinstance(step, dict) and isinstance(cond := step.get("if"), str):
yield cond
@@ -454,3 +546,31 @@ def test_main_still_fail_opens_when_recovery_is_empty(monkeypatch, capsys):
assert main() == 0
out = capsys.readouterr().out
assert "ci_review=true" in out
+
+
+def test_main_reads_the_run_e2e_label(monkeypatch, capsys):
+ monkeypatch.setattr(_mod, "pull_request_labels", lambda: ["ci-reviewed", _mod.RUN_E2E_LABEL])
+ monkeypatch.setattr(sys, "stdin", io.StringIO("gateway/run.py\n"))
+ monkeypatch.delenv("GITHUB_OUTPUT", raising=False)
+
+ assert main() == 0
+ out = capsys.readouterr().out
+ assert all(f"{lane}=true" in out for lane in SLOW_LANES)
+
+
+def test_pull_request_labels_prefers_the_live_labels_over_the_replayed_event(tmp_path, monkeypatch):
+ """A rerun replays the push's payload; a label added since must still count."""
+ event = tmp_path / "event.json"
+ event.write_text(json.dumps({"pull_request": {"number": 7, "labels": []}}), encoding="utf-8")
+ monkeypatch.setenv("EVENT_NAME", "pull_request")
+ monkeypatch.setenv("REPO", "NousResearch/hermes-agent")
+ monkeypatch.setenv("GITHUB_EVENT_PATH", str(event))
+
+ live = subprocess.CompletedProcess([], 0, stdout="run-e2e\n", stderr="")
+ monkeypatch.setattr(_mod.subprocess, "run", lambda *a, **k: live)
+ assert pull_request_labels() == ["run-e2e"]
+
+ failed = subprocess.CompletedProcess([], 1, stdout="", stderr="gh: Not Found")
+ monkeypatch.setattr(_mod.subprocess, "run", lambda *a, **k: failed)
+ event.write_text(json.dumps({"pull_request": {"number": 7, "labels": [{"name": "run-e2e"}]}}), encoding="utf-8")
+ assert pull_request_labels() == ["run-e2e"]