Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix incorrect PR title handling #941

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/pr-verifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Validate PR Title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
WIP_REGEX="^\W?WIP\W"
TAG_REGEX="^\[[[:alnum:]\._-]*\]"
PR_TITLE="${{ github.event.pull_request.title }}"
WIP_REGEX='^\W?WIP\W'
TAG_REGEX='^\[[[:alnum:]\._-]*\]'

# Trim WIP and tags from title
trimmed_title=$(echo "$PR_TITLE" | sed -E "s/$WIP_REGEX//" | sed -E "s/$TAG_REGEX//" | xargs)
trimmed_title=$(echo "${PR_TITLE}" | sed -E "s/${WIP_REGEX}//" | sed -E "s/${TAG_REGEX}//" | xargs)

# Normalize common emojis in text form to actual emojis
trimmed_title=$(echo "$trimmed_title" | sed -E "s/:warning:/⚠/g")
Expand All @@ -29,7 +30,7 @@ jobs:
trimmed_title=$(echo "$trimmed_title" | sed -E "s/:seedling:/🌱/g")

# Check PR type prefix
if [[ "$trimmed_title" =~ ^(⚠|✨|🐛|📖|🚀|🌱) ]]; then
if [[ "${trimmed_title}" =~ ^(⚠|✨|🐛|📖|🚀|🌱) ]]; then
echo "PR title is valid: $trimmed_title"
else
echo "Error: No matching PR type indicator found in title."
Expand All @@ -44,7 +45,7 @@ jobs:
fi

# Check that PR title does not contain Issue or PR number
if [[ "$trimmed_title" =~ \#[0-9]+ ]]; then
if [[ "${trimmed_title}" =~ \#[0-9]+ ]]; then
echo "Error: PR title should not contain issue or PR number."
echo "Issue numbers belong in the PR body as either \"Fixes #XYZ\" (if it closes the issue or PR), or something like \"Related to #XYZ\" (if it's just related)."
exit 1
Expand Down
Loading