Commit bb48e9eeb6

bb48e9eeb6b2d6083c73b5d831096e14ed830641

parent: 1e2385baec

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-06-05 18:57 UTC

Add repo exists check to CI workflow

Layout: unified · split

lib/checks/check-project.py +23
@@ -93,6 +93,10 @@ DUPLICATE_URL_MSG = (
93 "The URL for this submission already exists in another listing." 93 "The URL for this submission already exists in another listing."
94 " Please check that this is not a duplicate entry" 94 " Please check that this is not a duplicate entry"
95) 95)
96REPO_404_MSG = (
97 "The GitHub repository linked in this submission returns a 404."
98 " Please ensure the repo exists and is publicly accessible"
99)
96 100
97 101
98def load_diff(path): 102def load_diff(path):
@@ -291,6 +295,21 @@ def _pr_discloses_authorship(pr_body):
291 return bool(pr_body and _DISCLOSURE_RE.search(pr_body)) 295 return bool(pr_body and _DISCLOSURE_RE.search(pr_body))
292 296
293 297
298def check_repo_exists(diff, token):
299 """Return REPO_404_MSG if an added service's GitHub repo returns a 404."""
300 if not token:
301 return None
302 seen = set()
303 for svc in get_services(diff, "added"):
304 owner, repo = utils.parse_github_field(svc.get("fields", {}).get("github"))
305 if not owner or (owner, repo) in seen:
306 continue
307 seen.add((owner, repo))
308 if utils.repo_status(owner, repo, token, session=SESSION) == 404:
309 return {"msg": REPO_404_MSG, "level": "error"}
310 return None
311
312
294def check_repo_signals(diff, pr_user, token, pr_body=""): 313def check_repo_signals(diff, pr_user, token, pr_body=""):
295 """Check GitHub repo author match, stars, and activity for added services.""" 314 """Check GitHub repo author match, stars, and activity for added services."""
296 findings = [] 315 findings = []
@@ -396,6 +415,10 @@ def main():
396 if finding: 415 if finding:
397 findings.append(finding) 416 findings.append(finding)
398 417
418 finding = check_repo_exists(diff, token)
419 if finding:
420 findings.append(finding)
421
399 findings.extend(check_repo_signals(diff, pr_user, token, pr_body)) 422 findings.extend(check_repo_signals(diff, pr_user, token, pr_body))
400 except Exception as exc: 423 except Exception as exc:
401 logging.error("Unhandled error in main: %s", exc, exc_info=True) 424 logging.error("Unhandled error in main: %s", exc, exc_info=True)
lib/utils/__init__.py +2
@@ -12,6 +12,7 @@ from .github import (
12 repo_is_archived, 12 repo_is_archived,
13 repo_is_fork, 13 repo_is_fork,
14 repo_pushed_days_ago, 14 repo_pushed_days_ago,
15 repo_status,
15) 16)
16from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session 17from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session
17from .term import make_colors, setup_logging 18from .term import make_colors, setup_logging
@@ -36,6 +37,7 @@ __all__ = [
36 "repo_is_archived", 37 "repo_is_archived",
37 "repo_is_fork", 38 "repo_is_fork",
38 "repo_pushed_days_ago", 39 "repo_pushed_days_ago",
40 "repo_status",
39 "setup_logging", 41 "setup_logging",
40 "slugify", 42 "slugify",
41] 43]
lib/utils/github.py +17
@@ -67,6 +67,23 @@ def fetch_repo(owner, repo, token, session=None):
67 return gh_get(f"/repos/{owner}/{repo}", token, session=session, label="repos") 67 return gh_get(f"/repos/{owner}/{repo}", token, session=session, label="repos")
68 68
69 69
70def repo_status(owner, repo, token, session=None, timeout=DEFAULT_TIMEOUT):
71 """Return the HTTP status code for a repo, or None on transport error."""
72 session = session or make_session()
73 headers = {"Accept": "application/vnd.github.v3+json"}
74 if token:
75 headers["Authorization"] = f"token {token}"
76 try:
77 resp = session.get(
78 f"https://api.github.com/repos/{owner}/{repo}",
79 headers=headers, timeout=timeout,
80 )
81 return resp.status_code
82 except Exception as exc:
83 logging.warning("[repo-status] request error for %s/%s: %s", owner, repo, exc)
84 return None
85
86
70def commit_has_bot(commit, bot_set): 87def commit_has_bot(commit, bot_set):
71 """Return True if a commit was authored or co-authored by a known AI bot.""" 88 """Return True if a commit was authored or co-authored by a known AI bot."""
72 author = commit.get("commit", {}).get("author", {}) 89 author = commit.get("commit", {}).get("author", {})