From b3bbd0419ba9be8a6abba752c90e2de87ef99a3e Mon Sep 17 00:00:00 2001 From: smog-root Date: Sun, 20 Oct 2024 18:43:46 +0530 Subject: [PATCH 1/4] Implement GitHub PR Issue Checker Workflow --- .github/workflows/pr-checker.yaml | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/pr-checker.yaml diff --git a/.github/workflows/pr-checker.yaml b/.github/workflows/pr-checker.yaml new file mode 100644 index 0000000..dbab3ef --- /dev/null +++ b/.github/workflows/pr-checker.yaml @@ -0,0 +1,57 @@ +name: PR Issue Checker +# Created by @smog-root. +on: + pull_request: + types: [opened, edited] + +jobs: + check_pr_details: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies (if needed) + run: pip install re # Install Python's regex library (not needed if using built-in) + + - name: Check PR Description and Title + id: check_pr_details + run: | + python -c " +import re +import sys +import os + +pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '') +pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '') + +# Check if PR description is present +if not pr_description: + print('PR description is missing.') + sys.exit(1) + +# Check if the PR description contains 'Fixes #' +if not re.search(r'Fixes #[0-9]+', pr_description): + print('The PR description should include Fixes #.') + sys.exit(1) + +# Check if the PR title starts with FIX, FEAT, or DOC +if not re.match(r'^(FIX|FEAT|DOC)', pr_title): + print('The PR title should start with FIX, FEAT, or DOC.') + sys.exit(1) + +print('PR description and title are valid.') +" + env: + GITHUB_EVENT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} + GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }} + + - name: Output result + run: echo "All checks passed." + From c92b1f9757cb1c5bd3c5fad8b86b0047e0dff6a1 Mon Sep 17 00:00:00 2001 From: smog-root Date: Sun, 20 Oct 2024 20:37:23 +0530 Subject: [PATCH 2/4] Update pr-checker.yaml --- .github/workflows/pr-checker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checker.yaml b/.github/workflows/pr-checker.yaml index dbab3ef..2d3e74c 100644 --- a/.github/workflows/pr-checker.yaml +++ b/.github/workflows/pr-checker.yaml @@ -43,7 +43,7 @@ if not re.search(r'Fixes #[0-9]+', pr_description): # Check if the PR title starts with FIX, FEAT, or DOC if not re.match(r'^(FIX|FEAT|DOC)', pr_title): - print('The PR title should start with FIX, FEAT, or DOC.') + print('The PR title should start with Fixes, Closes, or FIX.') sys.exit(1) print('PR description and title are valid.') From 8809ace66bc994d8421b975276fb496dc71400dc Mon Sep 17 00:00:00 2001 From: smog-root Date: Sun, 20 Oct 2024 20:40:54 +0530 Subject: [PATCH 3/4] Update pr-checker.yaml --- .github/workflows/pr-checker.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-checker.yaml b/.github/workflows/pr-checker.yaml index 2d3e74c..71901d3 100644 --- a/.github/workflows/pr-checker.yaml +++ b/.github/workflows/pr-checker.yaml @@ -42,7 +42,8 @@ if not re.search(r'Fixes #[0-9]+', pr_description): sys.exit(1) # Check if the PR title starts with FIX, FEAT, or DOC -if not re.match(r'^(FIX|FEAT|DOC)', pr_title): +if not re.match(r'^(Fixes|Close|Closes|Closed|Fix|Fixed|Resolve|Resolves +Resolved)', pr_title): print('The PR title should start with Fixes, Closes, or FIX.') sys.exit(1) From de5940fe44e7c1b7fac095e6fbcd9b2143b6e4af Mon Sep 17 00:00:00 2001 From: smog-root Date: Sun, 20 Oct 2024 20:46:30 +0530 Subject: [PATCH 4/4] Update pr-checker.yaml --- .github/workflows/pr-checker.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-checker.yaml b/.github/workflows/pr-checker.yaml index 71901d3..52f6dda 100644 --- a/.github/workflows/pr-checker.yaml +++ b/.github/workflows/pr-checker.yaml @@ -38,13 +38,13 @@ if not pr_description: # Check if the PR description contains 'Fixes #' if not re.search(r'Fixes #[0-9]+', pr_description): - print('The PR description should include Fixes #.') + print('The PR description should include Fixes , Close, Closes, Closed , Fix , Fixed , Resolve , Resolves #.') sys.exit(1) # Check if the PR title starts with FIX, FEAT, or DOC if not re.match(r'^(Fixes|Close|Closes|Closed|Fix|Fixed|Resolve|Resolves Resolved)', pr_title): - print('The PR title should start with Fixes, Closes, or FIX.') + print('The PR title should start with Fixes , Close, Closes, Closed , Fix , Fixed , Resolve , Resolves') sys.exit(1) print('PR description and title are valid.')