Skip to content

The agent that grows with you

ci: catalog-only PRs run the catalog tests instead of the full suite

Teknium275b15fc3519
diff --git a/.github/actions/detect-changes/action.yml b/.github/actions/detect-changes/action.yml
index 906d24a0e2b..4473f528eaa 100644
--- a/.github/actions/detect-changes/action.yml
+++ b/.github/actions/detect-changes/action.yml
@@ -69,6 +69,9 @@ outputs:
remote_backends:
description: Run the SSH and Docker terminal backends against a real sshd and Docker daemon.
value: ${{ steps.classify.outputs.remote_backends }}
+ catalog:
+ description: Run the plugin-catalog tests (catalog-only diffs run these instead of the Python suite).
+ value: ${{ steps.classify.outputs.catalog }}
runs:
using: composite
diff --git a/.github/workflows/catalog-tests.yml b/.github/workflows/catalog-tests.yml
new file mode 100644
index 00000000000..ffdbf45364d
--- /dev/null
+++ b/.github/workflows/catalog-tests.yml
@@ -0,0 +1,59 @@
+name: Catalog tests
+
+# The tests that read plugin-catalog entries and contributor email maps. ci.yaml
+# calls this INSTEAD of the full Python suite when a PR changes only catalog
+# entry data (the classifier's `catalog` lane): a one-entry PR used to run 23k
+# tests on three OSes, where unrelated flakes blocked it. The structural and
+# pinned-source admission gates stay in plugin-catalog-ci.yml.
+#
+# The test set is discovered, not listed: every test file outside tests/e2e that
+# references the catalog or the email maps, so a new catalog test joins the lane
+# by existing.
+
+on:
+ workflow_call:
+ inputs:
+ commit:
+ description: Commit to test. Empty keeps the triggering commit.
+ type: string
+ default: ''
+
+permissions:
+ contents: read
+
+concurrency:
+ group: catalog-tests-${{ (github.ref_type == 'tag' || inputs.commit != '') && github.run_id || github.ref }}
+ cancel-in-progress: ${{ github.ref_type != 'tag' && inputs.commit == '' }}
+
+jobs:
+ catalog-tests:
+ name: Catalog tests
+ runs-on: blacksmith-4vcpu-ubuntu-2404
+ timeout-minutes: 15
+ steps:
+ - name: Checkout code
+ uses: useblacksmith/checkout@25227e61ff9dafe400e22fa487b673eac4e4409a # v1
+ with:
+ ref: ${{ inputs.commit }}
+ persist-credentials: false
+
+ - name: Set up locked Python and test dependencies
+ uses: ./.github/actions/setup-pm
+ with:
+ extras: '[]'
+ test-environment: 'true'
+ prune-python-cache: true
+
+ - name: Run the catalog tests
+ env:
+ OPENROUTER_API_KEY: ""
+ OPENAI_API_KEY: ""
+ NOUS_API_KEY: ""
+ run: |
+ set -euo pipefail
+ mapfile -t FILES < <(python3 scripts/ci/catalog_test_files.py)
+ echo "Catalog test files (${#FILES[@]}):"; printf ' %s\n' "${FILES[@]}"
+ scripts/run_tests.sh "${FILES[@]}"
+
+ - name: Check the checkout is clean
+ uses: ./.github/actions/check-clean-worktree
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 005a2bf68f7..638b5daec07 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -85,6 +85,7 @@ jobs:
desktop_updater: ${{ steps.gate-lanes.outputs.desktop_updater }}
rust: ${{ steps.gate-lanes.outputs.rust }}
remote_backends: ${{ steps.gate-lanes.outputs.remote_backends }}
+ catalog: ${{ steps.gate-lanes.outputs.catalog }}
docker_meta: ${{ steps.gate-lanes.outputs.docker_meta }}
e2e: ${{ steps.gate-lanes.outputs.e2e }}
e2e_upgrade: ${{ steps.gate-lanes.outputs.e2e_upgrade }}
@@ -203,6 +204,17 @@ jobs:
with:
commit: ${{ inputs.commit }}
+ catalog-tests:
+ name: Catalog tests
+ needs: detect
+ # A PR that changes only catalog entry data runs these instead of the
+ # Python suite (the classifier turns `python` off for it); required whenever
+ # detect selects it.
+ if: needs.detect.outputs.catalog == 'true'
+ uses: ./.github/workflows/catalog-tests.yml
+ with:
+ commit: ${{ inputs.commit }}
+
remote-backends:
name: Remote terminal backends
needs: detect
@@ -290,7 +302,7 @@ jobs:
contributor-check:
name: Check contributors
needs: detect
- if: needs.detect.outputs.python == 'true'
+ if: needs.detect.outputs.python == 'true' || needs.detect.outputs.catalog == 'true'
uses: ./.github/workflows/contributor-check.yml
with:
commit: ${{ inputs.commit }}
@@ -422,6 +434,7 @@ jobs:
- js-tests
- rust-tests
- remote-backends
+ - catalog-tests
- bootstrap-installer
- e2e-desktop
- e2e-desktop-core
diff --git a/scripts/ci/catalog_test_files.py b/scripts/ci/catalog_test_files.py
new file mode 100644
index 00000000000..8ea6fc1e3c0
--- /dev/null
+++ b/scripts/ci/catalog_test_files.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+"""Print the test files the ``catalog`` CI lane runs (catalog-tests.yml).
+
+Every ``tests/**/test_*.py`` outside ``tests/e2e/`` whose source names the
+plugin catalog or the contributor email maps. Discovery instead of a list, so a
+new test that reads ``plugin-catalog/`` joins the lane without anyone editing
+CI. Over-selection only costs seconds; a missed file is a test a catalog-only
+PR never runs.
+"""
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+
+REPO = Path(__file__).resolve().parents[2]
+PATTERN = re.compile(
+ r"plugin[-_]catalog|load_catalog|get_catalog_dir|contributors[/\"' ,]+emails"
+ r"|extract-plugins|fetch-plugin-stars|shared_metrics_catalog"
+)
+
+
+def catalog_test_files(repo: Path = REPO) -> list[str]:
+ out = []
+ for path in sorted((repo / "tests").rglob("test_*.py")):
+ rel = path.relative_to(repo).as_posix()
+ if rel.startswith("tests/e2e/"):
+ continue
+ if PATTERN.search(path.read_text(encoding="utf-8-sig", errors="replace")):
+ out.append(rel)
+ return out
+
+
+if __name__ == "__main__":
+ print("\n".join(catalog_test_files()))
diff --git a/scripts/ci/classify_changes.py b/scripts/ci/classify_changes.py
index 9d6a0b5694f..f65edcc7cb5 100644
--- a/scripts/ci/classify_changes.py
+++ b/scripts/ci/classify_changes.py
@@ -40,6 +40,12 @@ Lanes:
* ``rust`` — ``cargo test`` for the Tauri bootstrap installer. ``.rs``
lives under ``apps/``, so without this lane a Rust change matched ``frontend``
and only the TypeScript matrix ran.
+* ``catalog`` — the plugin-catalog tests (catalog-tests.yml). A diff made
+ only of catalog entry data (``plugin-catalog/*.yaml``, ``contributors/emails/``)
+ runs this lane INSTEAD of the Python suite: those files are data that a known
+ set of tests reads, so a one-entry PR need not run 23k tests on three OSes.
+ ``plugin-catalog/README.md`` is not entry data (a docs page mirrors it), and
+ any other file in the diff brings the full Python suite back.
* ``remote_backends`` — the SSH and Docker terminal backends against a real
sshd container and the runner's Docker daemon (remote-backends.yml). Every
other test of those backends is mocked, so a change to the backends, the
@@ -125,6 +131,10 @@ _PY_RELEVANT_CONTRACT_FILES = {
"plugin-catalog/README.md",
}
+# Catalog entry data: read by the catalog tests and the Plugin Catalog CI
+# admission gate, executed by nothing. Same set that gate allows in an entry PR.
+_CATALOG_DATA = ("plugin-catalog/", "contributors/emails/")
+
# Supply-chain scan: files that can execute code at install/import time.
_SCAN_EXTS = (".py", ".pth")
_SCAN_FILES = {"setup.cfg", "pyproject.toml"}
@@ -529,6 +539,10 @@ def _py_irrelevant(p: str) -> bool:
)
+def _is_catalog_data(p: str) -> bool:
+ return p.startswith(_CATALOG_DATA) and p not in _PY_RELEVANT_CONTRACT_FILES
+
+
def _py_test_only(p: str) -> bool:
"""Is ``p`` inside the test suite (never shipped / imported by the product)?
@@ -582,8 +596,10 @@ def classify(files: list[str], run_e2e: bool = False) -> dict[str, bool]:
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)
+ catalog = any(_is_catalog_data(f) for f in files)
+ code = [f for f in files if not _is_catalog_data(f)]
+ python = any(not _py_irrelevant(f) for f in code)
+ python_prod = any(not _py_irrelevant(f) and not _py_test_only(f) for f in code)
frontend = any(
f.startswith(_FRONTEND) or f in _ROOT_NPM or f in _FRONTEND_FILES
or f.startswith("tests-js/")
@@ -610,6 +626,7 @@ def classify(files: list[str], run_e2e: bool = False) -> dict[str, bool]:
"desktop_updater": any(_is_desktop_updater(f) for f in files),
"rust": any(_is_rust(f) for f in files),
"remote_backends": any(f.startswith(_REMOTE_BACKEND_PATHS) for f in files),
+ "catalog": catalog,
**{lane: run_e2e or on for lane, on in _slow_lanes(files).items()},
}
consumers = [c for f in files for c in _SHARED_FIXTURE_CONSUMERS.get(f, ())]
@@ -631,6 +648,7 @@ def classify(files: list[str], run_e2e: bool = False) -> dict[str, bool]:
ret["desktop_updater"] = True
ret["rust"] = True
ret["remote_backends"] = True
+ ret["catalog"] = True
ret.update(dict.fromkeys(_slow_lanes([]), True))
return ret
diff --git a/scripts/ci/required_results.py b/scripts/ci/required_results.py
index 1e6dbd014c9..6a9da5f3f24 100644
--- a/scripts/ci/required_results.py
+++ b/scripts/ci/required_results.py
@@ -30,7 +30,7 @@ EXCLUDED_JOBS = frozenset((*PR_ONLY_JOBS, *DEFERRED_JOBS))
NEEDS_JSON_OUTPUT = "needs-json"
# Reusable-workflow parents of the update/E2E consumers, and of the real
-# remote-backend lane. The actual detect outputs already arrive in
+# remote-backend and catalog lanes. The actual detect outputs already arrive in
# toJSON(needs); a selected consumer cannot skip merely because this is a PR
# rather than a release.
_UPDATE_CONSUMER_LANES = {
@@ -38,6 +38,7 @@ _UPDATE_CONSUMER_LANES = {
"tests-os": ("python", "desktop_updater", "e2e", "e2e_upgrade"),
"e2e-desktop-update": ("e2e_desktop_update",),
"remote-backends": ("remote_backends",),
+ "catalog-tests": ("catalog",),
}
diff --git a/tests/ci/test_classify_changes.py b/tests/ci/test_classify_changes.py
index 906942e3f9c..9bc6a34c70a 100644
--- a/tests/ci/test_classify_changes.py
+++ b/tests/ci/test_classify_changes.py
@@ -48,12 +48,13 @@ DEFAULT = {
"desktop_updater": True,
"rust": True,
"remote_backends": True,
+ "catalog": 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, docker_meta=False, python_prod=None, nix=False, docker=None, e2e=False, e2e_upgrade=False, e2e_desktop_core=False, e2e_desktop_update=False, remote_backends=False) -> 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, docker_meta=False, python_prod=None, nix=False, docker=None, e2e=False, e2e_upgrade=False, e2e_desktop_core=False, e2e_desktop_update=False, remote_backends=False, catalog=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.
#
@@ -82,6 +83,7 @@ def _lanes(python=False, frontend=False, site=False, scan=False, deps=False, uv_
"desktop_updater": desktop_updater,
"rust": rust,
"remote_backends": remote_backends,
+ "catalog": catalog,
}
@@ -407,6 +409,19 @@ CASES = {
["tests/docker/test_image_smoke.py"],
_lanes(python=True, python_prod=False, scan=True, docker=True),
),
+ # Catalog entry data runs the catalog tests INSTEAD of the Python suite.
+ "catalog entry → catalog only": (["plugin-catalog/foo.yaml"], _lanes(catalog=True)),
+ "catalog entry + email map → catalog only": (
+ ["plugin-catalog/foo.yaml", "contributors/emails/[email protected]"],
+ _lanes(catalog=True),
+ ),
+ # The rules README is mirrored by a docs-page test, so it keeps the suite.
+ "catalog README → python": (["plugin-catalog/README.md"], _lanes(python=True)),
+ # Any code next to the entry brings the full suite back.
+ "catalog entry + code → python and catalog": (
+ ["plugin-catalog/foo.yaml", "agent/display.py"],
+ _lanes(python=True, scan=True, catalog=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),
@@ -580,6 +595,8 @@ _REAL_UPDATE_LANES = (
("tests-os.yml", "install-update-e2e", "windows-install-update-e2e.yml", "e2e_upgrade"),
# Not an update suite, but the same contract: the real SSH/Docker backend lane.
("ci.yaml", "remote-backends", "remote-backends.yml", "remote_backends"),
+ # Catalog-only PRs skip the suite, so their catalog tests must gate the merge.
+ ("ci.yaml", "catalog-tests", "catalog-tests.yml", "catalog"),
)
@@ -730,3 +747,22 @@ def test_pull_request_labels_prefers_the_live_labels_over_the_replayed_event(tmp
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"]
+
+
+def test_catalog_lane_runs_every_test_that_reads_the_shipped_catalog():
+ """A catalog-only PR runs only the lane's discovered files, so a test that
+ reads the real ``plugin-catalog/`` must be among them."""
+ spec = importlib.util.spec_from_file_location("catalog_test_files", _REPO / "scripts/ci/catalog_test_files.py")
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
+ files = set(mod.catalog_test_files())
+ for must in (
+ "tests/hermes_cli/test_plugin_catalog.py",
+ "tests/scripts/test_validate_plugin_catalog.py",
+ "tests/scripts/test_contributor_map.py",
+ "tests/website/test_extract_plugins.py",
+ ):
+ assert must in files
+ assert not any(f.startswith("tests/e2e/") for f in files)
+ text = (_REPO / ".github/workflows/catalog-tests.yml").read_text(encoding="utf-8-sig")
+ assert "scripts/ci/catalog_test_files.py" in text and "scripts/run_tests.sh" in text
diff --git a/tests/ci/test_required_results.py b/tests/ci/test_required_results.py
index 22ef268cf0b..61c8df32ba3 100644
--- a/tests/ci/test_required_results.py
+++ b/tests/ci/test_required_results.py
@@ -42,6 +42,7 @@ def test_status_policy(job, result, ordinary, excluded, release):
("desktop_updater", ("tests-os",)),
("e2e_desktop_update", ("e2e-desktop-update",)),
("remote_backends", ("remote-backends",)),
+ ("catalog", ("catalog-tests",)),
])
@pytest.mark.parametrize("result", ["skipped", "absent", "success"])
def test_selected_update_consumers_must_succeed(lane, jobs, result):