Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/reusable-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ jobs:
- name: Conventional Commit title with offer-free wording
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: python3 scripts/check_pr_title.py
12 changes: 8 additions & 4 deletions scripts/check_pr_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* pass the wording check from scripts/forbidden_words.py (offer-free release notes).

Usage: python3 scripts/check_pr_title.py "feat(backup): add a restore drill"
PR_TITLE="..." python3 scripts/check_pr_title.py (how CI calls it)
PR_TITLE="..." PR_AUTHOR="login" python3 scripts/check_pr_title.py (how CI calls it)
Exit codes: 0 ok, 1 rejected, 2 no title given.
"""

Expand All @@ -26,9 +26,12 @@
TYPES = ("feat", "fix", "docs", "refactor", "perf", "test", "style", "build", "ci", "chore", "revert", "security")
TITLE_RE = re.compile(r"^(?P<type>[a-z]+)(?:\((?P<scope>[a-z0-9][a-z0-9._/-]*)\))?(?P<bang>!)?: (?P<subject>\S.*)$")
MAX_LENGTH = 100
# Bots whose titles follow Conventional Commits but start the summary with a capital ("Bump ...").
# Only the lower-case rule is relaxed for them; format, types, length and wording still apply.
CAPITALISED_SUMMARY_OK = ("dependabot[bot]",)


def problems(title: str) -> list[str]:
def problems(title: str, author: str = "") -> list[str]:
title = title.strip()
out: list[str] = []
m = TITLE_RE.match(title)
Expand All @@ -41,7 +44,8 @@ def problems(title: str) -> list[str]:
subject = m.group("subject")
if subject.endswith("."):
out.append("the summary must not end with a full stop")
if subject[:1].isupper() and not subject.split()[0].isupper():
if (subject[:1].isupper() and not subject.split()[0].isupper()
and author not in CAPITALISED_SUMMARY_OK):
out.append("the summary must start with a lower-case letter (imperative mood: 'add', 'fix')")
if len(title) > MAX_LENGTH:
out.append(f"the title is {len(title)} characters long; keep it to {MAX_LENGTH}")
Expand All @@ -55,7 +59,7 @@ def main(argv: list[str] | None = None) -> int:
if not title.strip():
print("error: no pull request title given", file=sys.stderr)
return 2
found = problems(title)
found = problems(title, os.environ.get("PR_AUTHOR", ""))
for prob in found:
print(f"error: {prob}")
if not found:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_template_copies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

ROOT = Path(__file__).resolve().parent.parent
TEMPLATE = ROOT.parent / "oss-template"
SOURCE_COMMIT = "9a47a307004b95567ae30d917aaa4536eda4045f" # luminare-dev/oss-template, 2026-10-07
SOURCE_COMMIT = "d917a85a876c5f5e83b5001002ed777056655c52" # luminare-dev/oss-template#2, 2026-10-21
COPIES = {
"scripts/forbidden_words.py": "dd4773373f182e457c0200036e0a010f6df880f506e6b5087f7935255300834e",
"scripts/set_byline.py": "7655a30b5d00ccdb88fa468e97055ffac8dcf74fa4c6c3f0695eb0af8787f0e1",
"scripts/check_workflows.py": "3c0a075411d2f0e0143ab130be638d3de7ba3dedc2ce64af19d7f3afb664b247",
"scripts/check_pr_title.py": "a3dc57b7702cd58ff5f98f000bf898964fefa21a029d40644b8d60ab9a4b28ed",
"scripts/check_pr_title.py": "a20da7141a68c291c1c023fab0cd1fb077b718132beae5d69db187bd7322a71d",
".github/workflows/pr-title.yml": "2e6c2aa6b2eef94c5c2a22a30482d9650aab86ff9de88a6a18ba4c7ebf61db6b",
".github/workflows/reusable-ci.yml": "377426a9f5b64960698693b2a04d6b9846c9fab37689d497e2b2346df15e134d",
".github/workflows/reusable-ci.yml": "c9c99667f9389f4c64f8716ea36623a72db682e996d6d1c2f7b6f6f3f3a65af9",
".github/workflows/reusable-gitleaks.yml": "696a42a07731eaa36bd2237e7f7853cb1c664306b51a7d84e156d3d0f069abf6",
".gitleaks.toml": "0e9a0915d0bc2636c6b59f8d0c8631fb64def2d9224f7c99b9e4709dc7d62d72",
}
Expand Down
Loading