Skip to content

Commit

Permalink
Reusable Workflow Experiment: Upstreaming commit message checks
Browse files Browse the repository at this point in the history
- Bringing checks from os-autoinst/openQA#5343.
- Setting up reusable workflows [0].

[0]: https://docs.github.com/en/actions/using-workflows/reusing-workflows
  • Loading branch information
josegomezr committed Oct 24, 2023
1 parent e555e72 commit 96cf0da
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
---
# https://github.com/marketplace/actions/gs-commit-message-checker
name: 'Commit Message Check'
# yamllint disable-line rule:truthy
on: [push, pull_request]

on:
workflow_call:
secrets:
accessToken:
required: true

jobs:
check-commit-message:
base-check-commit-message:
name: Check Commit Message
uses: gsactions/commit-message-checker@v2
runs-on: ubuntu-latest
steps:
- name: Check Subject Begining
uses: gsactions/commit-message-checker@v1
uses: gsactions/commit-message-checker@v2
with:
pattern: '^([A-Z]|\S+:)'
pattern: '^([A-Z]|\S+:|git subrepo pull)'
flags: 'g'
error: 'The subject does not start with a capital or tag.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}
accessToken: ${{ secrets.accessToken }}
- name: Check Subject Line Length
uses: gsactions/commit-message-checker@v1
uses: gsactions/commit-message-checker@v2
with:
pattern: '^.{1,72}(\n|$)'
flags: 'g'
error: 'The maximum subject line length of 72 characters is exceeded.'
excludeDescription: 'true' # excludes the description body of a pull request
excludeTitle: 'true' # excludes the title of a pull request
checkAllCommitMessages: 'true' # checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # only required if checkAllCommitMessages is true
accessToken: ${{ secrets.accessToken }} # only required if checkAllCommitMessages is true
- name: Check Subject Ending
uses: gsactions/commit-message-checker@v2
with:
pattern: '^.+(?<!\.)(\n|$)'
flags: 'g'
error: 'The subject cannot not end with a dot.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.accessToken }}
- name: Check Empty Line
uses: gsactions/commit-message-checker@v1
uses: gsactions/commit-message-checker@v2
with:
pattern: '^.*(\n\n|$)'
flags: 'g'
error: 'No newline between title and description.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}
accessToken: ${{ secrets.accessToken }}
15 changes: 15 additions & 0 deletions .github/workflows/commit-message-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: 'Commit Message Check'

on:
pull_request:
push:
branches:
# we must not fix commit messages when they already reached master
- '!master'

jobs:
call-check-commit-message:
uses: ./.github/workflows/base-commit-message-checker.yml
secrets:
accessToken: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 96cf0da

Please sign in to comment.