File tree Expand file tree Collapse file tree 4 files changed +81
-0
lines changed
scripts/github/checklist_validator Expand file tree Collapse file tree 4 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 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+ - [x] 2 . ~~ I have run git pre-commits.~~ (WIP)
29+ - [ ] 4 . I have updated relevant documentation.
30+ - [ ] 5 . I have considered the cross-team impact (and have PR approval from both Core & Demographics if necessary).
31+ - [ ] 6 . I have successfully deployed this change to a sandbox and witnessed it build:
32+ - [ ] 6a. [ ` Deploy - Sandbox ` ] ( https://github.com/NHSDigital/national-document-repository-infrastructure/actions/workflows/deploy-sandbox.yml ) - [ workflow run: TBC] ( https://github.com/NHSDigital/national-document-repository-infrastructure/actions/runs/XXX )
33+ - [ ] 7 . I have checked the Terraform Plan from this PR against ` ndr-dev ` .
Original file line number Diff line number Diff line change @@ -120,3 +120,21 @@ jobs:
120120 BRANCH_NAME=${{ github.event.repository.default_branch }}
121121 chmod +x scripts/markdown-validator.sh
122122 scripts/markdown-validator.sh
123+
124+ checklist_validator :
125+ name : Checklist Validation
126+ runs-on : ubuntu-latest
127+ steps :
128+ - name : Checkout repository
129+ uses : actions/checkout@v5
130+
131+ - name : Set up Python 3.11
132+ uses : actions/setup-python@v6
133+ with :
134+ python-version : 3.11
135+
136+ - name : Run checklist validator
137+ run : |
138+ python3 scripts/github/checklist_validator/main.py
139+ env :
140+ PR_BODY : ${{ github.event.pull_request.body }}
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments