Skip to content

Commit

Permalink
ENH: Add "commit-message" GitHub Actions workflow
Browse files Browse the repository at this point in the history
Adapted from Slicer/Slicer@f39e06f0d

This replaces the usage of https://github.com/marketplace/commitcheck which
has been unreliable at times and also difficult to see what is required to pass
a failing check.

This adds the "Check Commit Prefix" workflow step based on content
available at https://slicer.readthedocs.io/en/latest/developer_guide/style_guide.html#commits.

Co-authored-by: James Butler <james.butler@perkinelmer.com>
  • Loading branch information
jcfr and jamesobutler committed Apr 17, 2023
1 parent 97cc445 commit 47e372f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/commit-message.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Commit Message Check'
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
push:
branches:
- main

jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Prefix
uses: gsactions/commit-message-checker@16fa2d5de096ae0d35626443bcd24f1e756cafee # v2.0.0
with:
pattern: '^(ENH|PERF|BUG|STYLE|DOC|COMP): ([A-Z])+'
flags: 'gm'
excludeDescription: 'true' # optional: this excludes the description body of a pull request
excludeTitle: 'true' # optional: this excludes the title of a pull request
error: 'The first line has to start with a commit prefix, followed by a colon and space, and then followed by a message with a capital letter (e.g "ENH: Add support for awesome feature"). For more details on other requirements, see https://slicer.readthedocs.io/en/latest/developer_guide/style_guide.html#commits'
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
- name: Check Line Length
uses: gsactions/commit-message-checker@16fa2d5de096ae0d35626443bcd24f1e756cafee # v2.0.0
with:
pattern: '^[^#].{1,78}$'
error: 'The maximum line length of 78 characters is exceeded. For more details, see https://slicer.readthedocs.io/en/latest/developer_guide/style_guide.html#commits'
excludeDescription: 'true' # optional: this excludes the description body of a pull request
excludeTitle: 'true' # optional: this excludes the title of a pull request
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true

0 comments on commit 47e372f

Please sign in to comment.