Commit f9ce8cbff7

f9ce8cbff7715859e0711bac452f048d70c0737a

parent: bed4f2f298

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-03-24 12:16 UTC

Improves robustness of diff comparison, and adds a type and checkbox check

Layout: unified · split

.github/workflows/pr-check.yml +26 −6
@@ -21,21 +21,30 @@ jobs:
2121 - uses: actions/checkout@v5
2222 with:
2323 fetch-depth: 0
24 - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
24 - name: Find merge base with ${{ github.event.pull_request.base.ref }}
25 id: mb
26 env:
27 BASE_SHA: ${{ github.event.pull_request.base.sha }}
28 BASE_REF: ${{ github.event.pull_request.base.ref }}
29 run: |
30 git fetch origin "$BASE_REF" || git fetch --depth=1 origin "$BASE_SHA" || true
31 MB=$(git merge-base "$BASE_SHA" HEAD 2>/dev/null || echo "")
32 git cat-file -e "${MB}^{commit}" 2>/dev/null || MB=""
33 echo "sha=${MB:-$BASE_SHA}" >> "$GITHUB_OUTPUT"
2534 - uses: actions/setup-python@v6
2635 with:
2736 python-version: "3.12"
2837 - name: Check README edits
2938 id: readme
3039 continue-on-error: true
31 run: python lib/checks/check-readme-edits.py --base-ref ${{ github.event.pull_request.base.sha }}
40 run: python lib/checks/check-readme-edits.py --base-ref ${{ steps.mb.outputs.sha }}
3241 - name: Check PR metadata
3342 id: meta
3443 env:
3544 PR_TITLE: ${{ github.event.pull_request.title }}
3645 PR_BODY: ${{ github.event.pull_request.body }}
3746 PR_DRAFT: ${{ github.event.pull_request.draft }}
38 BASE_REF: ${{ github.event.pull_request.base.sha }}
47 BASE_REF: ${{ steps.mb.outputs.sha }}
3948 README_FAILED: ${{ steps.readme.outcome == 'failure' && 'true' || 'false' }}
4049 run: python lib/checks/check-pr-meta.py
4150 - name: Upload findings
@@ -56,13 +65,24 @@ jobs:
5665 yaml_changed: ${{ steps.changes.outputs.yaml_changed }}
5766 steps:
5867 - uses: actions/checkout@v5
59 - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
68 with:
69 fetch-depth: 0
70 - name: Find merge base with ${{ github.event.pull_request.base.ref }}
71 id: mb
72 env:
73 BASE_SHA: ${{ github.event.pull_request.base.sha }}
74 BASE_REF: ${{ github.event.pull_request.base.ref }}
75 run: |
76 git fetch origin "$BASE_REF" || git fetch --depth=1 origin "$BASE_SHA" || true
77 MB=$(git merge-base "$BASE_SHA" HEAD 2>/dev/null || echo "")
78 git cat-file -e "${MB}^{commit}" 2>/dev/null || MB=""
79 echo "sha=${MB:-$BASE_SHA}" >> "$GITHUB_OUTPUT"
6080 - uses: actions/setup-python@v6
6181 with:
6282 python-version: "3.12"
6383 - name: Detect changes
6484 id: changes
65 run: python lib/checks/detect-changes.py --base-ref ${{ github.event.pull_request.base.sha }}
85 run: python lib/checks/detect-changes.py --base-ref ${{ steps.mb.outputs.sha }}
6686 - name: Install dependencies
6787 if: steps.changes.outputs.yaml_changed == 'true'
6888 run: pip install -q -r lib/requirements.txt
@@ -75,7 +95,7 @@ jobs:
7595 if: steps.changes.outputs.yaml_changed == 'true'
7696 id: diff
7797 continue-on-error: true
78 run: python lib/checks/check-yaml-diff.py --base-ref ${{ github.event.pull_request.base.sha }}
98 run: python lib/checks/check-yaml-diff.py --base-ref ${{ steps.mb.outputs.sha }}
7999 - name: Check additions
80100 if: steps.changes.outputs.yaml_changed == 'true'
81101 id: additions
lib/checks/check-pr-meta.py +28 −4
@@ -44,6 +44,15 @@ BOT_MSG = (
4444 "Submissions are only accepted from humans."
4545 " This PR appears to have been authored by a bot or AI assistant."
4646)
47MISSING_TYPE_MSG = (
48 "Please specify the PR type (under the Type heading of the PR template),"
49 " for example 'Addition', 'Amendment' or 'Removal'"
50)
51
52_VALID_TYPES = re.compile(
53 r"addition|amendment|removal|spelling|grammar|website|lib|ci|api|misc|other",
54 re.IGNORECASE,
55)
4756
4857_BOT_AUTHOR_RE = re.compile(
4958 r"(?:noreply@anthropic\.com|devin-ai-integration|copilot-swe-agent|noreply@cursor\.com)",
@@ -86,20 +95,32 @@ def check_template(body):
8695 return None
8796
8897
89def check_checkboxes(body):
90 """Return a finding if any checklist checkboxes are unchecked."""
98def check_checkboxes(body, min_checkboxes=4):
99 """Return a finding if any checklist checkboxes are unchecked or missing."""
91100 section = extract_section(body, "Checklist")
92101 if section is None:
93102 return None
94103 checked = re.findall(r"- \[x\]", section, re.IGNORECASE)
95104 unchecked = re.findall(r"- \[ \]", section)
96 if not checked and not unchecked:
97 return None
105 total = len(checked) + len(unchecked)
106 if total < min_checkboxes:
107 return CHECKBOX_MSG
98108 if unchecked:
99109 return CHECKBOX_MSG
100110 return None
101111
102112
113def check_type(body):
114 """Return a finding if the Type section doesn't contain a recognised PR type."""
115 content = extract_section(body, "Type")
116 if content is None:
117 return None # missing section is already caught by check_template
118 text = strip_html_comments(content)
119 if text and not _VALID_TYPES.search(text):
120 return MISSING_TYPE_MSG
121 return None
122
123
103124def check_bot_coauthors(base_ref):
104125 """Return a finding if any commit in the PR has a bot author or co-author."""
105126 if not base_ref:
@@ -166,6 +187,9 @@ def main():
166187 if finding:
167188 findings.append({"msg": finding, "level": "error"})
168189 critical = True
190 finding = check_type(body)
191 if finding:
192 findings.append(finding)
169193
170194 finding = check_readme(readme_failed)
171195 if finding: