-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from cbgbt/commitlint
ci: enable commitlint for PRs
- Loading branch information
Showing
2 changed files
with
70 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,42 @@ | ||
/* [commitlint](https://github.com/conventional-changelog/commitlint) configuration */ | ||
import { | ||
RuleConfigSeverity, | ||
} from '@commitlint/types'; | ||
|
||
export default { | ||
parserPreset: 'conventional-changelog-conventionalcommits', | ||
rules: { | ||
'header-max-length': [RuleConfigSeverity.Error, 'always', 72], // Header should be 72 characters or shorter | ||
'header-trim': [RuleConfigSeverity.Error, 'always'], // No leading/trailing whitespace in header | ||
'subject-empty': [RuleConfigSeverity.Error, 'never'], // No empty subject | ||
'subject-case': [ // Subject line should be lowercase | ||
RuleConfigSeverity.Error, | ||
'never', | ||
['sentence-case', 'start-case', 'pascal-case', 'upper-case']], | ||
'subject-full-stop': [RuleConfigSeverity.Error, 'never'], // No full-stop at end of subject | ||
'body-max-line-length': [RuleConfigSeverity.Error, 'always', 72], // Body lines should be 72 characteres or shorter | ||
'body-leading-blank': [RuleConfigSeverity.Error, 'always'], // Empty line before body | ||
'type-empty': [RuleConfigSeverity.Error, 'never'], // Commit type must be present | ||
'type-case': [RuleConfigSeverity.Error, 'always', 'lower-case'], // Commit type should be lowercase | ||
'type-enum': [ // Commit type allowlist | ||
RuleConfigSeverity.Error, | ||
'always', | ||
[ | ||
'build', | ||
'chore', | ||
'ci', | ||
'docs', | ||
'feat', | ||
'fix', | ||
'perf', | ||
'refactor', | ||
'revert', | ||
'style', | ||
'test', | ||
], | ||
], | ||
}, | ||
ignores: [ | ||
(message) => message.includes("Merge pull request #"), // PR merges are allowed | ||
], | ||
}; |
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,28 @@ | ||
name: Lint Commit Messages | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
|
||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
- name: Install dependencies | ||
run: npm install commitlint @commitlint/config-conventional | ||
- name: Run commitlint against commits in PR | ||
run: | | ||
npx commitlint \ | ||
-g ${{ github.workspace }}/.commitlint.config.mjs \ | ||
--from ${{ github.event.pull_request.base.sha }} \ | ||
--to ${{ github.event.pull_request.head.sha }} \ | ||
--help-url="https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_BASE_REF}/CONTRIBUTING.md" \ | ||
--verbose |