Commit 559b7f831a

559b7f831a41e082644cb48cbaca0cd51af9d376

parent: 9307f56d4d

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-06-17 08:19 UTC

Adds make review_diff script for easier running local checks on just diff

Layout: unified · split

Makefile +4 −1
@@ -22,7 +22,7 @@
2222
2323# Targets
2424.PHONY: all \
25 install_lib_deps gen_readme gen_changelog validate review lib \
25 install_lib_deps gen_readme gen_changelog validate review review_diff lib \
2626 install_web_deps build_web start_web web
2727
2828# Get Python bin
@@ -48,6 +48,9 @@ gen_changelog: install_lib_deps
4848review: install_lib_deps
4949 $(PYTHON) $(LIB_DIR)/review-listings.py $(ARGS)
5050
51review_diff: install_lib_deps
52 $(PYTHON) $(LIB_DIR)/review-listings.py --changed-since $(or $(BASE),main) $(ARGS)
53
5154lib: install_lib_deps validate gen_readme gen_changelog
5255
5356# Targets for web/
lib/checks/check-project.py +3 −7
@@ -204,8 +204,8 @@ def check_security_alerts(owner, repo, token):
204204
205205def check_spam_prs(pr_user, token):
206206 """Return list of spam findings based on recent PR activity."""
207 if not pr_user or not token:
208 logger.warning("check_spam_prs skipped: %s", "no PR_USER" if not pr_user else "no GITHUB_TOKEN")
207 if not pr_user:
208 logger.warning("check_spam_prs skipped: no PR_USER")
209209 return []
210210 try:
211211 since = (datetime.now(timezone.utc) - timedelta(days=SPAM_WINDOW_DAYS)).strftime("%Y-%m-%d")
@@ -245,7 +245,7 @@ def check_spam_prs(pr_user, token):
245245
246246def check_new_account(pr_user, token):
247247 """Return NEW_ACCOUNT_MSG if the PR author's GitHub account is very new."""
248 if not pr_user or not token:
248 if not pr_user:
249249 return None
250250 data = _gh_get(f"/users/{pr_user}", token, label="user")
251251 if not data:
@@ -296,8 +296,6 @@ def _pr_discloses_authorship(pr_body):
296296
297297def check_repo_exists(diff, token):
298298 """Return REPO_404_MSG if an added service's GitHub repo returns a 404."""
299 if not token:
300 return None
301299 seen = set()
302300 for svc in get_services(diff, "added"):
303301 owner, repo = utils.parse_github_field(svc.get("fields", {}).get("github"))
@@ -312,8 +310,6 @@ def check_repo_exists(diff, token):
312310def check_repo_signals(diff, pr_user, token, pr_body=""):
313311 """Check GitHub repo author match, stars, and activity for added services."""
314312 findings = []
315 if not token:
316 return findings
317313 cache = {}
318314 for svc in get_services(diff, "added"):
319315 gh = svc.get("fields", {}).get("github")
lib/review-listings.py +36 −7
@@ -540,6 +540,17 @@ def build_context(args, data, token, api_token):
540540 return ctx
541541
542542
543def changed_service_keys(ref, head):
544 """Return {(category, section, name)} for services added or modified vs a git ref."""
545 from yaml_diff import build_index, diff_index, load_yaml_at_ref
546 base = load_yaml_at_ref(ref)
547 if base is None:
548 logging.error("Could not read awesome-privacy.yml at git ref %s", ref)
549 sys.exit(2)
550 added, _, modified = diff_index(build_index(base, 3), build_index(head, 3))
551 return set(added) | {k for k, _ in modified}
552
553
543554def filter_entries(data, args):
544555 for cat, sec, svc in utils.iter_services(data):
545556 if args.category and args.category.lower() != cat.lower():
@@ -654,7 +665,7 @@ def _markdown_summary(s):
654665
655666
656667def render_list(findings, colors, summary):
657 lines = []
668 lines = ["", colors["bold"]("Findings"), "--------"]
658669 if not findings:
659670 lines.append(colors["green"]("✓ All services passed."))
660671 grouped: dict = {}
@@ -766,6 +777,8 @@ def parse_args():
766777 p.add_argument("--category", help="filter to a single category")
767778 p.add_argument("--section", help="filter to a single section")
768779 p.add_argument("--service", help="filter to a single service")
780 p.add_argument("--changed-since", metavar="REF",
781 help="only review services added or modified vs this git ref (e.g. main)")
769782 p.add_argument("--only", type=_csv, default=[], help="comma-separated checks to run")
770783 p.add_argument("--skip", type=_csv, default=[], help="comma-separated checks to skip")
771784 p.add_argument("--severity", choices=["all", "warn", "error"], default="all")
@@ -814,25 +827,34 @@ def main():
814827 token = args.token or os.environ.get("GITHUB_TOKEN", "")
815828 api_token = os.environ.get("API_TOKEN", "")
816829
830 # A targeted review (single entry/diff) runs token-gated checks unauthenticated, accepting
831 # rate limits. A full review skips them without a token, to avoid hammering the APIs across
832 # every listing once limits are hit.
833 targeted = bool(args.service or args.category or args.section or args.changed_since)
834
817835 if not token:
818836 gh_checks = [n for n in enabled if CHECKS[n].needs_github]
819 if gh_checks:
837 if gh_checks and not targeted:
820838 logging.warning(
821 "GITHUB_TOKEN not set, skipping GitHub checks (%s). "
822 "Export GITHUB_TOKEN to enable them.",
839 "GITHUB_TOKEN not set, skipping GitHub checks (%s) for a full review. "
840 "Export GITHUB_TOKEN, or narrow with --service/--category/--changed-since.",
823841 ", ".join(gh_checks),
824842 )
825843 enabled = [n for n in enabled if not CHECKS[n].needs_github]
844 elif gh_checks:
845 logging.info("GITHUB_TOKEN not set, running GitHub checks unauthenticated (may be rate-limited)")
826846
827847 if not api_token:
828848 api_checks = [n for n in enabled if CHECKS[n].needs_api]
829 if api_checks:
849 if api_checks and not targeted:
830850 logging.warning(
831 "API_TOKEN not set, skipping API checks (%s). "
832 "Export API_TOKEN to enable them.",
851 "API_TOKEN not set, skipping API checks (%s) for a full review. "
852 "Export API_TOKEN, or narrow the review to run them.",
833853 ", ".join(api_checks),
834854 )
835855 enabled = [n for n in enabled if not CHECKS[n].needs_api]
856 elif api_checks:
857 logging.info("API_TOKEN not set, running API checks unauthenticated (may be rate-limited)")
836858
837859 if not enabled:
838860 logging.error("No checks to run after filters.")
@@ -848,6 +870,13 @@ def main():
848870 sys.exit(2)
849871
850872 entries = list(filter_entries(data, args))
873 if args.changed_since:
874 keys = changed_service_keys(args.changed_since, data)
875 entries = [e for e in entries if (e.category, e.section, e.name) in keys]
876 if not entries:
877 logging.info("No added or modified services since %s, nothing to review",
878 args.changed_since)
879 return
851880 if not entries:
852881 logging.error("No services matched filters (category=%s, section=%s, service=%s)",
853882 args.category, args.section, args.service)