forked from ouster-lidar/ouster-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Github Actions to check PR messages (ouster-lidar#513)
* Repo settings now always squash merge * Default commit message is lifted from PR description
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import sys | ||
import re | ||
|
||
title_re = r'\A[0-9A-Z][\x20-\x7E]{0,88}([a-zA-Z0-9]|[\)])' | ||
description_re = r'(((\r)?\n[\20-\x7E]{0,100})+)?(\n)?' | ||
|
||
title = os.environ.get("TITLE") | ||
pr_number_string = os.environ.get("PR_NUMBER") | ||
pr_description = "\n" + os.environ.get("PR_BODY") | ||
|
||
# check title length with (PR number) added at end | ||
new_title = title + " (#" + pr_number_string + ")" | ||
|
||
error = False | ||
print(f"Checking PR title {repr(new_title)}...") | ||
if not re.fullmatch(title_re, new_title): | ||
print(f"Error: Please revise the PR title {new_title} " | ||
"to match the regex {title_re} where:\n" | ||
"* the first letter is a capital letter or numeral 0-9\n" | ||
"* title is more than 2 characters long\n" | ||
"* the title is no longer than 90 characters including " | ||
"the addition of (###) for the PR number") | ||
error = True | ||
|
||
print(f"Checking PR description {repr(pr_description)}") | ||
if not re.fullmatch(description_re, pr_description): | ||
print(f"Error: The PR description {repr(pr_description)}, " | ||
"which will be treated as your commit message, does " | ||
"not match the regex {description_re}") | ||
error = True | ||
|
||
if error: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: check-merge-commit-message-on-PR | ||
|
||
run-name: Check merge commit messages by ${{ github.actor }} on ${{ github.ref }} | ||
on: [pull_request] | ||
|
||
jobs: | ||
check_title_and_description: | ||
if: github.event_name == 'pull_request' && ! github.event.pull_request.draft | ||
name: check PR title and description | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: check PR title and description | ||
run: python .github/check_title_and_description.py | ||
shell: bash | ||
env: | ||
TITLE: ${{ github.event.pull_request.title }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_BODY: ${{ github.event.pull_request.body }} |