Skip to content

Commit

Permalink
DEV: Ensure that the PR titles have the correct format (#2378)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan6419846 authored Dec 29, 2023
1 parent ed0f29c commit 2f4f705
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/scripts/check_pr_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Check that all PR titles follow the desired scheme.""" # noqa: INP001

import os
import sys

KNOWN_PREFIXES = (
"SEC: ",
"BUG: ",
"ENH: ",
"DEP: ",
"PI: ",
"ROB: ",
"DOC: ",
"TST: ",
"DEV: ",
"STY: ",
"MAINT: ",
)
PR_TITLE = os.getenv("PR_TITLE", "")

if not PR_TITLE.startswith(KNOWN_PREFIXES) or not PR_TITLE.split(": ", maxsplit=1)[1]:
sys.stderr.write(
f"The PR title '{PR_TITLE}' does not follow the projects naming scheme: "
"https://pypdf.readthedocs.io/en/latest/dev/intro.html#commit-messages\n",
)
sys.stderr.write(
"If you do not know which one to choose or if multiple apply, make a best guess. "
"Nobody will complain if it does not quite fit :-)\n",
)
sys.exit(1)
else:
sys.stdout.write(f"PR title '{PR_TITLE}' appears to be valid.\n")
6 changes: 6 additions & 0 deletions .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ jobs:
- name: Test with mypy
run : |
mypy pypdf
- name: Check PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
python .github/scripts/check_pr_title.py
if: github.event_name == 'pull_request'

package:
name: Build & verify package
Expand Down

0 comments on commit 2f4f705

Please sign in to comment.