Skip to content

The agent that grows with you

ci: run the messaging-gated gateway cases in the messaging-equipped e2e job

Tekniumab386ebd5f16
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 76f17c52ea9..92f7e995d3b 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -179,6 +179,27 @@ jobs:
run: |
"$HERMES_PYTHON" -c "import sqlite3, hermes_state_wal as w; print('sqlite', sqlite3.sqlite_version); assert not w.is_sqlite_wal_reset_vulnerable()"
+ - name: Run messaging-gated gateway cases
+ # These gateway files drive the REAL Discord/Telegram SDKs and skip when the
+ # `messaging` extra is absent, which it is in the ordinary `test` slices; this is
+ # the only job that installs it. Whole files (run_tests.sh drops ::node selectors),
+ # and a skip here is a coverage hole, not a pass: fail on any.
+ run: |
+ set -o pipefail
+ log="$RUNNER_TEMP/messaging-gateway.log"
+ scripts/run_tests.sh -rs \
+ tests/gateway/test_native_role_reauthorization.py \
+ tests/gateway/test_native_telegram_startup_recovery.py \
+ tests/gateway/test_native_pause_notice.py | tee "$log"
+ summary=$(grep '^=== Summary:' "$log")
+ case "$summary" in
+ *skipped*) echo "::error::messaging-gated gateway cases skipped: $summary"; exit 1 ;;
+ esac
+ env:
+ OPENROUTER_API_KEY: ""
+ OPENAI_API_KEY: ""
+ NOUS_API_KEY: ""
+
- name: Run e2e tests
# One subprocess per file, in parallel: the core suites spawn real
# processes (serve, gateway, tui_gateway, MCP servers, SQLite writers)
diff --git a/scripts/ci/classify_changes.py b/scripts/ci/classify_changes.py
index 7a011042aec..68fba739008 100644
--- a/scripts/ci/classify_changes.py
+++ b/scripts/ci/classify_changes.py
@@ -374,6 +374,11 @@ _E2E_LANES: dict[str, tuple[str, ...]] = {
# The state.db torture chamber and the compaction/exactly-once
# suites are the only tests that run real concurrent writers.
"hermes_state",
+ # Messaging-gated gateway cases: only the e2e job installs the real
+ # Discord/Telegram SDKs (tests.yml "Run messaging-gated gateway cases").
+ "tests/gateway/test_native_role_reauthorization.py",
+ "tests/gateway/test_native_telegram_startup_recovery.py",
+ "tests/gateway/test_native_pause_notice.py",
),
"e2e_upgrade": (
*_PY_TEST_HARNESS,
diff --git a/tests/ci/test_messaging_gated_selection.py b/tests/ci/test_messaging_gated_selection.py
new file mode 100644
index 00000000000..da42e15819e
--- /dev/null
+++ b/tests/ci/test_messaging_gated_selection.py
@@ -0,0 +1,35 @@
+"""Dependency-gated gateway cases run in a job that has their dependency.
+
+The ordinary pytest slices omit the ``messaging`` extra, so a gateway test that probes for the REAL
+Discord/Telegram/Slack distribution skips there. Only the e2e job installs that extra; every such
+file must be named by its messaging step (and start the e2e lane), or it is never run anywhere.
+"""
+from __future__ import annotations
+
+import importlib.util
+import re
+from pathlib import Path
+
+import pytest
+
+_REPO = Path(__file__).resolve().parents[2]
+_SDK_PROBE = re.compile(r"PathFinder\.find_spec\(\s*[\"'](discord|telegram|slack_bolt|slack_sdk)[\"']\s*\)")
+
+
+def test_every_messaging_gated_gateway_file_runs_in_the_messaging_job():
+ gated = sorted(str(path.relative_to(_REPO)) for path in (_REPO / "tests" / "gateway").glob("test_*.py")
+ if _SDK_PROBE.search(path.read_text(encoding="utf-8")))
+ assert gated, "no messaging-gated gateway file found; the probe pattern drifted"
+ yaml = pytest.importorskip("hermes_yaml")
+ job = yaml.safe_load((_REPO / ".github" / "workflows" / "tests.yml").read_text(encoding="utf-8"))["jobs"]["e2e"]
+ extras = next(step["with"]["extras"] for step in job["steps"] if "setup-pm" in step.get("uses", ""))
+ assert "messaging" in extras
+ script = "\n".join(step.get("run", "") for step in job["steps"] if "messaging-gated" in step.get("name", ""))
+ missing = [path for path in gated if path not in script]
+ assert not missing, f"never run with their SDK installed: {missing}"
+ # A skip in that step is a coverage hole, not a pass.
+ assert "-rs" in script and "skipped" in script
+ spec = importlib.util.spec_from_file_location("classify_changes", _REPO / "scripts" / "ci" / "classify_changes.py")
+ classify_changes = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(classify_changes)
+ assert all(classify_changes.classify([path])["e2e"] for path in gated), "editing one must start the e2e job"