Skip to content

Commit

Permalink
Fix parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEyo1 committed Feb 22, 2024
1 parent 26dac2b commit 6b86c28
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
types:
- opened
- synchronize
- reopened
- edited

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -107,23 +102,3 @@ jobs:
grep -E "$pattern" "$log_file"
exit 1
fi
remind-pr-author:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Preprocess PR Body with Python
run: |
python scripts/process_message.py "${TEXT_BODY}" > processed_body.txt
env:
TEXT_BODY: ${{ github.event.pull_request.body }}
shell: bash

- name: Extract Proposed Commit Message
run: |
processed_body=$(cat processed_body.txt)
proposed_commit_message=$(echo "$processed_body" | awk '/\*\*Proposed commit message: \(wrap lines at 72 characters\)\*\*/,/\*\*Checklist:\*\* :ballot_box_with_check:/' | tail -n +2 | head -n -3)
echo "Proposed commit message: $proposed_commit_message"
echo "message_filled=$(echo $proposed_commit_message | grep -q '[^[:space:]]'; echo $?)"
38 changes: 38 additions & 0 deletions .github/workflows/pr-message-reminder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PR Message Reminder
on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
types:
- opened
- synchronize
- reopened
- edited

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
remind-pr-author:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Extract Proposed Commit Message
run: |
python scripts/process_message.py "${TEXT_BODY}" > processed_body.txt
processed_body=$(cat processed_body.txt)
proposed_commit_message=$(echo "$processed_body" | awk '/\\*\\*Proposed commit message: \\\(wrap lines at 72 characters\\\)\\*\\*/,/\\*\\*Checklist:\\*\\*/' | tail -n +2 | head -n -3)
echo "Proposed commit message: $proposed_commit_message"
if ! grep -q '[^[:space:]]' <<< "$proposed_commit_message"; then
echo "Please fill in the proposed commit message section in the pull request description."
exit 1
fi
env:
TEXT_BODY: ${{ github.event.pull_request.body }}

4 changes: 0 additions & 4 deletions scripts/process_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
markdown_content = sys.argv[1]

# Preprocessing the markdown content
# add eof
markdown_content = markdown_content.replace('`', '\\`')
markdown_content = markdown_content.replace('\n', '\\n').replace('\r', '').replace('\t', '\\t')
markdown_content = markdown_content.replace('(', '\\(').replace(')', '\\)')
markdown_content = re.sub(r'<!--.*?-->', '', markdown_content, flags=re.DOTALL) # Remove HTML comments
markdown_content = re.sub(r'^\s+', '', markdown_content, flags=re.MULTILINE) # Trim leading whitespace
markdown_content = re.sub(r'\s+$', '', markdown_content, flags=re.MULTILINE) # Trim trailing whitespace

print(markdown_content)

Expand Down

0 comments on commit 6b86c28

Please sign in to comment.