Commit 63bdb10b41

63bdb10b41b011b9c1dce496cbeb8a02c3bf008e

parent: 22adcecac3

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-03-13 20:26 UTC

Improve PR checking workflows

- Once all checks pass, assign to maintainer for review
- Make Submission info section replaceable so content not stale
- Broaden check for spam PRs, because AI crap still getting through
- Fix node20 warnings and other outdated GH workflows
- Remove "Data Validation summary" from md output
- Don't run website checks, when submitted website is the GitHub
- Add check for newly created GitHub accounts
- Add check for duplicate service additions

Layout: unified · split

.github/workflows/pr-check.yml +18 −18
@@ -18,9 +18,9 @@ jobs:
1818 name: PR Compliance
1919 runs-on: ubuntu-latest
2020 steps:
21 - uses: actions/checkout@v4
21 - uses: actions/checkout@v5
2222 - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
23 - uses: actions/setup-python@v5
23 - uses: actions/setup-python@v6
2424 with:
2525 python-version: "3.12"
2626 - name: Check README edits
@@ -38,7 +38,7 @@ jobs:
3838 run: python lib/checks/check-pr-meta.py
3939 - name: Upload findings
4040 if: always()
41 uses: actions/upload-artifact@v4
41 uses: actions/upload-artifact@v5
4242 with:
4343 name: findings-compliance
4444 path: /tmp/findings-compliance.json
@@ -53,9 +53,9 @@ jobs:
5353 outputs:
5454 yaml_changed: ${{ steps.changes.outputs.yaml_changed }}
5555 steps:
56 - uses: actions/checkout@v4
56 - uses: actions/checkout@v5
5757 - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
58 - uses: actions/setup-python@v5
58 - uses: actions/setup-python@v6
5959 with:
6060 python-version: "3.12"
6161 - name: Detect changes
@@ -83,7 +83,7 @@ jobs:
8383 run: python lib/checks/check-additions.py
8484 - name: Upload diff data
8585 if: always()
86 uses: actions/upload-artifact@v4
86 uses: actions/upload-artifact@v5
8787 with:
8888 name: pr-diff
8989 path: |
@@ -92,7 +92,7 @@ jobs:
9292 if-no-files-found: ignore
9393 - name: Upload findings
9494 if: always()
95 uses: actions/upload-artifact@v4
95 uses: actions/upload-artifact@v5
9696 with:
9797 name: findings-data
9898 path: /tmp/findings-data.json
@@ -107,13 +107,13 @@ jobs:
107107 if: "!cancelled() && needs.data-validation.outputs.yaml_changed == 'true'"
108108 runs-on: ubuntu-latest
109109 steps:
110 - uses: actions/checkout@v4
111 - uses: actions/setup-python@v5
110 - uses: actions/checkout@v5
111 - uses: actions/setup-python@v6
112112 with:
113113 python-version: "3.12"
114114 - run: pip install -q -r lib/requirements.txt
115115 - name: Download diff data
116 uses: actions/download-artifact@v4
116 uses: actions/download-artifact@v5
117117 with:
118118 name: pr-diff
119119 path: /tmp
@@ -131,14 +131,14 @@ jobs:
131131 run: python lib/checks/make-info-stats.py
132132 - name: Upload repo stats
133133 if: always()
134 uses: actions/upload-artifact@v4
134 uses: actions/upload-artifact@v5
135135 with:
136136 name: repo-stats
137137 path: /tmp/repo-stats.md
138138 if-no-files-found: ignore
139139 - name: Upload findings
140140 if: always()
141 uses: actions/upload-artifact@v4
141 uses: actions/upload-artifact@v5
142142 with:
143143 name: findings-project
144144 path: /tmp/findings-project.json
@@ -150,25 +150,25 @@ jobs:
150150 needs: [pr-compliance, data-validation, submission-eligibility]
151151 runs-on: ubuntu-latest
152152 steps:
153 - uses: actions/checkout@v4
154 - uses: actions/setup-python@v5
153 - uses: actions/checkout@v5
154 - uses: actions/setup-python@v6
155155 with:
156156 python-version: "3.12"
157157 - name: Download all findings
158 uses: actions/download-artifact@v4
158 uses: actions/download-artifact@v5
159159 with:
160160 pattern: findings-*
161161 path: /tmp/artifacts
162162 merge-multiple: true
163163 continue-on-error: true
164164 - name: Download diff data
165 uses: actions/download-artifact@v4
165 uses: actions/download-artifact@v5
166166 with:
167167 name: pr-diff
168168 path: /tmp/artifacts
169169 continue-on-error: true
170170 - name: Download repo stats
171 uses: actions/download-artifact@v4
171 uses: actions/download-artifact@v5
172172 with:
173173 name: repo-stats
174174 path: /tmp/artifacts
@@ -181,7 +181,7 @@ jobs:
181181 run: python lib/checks/format-comment.py
182182 - name: Upload PR metadata
183183 if: always()
184 uses: actions/upload-artifact@v4
184 uses: actions/upload-artifact@v5
185185 with:
186186 name: pr-meta
187187 path: /tmp/pr-meta/
.github/workflows/pr-comment.yml +43 −9
@@ -20,12 +20,12 @@ jobs:
2020 if: github.event.workflow_run.event == 'pull_request'
2121
2222 steps:
23 - uses: actions/checkout@v4
23 - uses: actions/checkout@v5
2424
2525 - name: Download PR metadata
2626 id: download
2727 continue-on-error: true
28 uses: actions/download-artifact@v4
28 uses: actions/download-artifact@v5
2929 with:
3030 name: pr-meta
3131 path: pr-meta
@@ -34,7 +34,7 @@ jobs:
3434
3535 - name: Resolve PR context
3636 id: context
37 uses: actions/github-script@v7
37 uses: actions/github-script@v8
3838 with:
3939 github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
4040 script: |
@@ -95,7 +95,7 @@ jobs:
9595
9696 - name: Post or update comment
9797 if: steps.context.outputs.pr_number
98 uses: actions/github-script@v7
98 uses: actions/github-script@v8
9999 with:
100100 github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
101101 script: |
@@ -136,17 +136,38 @@ jobs:
136136 console.log('Updated bot comment.');
137137 }
138138
139 // Auto-assign Lissy93 for review when appropriate (non-critical)
140 try {
141 const readInt = (f) => fs.existsSync(f) ? parseInt(fs.readFileSync(f, 'utf8').trim()) : NaN;
142 const errors = readInt('pr-meta/error-count.txt');
143 const total = readInt('pr-meta/findings-count.txt');
144 const shouldAssign =
145 (action === 'create' && errors === 0 && total === 0) ||
146 (action === 'update' && errors === 0);
147 if (shouldAssign) {
148 await github.rest.issues.addAssignees({
149 owner: context.repo.owner,
150 repo: context.repo.repo,
151 issue_number: prNumber,
152 assignees: ['Lissy93'],
153 });
154 console.log('Assigned Lissy93 for review.');
155 }
156 } catch (err) {
157 console.log(`Failed to auto-assign: ${err.message}`);
158 }
159
139160 review-notify:
140161 name: Notify maintainer
141162 runs-on: ubuntu-latest
142163 if: github.event_name == 'pull_request_review'
143164
144165 steps:
145 - uses: actions/checkout@v4
166 - uses: actions/checkout@v5
146167
147168 - name: Fetch review and CI context
148169 id: context
149 uses: actions/github-script@v7
170 uses: actions/github-script@v8
150171 with:
151172 github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
152173 script: |
@@ -191,7 +212,7 @@ jobs:
191212 run: python lib/checks/check-review-ready.py
192213
193214 - name: Post notification
194 uses: actions/github-script@v7
215 uses: actions/github-script@v8
195216 with:
196217 github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
197218 script: |
@@ -212,10 +233,23 @@ jobs:
212233 '@Lissy93 - Please evaluate, and either merge or leave feedback.',
213234 ].join('\n');
214235
236 const prNumber = parseInt('${{ steps.context.outputs.pr_number }}');
237
215238 await github.rest.issues.createComment({
216239 owner: context.repo.owner,
217240 repo: context.repo.repo,
218 issue_number: parseInt('${{ steps.context.outputs.pr_number }}'),
241 issue_number: prNumber,
219242 body,
220243 });
221 console.log('Posted maintainer notification.');
244
245 // Once all checks pass, assign the PR to myself, so i get notiifcation to review
246 try {
247 await github.rest.issues.addAssignees({
248 owner: context.repo.owner,
249 repo: context.repo.repo,
250 issue_number: prNumber,
251 assignees: ['Lissy93'],
252 });
253 } catch (err) {
254 console.log(`Failed to assign Lissy93: ${err.message}`);
255 }
lib/checks/check-project.py +96 −19
@@ -26,7 +26,10 @@ AI_BOT_AUTHORS = [
2626 "copilot-swe-agent.github.com",
2727 "noreply@cursor.com",
2828]
29SPAM_PR_THRESHOLD = 5
29SPAM_AWESOME_THRESHOLD = 3
30SPAM_DISTINCT_REPO_THRESHOLD = 7
31SPAM_WINDOW_DAYS = 2
32NEW_ACCOUNT_DAYS = 14
3033
3134LINK_MSG = (
3235 "The link(s) you included seem to be returning a 404."
@@ -47,7 +50,8 @@ ACTIVITY_MSG = (
4750)
4851MATURITY_MSG = (
4952 "This project appears to be quite new (created less than 4 months ago)."
50 " Repositories should have a proven track record before listing."
53 " Repositories should have a proven track record before listing,"
54 " and at least 16 weeks since first stable release."
5155)
5256AI_CODE_MSG = (
5357 "This project appears to contain AI-generated code."
@@ -62,15 +66,27 @@ LICENSE_MSG = (
6266)
6367ARCHIVED_MSG = (
6468 "The GitHub project linked has been archived."
65 " Additions must be actively maintained."
69 " Additions must be actively maintained"
6670)
6771SECURITY_MSG = (
6872 "This project has open security vulnerabilities (critical or high severity)"
6973 " flagged by GitHub Dependabot. Please verify these have been addressed"
7074)
71SPAM_MSG = (
72 "This user has opened up a large number of PRs to other awesome-* repos"
73 " in the past 24 hours, and appears to be spamming"
75SPAM_AWESOME_MSG = (
76 "You have made many similar submissions on other awesome-* repos today."
77 " Please ensure that your submission is actually a good fit for awesome-privacy"
78)
79SPAM_MANY_MSG = (
80 "The submitter of this PR appears to have been previously flagged as a spammer."
81 " Caution is needed when reviewing this PR"
82)
83NEW_ACCOUNT_MSG = (
84 "This user has only just joined GitHub."
85 " New accounts submitting to awesome lists can be a spam signal, careful review needed"
86)
87DUPLICATE_URL_MSG = (
88 "The URL for this submission already exists in another listing."
89 " Please check that this is not a duplicate entry"
7490)
7591
7692
@@ -249,37 +265,91 @@ def check_security_alerts(owner, repo, token):
249265
250266
251267def check_spam_prs(pr_user, token):
252 """Return SPAM_MSG if the user has opened many PRs to other awesome-* repos recently."""
268 """Return list of spam findings based on recent PR activity."""
253269 if not pr_user or not token:
254 return None
270 return []
255271 try:
256 since = (datetime.now(timezone.utc) - timedelta(days=1)).strftime("%Y-%m-%d")
257 headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": USER_AGENT}
258 headers["Authorization"] = f"token {token}"
272 since = (datetime.now(timezone.utc) - timedelta(days=SPAM_WINDOW_DAYS)).strftime("%Y-%m-%d")
273 headers = {
274 "Accept": "application/vnd.github.v3+json",
275 "User-Agent": USER_AGENT,
276 "Authorization": f"token {token}",
277 }
259278 resp = requests.get(
260279 "https://api.github.com/search/issues",
261280 headers=headers, timeout=TIMEOUT,
262281 params={"q": f"type:pr author:{pr_user} created:>={since}"},
263282 )
264283 if resp.status_code != 200:
265 return None
284 return []
266285 items = resp.json().get("items", [])
267286 this_repo = os.environ.get("GITHUB_REPOSITORY", "Lissy93/awesome-privacy").lower()
268 count = 0
287 awesome_count = 0
288 distinct_repos = set()
269289 for item in items:
270290 repo_url = item.get("repository_url", "")
271291 # repository_url looks like https://api.github.com/repos/owner/repo-name
272292 repo_full = "/".join(repo_url.rstrip("/").split("/")[-2:]).lower()
293 if repo_full == this_repo:
294 continue
295 distinct_repos.add(repo_full)
273296 repo_name = repo_url.rstrip("/").split("/")[-1].lower()
274 if repo_name.startswith("awesome-") and repo_full != this_repo:
275 count += 1
276 if count >= SPAM_PR_THRESHOLD:
277 return SPAM_MSG
297 if repo_name.startswith("awesome-"):
298 awesome_count += 1
299 findings = []
300 if awesome_count >= SPAM_AWESOME_THRESHOLD:
301 findings.append(SPAM_AWESOME_MSG)
302 if len(distinct_repos) >= SPAM_DISTINCT_REPO_THRESHOLD:
303 findings.append(SPAM_MANY_MSG)
304 return findings
305 except Exception:
306 return []
307
308
309def check_new_account(pr_user, token):
310 """Return NEW_ACCOUNT_MSG if the PR author's GitHub account is very new."""
311 if not pr_user or not token:
312 return None
313 try:
314 headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": USER_AGENT}
315 headers["Authorization"] = f"token {token}"
316 resp = requests.get(
317 f"https://api.github.com/users/{pr_user}",
318 headers=headers, timeout=TIMEOUT,
319 )
320 if resp.status_code != 200:
321 return None
322 created = resp.json().get("created_at")
323 if not created:
324 return None
325 created_dt = datetime.fromisoformat(created.replace("Z", "+00:00"))
326 if (datetime.now(timezone.utc) - created_dt).days < NEW_ACCOUNT_DAYS:
327 return NEW_ACCOUNT_MSG
278328 except Exception:
279329 pass
280330 return None
281331
282332
333def check_duplicate_urls(diff, head):
334 """Return DUPLICATE_URL_MSG if an added service's URL already exists in the YAML."""
335 if not head:
336 return None
337 # Count how many times each URL appears in the head YAML
338 url_counts = {}
339 for cat in head.get("categories", []):
340 for sec in cat.get("sections", []):
341 for svc in sec.get("services", []):
342 url = svc.get("url", "").rstrip("/").lower()
343 if url:
344 url_counts[url] = url_counts.get(url, 0) + 1
345 # The added service is in head already, so a count > 1 means a duplicate exists
346 for svc in get_services(diff, "added"):
347 url = svc.get("fields", {}).get("url", "").rstrip("/").lower()
348 if url and url_counts.get(url, 0) > 1:
349 return DUPLICATE_URL_MSG
350 return None
351
352
283353_DISCLOSURE_RE = re.compile(
284354 r"i am the author|i'm the author|my project|i created|i develop"
285355 r"|i maintain|i built|my own project|i made|author of|maintainer of",
@@ -383,11 +453,18 @@ def main():
383453 pr_user = os.environ.get("PR_USER", "")
384454 pr_body = os.environ.get("PR_BODY", "")
385455 token = os.environ.get("GITHUB_TOKEN", "")
386 findings.extend(check_repo_signals(diff, pr_user, token, pr_body))
387456
388 finding = check_spam_prs(pr_user, token)
457 findings.extend(check_spam_prs(pr_user, token))
458
459 finding = check_new_account(pr_user, token)
389460 if finding:
390461 findings.append(finding)
462
463 finding = check_duplicate_urls(diff, head)
464 if finding:
465 findings.append(finding)
466
467 findings.extend(check_repo_signals(diff, pr_user, token, pr_body))
391468 except Exception:
392469 pass
393470
lib/checks/check-yaml-diff.py −17
@@ -156,22 +156,6 @@ def write_diff_summary(diff_result):
156156 f.write("\n".join(bullets) + "\n")
157157
158158
159def write_step_summary(diff_result):
160 """Write a bullet-point Markdown summary to $GITHUB_STEP_SUMMARY."""
161 summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
162 if not summary_file:
163 return
164
165 bullets = format_diff_bullets(diff_result)
166 lines = ["## YAML Diff Analysis\n"]
167 if bullets:
168 lines.extend(bullets)
169 else:
170 lines.append("No changes detected in `awesome-privacy.yml`.")
171
172 with open(summary_file, "a") as f:
173 f.write("\n".join(lines) + "\n")
174
175159
176160def main():
177161 parser = argparse.ArgumentParser()
@@ -227,7 +211,6 @@ def main():
227211 json.dump(diff_result, f, indent=2)
228212
229213 write_github_output("has_service_changes", str(bool(added or removed or modified)).lower())
230 write_step_summary(diff_result)
231214 write_diff_summary(diff_result)
232215
233216 added_count = len(added)
lib/checks/format-comment.py +5 −2
@@ -179,7 +179,8 @@ def write_step_summary(errors, warnings, user, pr_number, run_id, changes_summar
179179 if pr_number:
180180 lines.append(
181181 f"This workflow run was triggered at {timestamp}"
182 f" for PR #{pr_number} which was opened by @{user}\n"
182 f" for PR [#{pr_number}](https://github.com/Lissy93/awesome-privacy/pull/{pr_number})"
183 f" which was opened by @{user}\n"
183184 )
184185 else:
185186 lines.append(
@@ -191,7 +192,7 @@ def write_step_summary(errors, warnings, user, pr_number, run_id, changes_summar
191192 lines.append(f"{changes_summary}\n")
192193
193194 if repo_stats:
194 lines.append("#### Submission Info\n")
195 lines.append("### Submission Info\n")
195196 lines.append(f"{repo_stats}\n")
196197
197198 with open(summary_file, "a") as f:
@@ -217,6 +218,8 @@ def main():
217218 all_findings = errors + warnings
218219 with open(os.path.join(OUTPUT_DIR, "findings-count.txt"), "w") as f:
219220 f.write(str(len(all_findings)))
221 with open(os.path.join(OUTPUT_DIR, "error-count.txt"), "w") as f:
222 f.write(str(len(errors)))
220223 changes_summary = load_diff_summary()
221224 changes_bullets = _extract_changes_bullets(changes_summary)
222225 repo_stats = load_repo_stats()
lib/checks/make-info-stats.py +10 −4
@@ -591,11 +591,17 @@ def main():
591591 print(f"Failed to fetch repo data for {args['owner']}/{args['repo']}", file=sys.stderr)
592592
593593 if args["url"]:
594 site_data = fetch_website_data(args["url"])
595 has_sec_txt = check_security_txt(args["url"])
596 if site_data or has_sec_txt is not None:
594 parsed_url = urlparse(args["url"])
595 if parsed_url.hostname and parsed_url.hostname.rstrip(".").endswith("github.com"):
596 print(f"Skipped website checks, since github repo was specified: {args['url']}", file=sys.stderr)
597597 sections.append(("Website Checks",
598 format_markdown(grade_website_stats(site_data, args["url"], has_sec_txt))))
598 f"- {ORANGE} **Skipped** web checks, since repo URL was submitted instead of a website"))
599 else:
600 site_data = fetch_website_data(args["url"])
601 has_sec_txt = check_security_txt(args["url"])
602 if site_data or has_sec_txt is not None:
603 sections.append(("Website Checks",
604 format_markdown(grade_website_stats(site_data, args["url"], has_sec_txt))))
599605
600606 if args["android"]:
601607 data = fetch_android_data(args["android"])
lib/checks/prepare-comment.py +40 −5
@@ -70,6 +70,35 @@ def _extract_pr_author(existing_body):
7070 return match.group(1) if match else None
7171
7272
73_SUBMISSION_INFO_RE = re.compile(
74 r"<details><summary>Submission Info</summary>\s*\n.*?</details>",
75 re.DOTALL,
76)
77
78
79def _extract_submission_info(body):
80 """Extract the Submission Info <details> block, or None if absent."""
81 match = _SUBMISSION_INFO_RE.search(body)
82 return match.group(0) if match else None
83
84
85def _refresh_submission_info(existing_body, new_body):
86 """Replace or insert the Submission Info block from new_body into existing_body."""
87 new_block = _extract_submission_info(new_body)
88 if not new_block:
89 return existing_body
90 old_block = _extract_submission_info(existing_body)
91 if old_block:
92 if old_block == new_block:
93 return existing_body
94 return existing_body.replace(old_block, new_block)
95 # No existing block — insert before Updates section or workflow run link
96 for anchor in ("---\n\n### Updates", "<sup>For full details"):
97 if anchor in existing_body:
98 return existing_body.replace(anchor, new_block + "\n\n" + anchor, 1)
99 return existing_body.rstrip() + "\n\n" + new_block
100
101
73102def build_edit_line(existing_body, findings_count, check_run_id, repo):
74103 """Build the edit line to append, or None if nothing to do."""
75104 run_tag = f"<!-- run:{check_run_id} -->"
@@ -154,14 +183,20 @@ def main():
154183 findings_count = read_findings_count(new_body)
155184 edit_line = build_edit_line(existing_body, findings_count, check_run_id, repo)
156185
157 if not edit_line:
186 # Refresh the Submission Info block even if findings haven't changed
187 refreshed_body = _refresh_submission_info(existing_body, new_body)
188 info_changed = refreshed_body != existing_body
189
190 if not edit_line and not info_changed:
158191 write_output("skip")
159192 return
160193
161 if "### Updates" in existing_body:
162 updated = existing_body.rstrip() + "\n" + edit_line
163 else:
164 updated = existing_body.rstrip() + "\n\n---\n\n### Updates\n\n" + edit_line
194 updated = refreshed_body
195 if edit_line:
196 if "### Updates" in updated:
197 updated = updated.rstrip() + "\n" + edit_line
198 else:
199 updated = updated.rstrip() + "\n\n---\n\n### Updates\n\n" + edit_line
165200 write_output("update", updated)
166201
167202