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 = (
9393 "The URL for this submission already exists in another listing."
9494 " Please check that this is not a duplicate entry"
9595)
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)
96100
97101
98102def load_diff(path):
@@ -291,6 +295,21 @@ def _pr_discloses_authorship(pr_body):
291295 return bool(pr_body and _DISCLOSURE_RE.search(pr_body))
292296
293297
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
294313def check_repo_signals(diff, pr_user, token, pr_body=""):
295314 """Check GitHub repo author match, stars, and activity for added services."""
296315 findings = []
@@ -396,6 +415,10 @@ def main():
396415 if finding:
397416 findings.append(finding)
398417
418 finding = check_repo_exists(diff, token)
419 if finding:
420 findings.append(finding)
421
399422 findings.extend(check_repo_signals(diff, pr_user, token, pr_body))
400423 except Exception as exc:
401424 logging.error("Unhandled error in main: %s", exc, exc_info=True)
lib/utils/__init__.py +2
@@ -12,6 +12,7 @@ from .github import (
1212 repo_is_archived,
1313 repo_is_fork,
1414 repo_pushed_days_ago,
15 repo_status,
1516)
1617from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session
1718from .term import make_colors, setup_logging
@@ -36,6 +37,7 @@ __all__ = [
3637 "repo_is_archived",
3738 "repo_is_fork",
3839 "repo_pushed_days_ago",
40 "repo_status",
3941 "setup_logging",
4042 "slugify",
4143]
lib/utils/github.py +17
@@ -67,6 +67,23 @@ def fetch_repo(owner, repo, token, session=None):
6767 return gh_get(f"/repos/{owner}/{repo}", token, session=session, label="repos")
6868
6969
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
7087def commit_has_bot(commit, bot_set):
7188 """Return True if a commit was authored or co-authored by a known AI bot."""
7289 author = commit.get("commit", {}).get("author", {})