Commit acd153fd22

acd153fd2231122d1ba22dd39cc30cd770f85578

parent: 512299c71d

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-02-23 21:32 UTC

Simplifies comment logic

Layout: unified · split

.github/workflows/pr-comment.yml +26 −32
@@ -26,7 +26,7 @@ jobs:
2626 run-id: ${{ github.event.workflow_run.id }}
2727 github-token: ${{ secrets.GITHUB_TOKEN }}
2828
29 - name: Post or update comment
29 - name: Post comment
3030 uses: actions/github-script@v7
3131 with:
3232 github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
@@ -34,12 +34,20 @@ jobs:
3434 const fs = require('fs');
3535 const marker = '<!-- pr-check-bot -->';
3636
37 // Check if there are findings to post
38 const commentFile = 'pr-meta/comment.md';
39 if (!fs.existsSync(commentFile)) {
40 console.log('No findings to post — skipping.');
41 return;
42 }
43
3744 // Determine the PR number
3845 let prNumber;
3946 const numberFile = 'pr-meta/number.txt';
4047 if (fs.existsSync(numberFile)) {
4148 prNumber = parseInt(fs.readFileSync(numberFile, 'utf8').trim());
42 } else {
49 }
50 if (!prNumber) {
4351 // workflow_run.pull_requests is empty for fork PRs, so
4452 // fall back to searching by head SHA if needed
4553 const prs = context.payload.workflow_run.pull_requests;
@@ -53,48 +61,34 @@ jobs:
5361 state: 'open',
5462 sort: 'updated',
5563 direction: 'desc',
56 per_page: 10,
64 per_page: 100,
5765 });
5866 const match = prList.find(pr => pr.head.sha === headSha);
5967 if (!match) {
60 console.log(`No open PR found for SHA ${headSha} — skipping comment.`);
68 console.log(`No open PR found for SHA ${headSha} — skipping.`);
6169 return;
6270 }
6371 prNumber = match.number;
6472 }
6573 }
6674
67 // Find existing bot comment
75 // Skip if we already commented on this PR
6876 const { data: comments } = await github.rest.issues.listComments({
6977 owner: context.repo.owner,
7078 repo: context.repo.repo,
7179 issue_number: prNumber,
80 per_page: 100,
7281 });
73 const existing = comments.find(c => c.body.includes(marker));
74
75 const commentFile = 'pr-meta/comment.md';
76 if (fs.existsSync(commentFile)) {
77 const body = fs.readFileSync(commentFile, 'utf8').trim();
78 if (existing) {
79 await github.rest.issues.updateComment({
80 owner: context.repo.owner,
81 repo: context.repo.repo,
82 comment_id: existing.id,
83 body,
84 });
85 } else {
86 await github.rest.issues.createComment({
87 owner: context.repo.owner,
88 repo: context.repo.repo,
89 issue_number: prNumber,
90 body,
91 });
92 }
93 } else if (existing) {
94 // No findings — remove stale comment
95 await github.rest.issues.deleteComment({
96 owner: context.repo.owner,
97 repo: context.repo.repo,
98 comment_id: existing.id,
99 });
82 if (comments.some(c => c.body.includes(marker))) {
83 console.log('Bot comment already exists — skipping.');
84 return;
10085 }
86
87 // Post the comment
88 const body = fs.readFileSync(commentFile, 'utf8').trim();
89 await github.rest.issues.createComment({
90 owner: context.repo.owner,
91 repo: context.repo.repo,
92 issue_number: prNumber,
93 body,
94 });
lib/checks/__pycache__/check-links.cpython-310.pyc deleted

Binary file not shown.

lib/checks/__pycache__/check-readme-edits.cpython-310.pyc deleted

Binary file not shown.

lib/checks/__pycache__/check-template.cpython-310.pyc deleted

Binary file not shown.

lib/checks/__pycache__/check-yaml-diff.cpython-310.pyc deleted

Binary file not shown.

lib/checks/__pycache__/detect-changes.cpython-310.pyc deleted

Binary file not shown.

lib/checks/__pycache__/warn-non-yaml.cpython-310.pyc deleted

Binary file not shown.

lib/checks/check-additions.py +6 −9
@@ -86,12 +86,13 @@ def check_required_fields(diff, head):
8686 for svc in diff.get("services", {}).get("modified", []):
8787 if not head:
8888 continue
89 changed = svc.get("changed_fields", [])
8990 fields = find_service_fields(
9091 head, svc["category"], svc["section"], svc["service"]
9192 )
9293 if fields:
9394 for f in REQUIRED_FIELDS:
94 if not fields.get(f):
95 if f in changed and not fields.get(f):
9596 missing.add(f)
9697 if missing:
9798 names = ", ".join(f"`{f}`" for f in sorted(missing))
@@ -120,16 +121,12 @@ def check_open_source(diff):
120121
121122
122123def check_single_entry(diff):
123 """Return a finding if the diff contains multiple service or section changes."""
124 """Return a finding if the diff adds multiple new services or sections."""
124125 services = diff.get("services", {})
125 svc_count = (
126 len(services.get("added", []))
127 + len(services.get("removed", []))
128 + len(services.get("modified", []))
129 )
130 if svc_count > 1:
126 added_count = len(services.get("added", []))
127 if added_count > 1:
131128 return MULTIPLE_MSG
132 if svc_count == 0:
129 if added_count == 0:
133130 sec_count = len(diff.get("sections", []))
134131 if sec_count > 1:
135132 return MULTIPLE_MSG