Skip to content

Commit afac170

Browse files
authored
[NDR-319] Add PR checklist (#530)
1 parent 2512d28 commit afac170

File tree

4 files changed

+85
-1
lines changed

4 files changed

+85
-1
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- markdownlint-disable-next-line first-line-heading -->
2+
## Overview
3+
4+
**Jira ticket**: [TBC](https://nhsd-jira.digital.nhs.uk/browse/XXX)
5+
6+
### Description
7+
8+
<!-- Describe your changes in detail. -->
9+
10+
### Context
11+
12+
<!-- Why is this change required? What problem does it solve? -->
13+
14+
## Checklist
15+
16+
<!--
17+
18+
Put an `x` in the completed tasks.
19+
20+
If a task is not relevant, `x` it, then strike through the text e.g.:
21+
- [x] ~~This task is not relevant.~~
22+
23+
-->
24+
25+
Tasks for all changes:
26+
27+
- [ ] 1. I have linked this PR to its Jira ticket.
28+
- [ ] 2. I have run git pre-commits.
29+
- [ ] 3. I have updated relevant documentation.
30+
- [ ] 4. I have considered the cross-team impact (and have PR approval from both Core & Demographics if necessary).
31+
- [ ] 5. I have successfully [deployed this change to a sandbox](https://github.com/NHSDigital/national-document-repository-infrastructure/actions/workflows/deploy-sandbox.yml) and witnessed it build: [Workflow run: TBC](https://github.com/NHSDigital/national-document-repository-infrastructure/actions/runs/XXX)
32+
- [ ] 6. I have checked the Terraform Plan from this PR against `ndr-dev`.

.github/workflows/automated-pr-validator.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: "Z-AUTOMATED: PR Validator"
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, reopened]
5+
types: [opened, synchronize, reopened, edited]
6+
7+
permissions: {}
68

79
jobs:
810
sbom_scan:
@@ -120,3 +122,23 @@ jobs:
120122
BRANCH_NAME=${{ github.event.repository.default_branch }}
121123
chmod +x scripts/markdown-validator.sh
122124
scripts/markdown-validator.sh
125+
126+
checklist_validator:
127+
name: Checklist Validation
128+
runs-on: ubuntu-latest
129+
permissions:
130+
contents: read
131+
steps:
132+
- name: Checkout repository
133+
uses: actions/checkout@v5
134+
135+
- name: Set up Python 3.11
136+
uses: actions/setup-python@v6
137+
with:
138+
python-version: 3.11
139+
140+
- name: Run checklist validator
141+
run: |
142+
python3 scripts/github/checklist_validator/main.py
143+
env:
144+
PR_BODY: ${{ github.event.pull_request.body }}

scripts/github/checklist_validator/__init __.py

Whitespace-only changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
def validate_checklist(body: str) -> bool:
2+
"""
3+
Check if all PR checklist items are ticked.
4+
Returns True if all boxes are checked, False otherwise.
5+
"""
6+
if not body:
7+
return False
8+
9+
lines = body.splitlines()
10+
for line in lines:
11+
line = line.strip()
12+
if line.startswith("- [ ]"):
13+
return False
14+
return True
15+
16+
17+
def main():
18+
import os
19+
20+
pr_body = os.environ.get("PR_BODY", "")
21+
if validate_checklist(pr_body):
22+
print("All checklist items are checked ✅")
23+
exit(0)
24+
else:
25+
print("Some checklist items are not checked ❌")
26+
exit(1)
27+
28+
29+
if __name__ == "__main__":
30+
main()

0 commit comments

Comments
 (0)