Skip to content

Commit

Permalink
build(ci): Add conventional commit title check (#11520)
Browse files Browse the repository at this point in the history
Summary:
Check the PR title against cc pattern added  in #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: #11520

Reviewed By: pedroerp

Differential Revision: D65947963

Pulled By: Yuhta

fbshipit-source-id: 290b97f784011367d3e481ff49f42b7da65fdf7a
  • Loading branch information
assignUser authored and facebook-github-bot committed Nov 14, 2024
1 parent 9494cbc commit 88e3e61
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/preliminary_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ name: Run Checks

on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize

permissions:
contents: read
Expand Down Expand Up @@ -70,3 +75,23 @@ jobs:
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
exit 1
fi
title-check:
name: PR Title Format
runs-on: ubuntu-latest
steps:
- shell: python
env:
title: "${{ github.event.pull_request.title }}"
run: |
import re
import os
title = os.environ["title"]
title_re = r"^(feat|fix|build|test|docs|refactor|misc)(\(.+\))?!?: ([A-Z].+)[^.]$"
match = re.search(title_re, title)
if match is None:
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")
exit(1)
else:
exit(0)

0 comments on commit 88e3e61

Please sign in to comment.