Skip to content

Commit 2b26db0

Browse files
committed
feat(health): check the org profile repo and TechMachine itself
The .github repo has no workflows and no endpoint; the check lists its workflows, finds none and reports nothing, which a test now pins down. TechMachine was the one repository with workflows that nothing watched.
1 parent 365d273 commit 2b26db0

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎machine/repos.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@
3838
"allowed_secrets": [
3939
"TECHENGINEBOT_TOKEN"
4040
]
41+
},
42+
{
43+
"name": "GetTechAPI/.github",
44+
"branches": [
45+
"main"
46+
]
47+
},
48+
{
49+
"name": "GetTechAPI/TechMachine",
50+
"branches": [
51+
"develop",
52+
"main"
53+
],
54+
"allowed_secrets": [
55+
"TECHENGINEBOT_TOKEN"
56+
]
4157
}
4258
],
4359
"endpoints": [

‎tests/test_health.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,42 @@ def test_other_workflows_are_never_leftovers():
8383
assert not leftover_workflow(ci, has_dependabot_config=False)
8484

8585

86+
def test_a_repo_without_workflows_or_endpoints_is_clean(monkeypatch):
87+
# The org profile repo (.github) holds community files only: no workflows,
88+
# no Pages. One listing call, nothing else, and no finding.
89+
calls = []
90+
91+
def get(url: str, token: str | None) -> dict:
92+
calls.append(url)
93+
return {"total_count": 0, "workflows": []}
94+
monkeypatch.setattr(health, "_get", get)
95+
config = {"repos": [{"name": "org/.github", "branches": ["main"]}], "endpoints": []}
96+
assert health.check(config, None) == []
97+
assert calls == [f"{health.API}/repos/org/.github/actions/workflows?per_page=100"]
98+
assert "Checked .github and 0 public endpoints" in render([], config)
99+
100+
101+
def test_a_repo_that_cannot_be_listed_is_reported(monkeypatch):
102+
def missing(url: str, token: str | None) -> dict:
103+
raise urllib.error.HTTPError(url, 404, "Not Found", None, None)
104+
monkeypatch.setattr(health, "_get", missing)
105+
config = {"repos": [{"name": "org/gone", "branches": ["main"]}], "endpoints": []}
106+
findings = health.check(config, None)
107+
assert [f.where for f in findings] == ["org/gone"]
108+
assert "could not list workflows" in findings[0].what
109+
110+
111+
def test_repos_json_is_well_formed():
112+
import json
113+
config = json.loads(health.CONFIG.read_text(encoding="utf-8"))
114+
names = [repo["name"] for repo in config["repos"]]
115+
assert len(names) == len(set(names))
116+
for repo in config["repos"]:
117+
assert repo["name"].startswith("GetTechAPI/") and repo["branches"], repo
118+
for endpoint in config["endpoints"]:
119+
assert endpoint["url"].startswith("https://") and endpoint["expect"], endpoint
120+
121+
86122
def test_endpoint_without_expected_field_is_a_problem():
87123
assert endpoint_finding("summary", "https://x", "count", {"other": 1})
88124
assert endpoint_finding("summary", "https://x", "count", "<html>404</html>")

0 commit comments

Comments
 (0)