Skip to content

Commit 88e3e61

Browse files
assignUserfacebook-github-bot
authored andcommitted
build(ci): Add conventional commit title check (facebookincubator#11520)
Summary: Check the PR title against cc pattern added in facebookincubator#11356. Fails with a pointer to CONTRIBUTING.md. We are running the title change on every commit as it takes under 5 seconds to run and this way we avoid weird states with skipped checks overriding failed results when the title was triggered outside of a commit. We could add a comment to the PR but that would require a workflow with elevated permissions using `pull_request_target` which should be avoided if possible. So I think the marginally lower ux is justified, we still get a marker/reminder for reviewers through this job. Pull Request resolved: facebookincubator#11520 Reviewed By: pedroerp Differential Revision: D65947963 Pulled By: Yuhta fbshipit-source-id: 290b97f784011367d3e481ff49f42b7da65fdf7a
1 parent 9494cbc commit 88e3e61

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/preliminary_checks.yml

+25
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ name: Run Checks
1515

1616
on:
1717
pull_request:
18+
types:
19+
- opened
20+
- reopened
21+
- edited
22+
- synchronize
1823

1924
permissions:
2025
contents: read
@@ -70,3 +75,23 @@ jobs:
7075
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
7176
exit 1
7277
fi
78+
79+
title-check:
80+
name: PR Title Format
81+
runs-on: ubuntu-latest
82+
steps:
83+
- shell: python
84+
env:
85+
title: "${{ github.event.pull_request.title }}"
86+
run: |
87+
import re
88+
import os
89+
title = os.environ["title"]
90+
title_re = r"^(feat|fix|build|test|docs|refactor|misc)(\(.+\))?!?: ([A-Z].+)[^.]$"
91+
match = re.search(title_re, title)
92+
93+
if match is None:
94+
print("::error::Please follow conventional commit guidelines in commit titles as described in CONTRIBUTING.md: https://github.com/facebookincubator/velox/blob/main/CONTRIBUTING.md#commit-messages")
95+
exit(1)
96+
else:
97+
exit(0)

0 commit comments

Comments
 (0)