Skip to content

Commit 3318c47

Browse files
sirknightjdisa6302
andauthored
Pr checker (#1242)
* Add PR description lint (#1144) * Add PR description lint * windows build fix * Set CMAKE_OBJECT_PATH_MAX for windows * Add openssl build * Allow * characters to be used in the description --------- Co-authored-by: Divya Sampath Kumar <[email protected]>
1 parent ed7b2f1 commit 3318c47

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
*Issue #, if available:*
22

3-
*Description of changes:*
3+
*What was changed?*
44

5+
*Why was it changed?*
6+
7+
*How was it changed?*
8+
9+
*What testing was done for the changes?*
510

611
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

.github/workflows/pr-desc-lint.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: PR Description Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
- master
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
- edited
13+
14+
jobs:
15+
check-description:
16+
runs-on: macos-latest
17+
steps:
18+
- name: Install GitHub CLI
19+
run: |
20+
brew install gh
21+
- name: Check PR Description
22+
env:
23+
GH_TOKEN: ${{ github.token }}
24+
run: |
25+
pr_link="https://github.com/${GITHUB_REPOSITORY}/pull/${{ github.event.pull_request.number }}"
26+
27+
echo "$pr_link"
28+
29+
pr_description=$(gh pr view $pr_link --json body -q ".body")
30+
31+
if [ -z "$pr_description" ]; then
32+
echo "Failed to fetch the PR description"
33+
exit 1
34+
fi
35+
36+
# Define minimum character count for each section
37+
MIN_CHARS=10
38+
# Extract contents
39+
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*Why was it changed?\*/p' | sed '$d' | sed '1d')
40+
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*How was it changed?\*/p' | sed '$d' | sed '1d')
41+
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*What testing was done for the changes?\*/p' | sed '$d' | sed '1d')
42+
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/By submitting this pull request/p' | sed '$d' | sed '1d')
43+
44+
error_occurred=0
45+
if [[ ${#what_changed} -lt $MIN_CHARS ]]; then
46+
echo "PR description for what changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${what_changed}"
47+
error_occurred=1
48+
fi
49+
if [[ ${#why_changed} -lt $MIN_CHARS ]]; then
50+
echo "PR description for why it changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${why_changed}"
51+
error_occurred=1
52+
fi
53+
if [[ ${#how_changed} -lt $MIN_CHARS ]]; then
54+
echo "PR description for how was it changed section is either missing or too short. Required: ${MIN_CHARS}, Current: ${how_changed}"
55+
error_occurred=1
56+
fi
57+
if [[ ${#testing_done} -lt $MIN_CHARS ]]; then
58+
echo "PR description for testing section are either missing or too short. Required: ${MIN_CHARS}, Current: ${testing_done}"
59+
error_occurred=1
60+
fi
61+
if [[ $error_occurred -eq 1 ]]; then
62+
exit 1
63+
fi

0 commit comments

Comments
 (0)