molecule-core/tools/gate-check-v3/test_gate_check.py
Molecule AI Core-BE f908aa894b
All checks were successful
sop-checklist / all-items-acked (pull_request) injected after rebase
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 20s
CI / Detect changes (pull_request) Successful in 1m8s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m5s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 1m1s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 58s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 26s
qa-review / approved (pull_request) Successful in 27s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m38s
security-review / approved (pull_request) Successful in 30s
gate-check-v3 / gate-check (pull_request) Successful in 44s
sop-checklist-gate / gate (pull_request) Successful in 21s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m7s
sop-tier-check / tier-check (pull_request) Successful in 26s
audit-force-merge / audit (pull_request) Successful in 23s
CI / Platform (Go) (pull_request) Successful in 11s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 13s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 8s
CI / Canvas (Next.js) (pull_request) Successful in 11s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 12s
CI / Python Lint & Test (pull_request) Successful in 9s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 11s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 7s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 5s
fix(gate-check): map infra-sre Gitea login to core-devops agent
infra-sre IS the engineers/core-devops agent (same team, same work).
Without this alias, infra-sre reviews and comments never satisfy the
engineers gate in signal_1_comment_scan, causing PRs to remain blocked
even when infra-sre explicitly posts [devops-agent] APPROVED.

Changes:
- Add LOGIN_ALIASES dict: infra-sre → core-devops
- Resolve aliases in signal_1_comment_scan comment-matching loop
- Resolve aliases in signal_1_comment_scan reviews collection
- Add test covering infra-sre APPROVED review → engineers CLEAR

Fixes #896.

[core-be-agent]

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 22:37:50 +00:00

77 lines
2.5 KiB
Python

import importlib.util
import pathlib
SCRIPT = pathlib.Path(__file__).with_name("gate_check.py")
def load_gate_check():
spec = importlib.util.spec_from_file_location("gate_check", SCRIPT)
mod = importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(mod)
return mod
def test_run_skips_pr_not_targeting_default_branch(monkeypatch):
mod = load_gate_check()
def fake_api_get(path):
assert path == "/repos/molecule-ai/molecule-core/pulls/843"
return {
"number": 843,
"base": {"ref": "staging"},
"head": {"sha": "84b9ca3a129075b8d5159eda5e678f68be1af20f"},
}
monkeypatch.setenv("DEFAULT_BRANCH", "main")
monkeypatch.setattr(mod, "api_get", fake_api_get)
result = mod.run("molecule-ai/molecule-core", 843, post_comment=False)
assert result["verdict"] == "CLEAR"
assert result["skipped"] is True
assert "staging" in result["reason"]
def test_signal_1_infra_sre_login_alias_resolved_to_core_devops(monkeypatch):
"""infra-sre posts [devops-agent] APPROVED → engineers gate satisfied via LOGIN_ALIASES."""
mod = load_gate_check()
def fake_api_get(path):
# PR 900 has tier:low label
if path == "/repos/molecule-ai/molecule-core/pulls/900":
return {
"number": 900,
"labels": [{"name": "tier:low"}],
}
raise AssertionError(f"unexpected api_get: {path}")
def fake_api_list(path):
if path == "/repos/molecule-ai/molecule-core/issues/900/comments":
return []
if path == "/repos/molecule-ai/molecule-core/pulls/900/comments":
return []
if path == "/repos/molecule-ai/molecule-core/pulls/900/reviews":
return [
{
"id": 1,
"user": {"login": "infra-sre"},
"state": "APPROVED",
"submitted_at": "2026-05-13T10:00:00Z",
}
]
raise AssertionError(f"unexpected api_list: {path}")
monkeypatch.setattr(mod, "api_get", fake_api_get)
monkeypatch.setattr(mod, "api_list", fake_api_list)
result = mod.signal_1_comment_scan(900, "molecule-ai/molecule-core")
assert result["verdict"] == "CLEAR"
assert result["signal"] == "agent_tag_comments"
# infra-sre (aliased to core-devops) should satisfy engineers gate
engineers = result["results"]["core-devops"]
assert engineers["verdict"] == "APPROVED"
assert engineers["group"] == "engineers"