Skip to content

Commit 20e6631

Browse files
committed
ci: added commit-lint job
1 parent 04b04cb commit 20e6631

File tree

6 files changed

+133
-3
lines changed

6 files changed

+133
-3
lines changed

.github/.commitlint.config.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// More info: https://github.com/wayofdev/npm-shareable-configs/blob/master/packages/commitlint-config/src/index.js
2+
const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/
3+
4+
export default {
5+
extends: ['@commitlint/config-conventional'],
6+
/*
7+
This resolves a linting conflict between commitlint's body-max-line-length
8+
due to @semantic-release/git putting release notes in the commit body
9+
https://github.com/semantic-release/git/issues/331
10+
*/
11+
ignores: [(commitMessage) => automaticCommitPattern.test(commitMessage)],
12+
rules: {
13+
'body-leading-blank': [1, 'always'],
14+
'body-max-line-length': [2, 'always', 120],
15+
'footer-leading-blank': [1, 'always'],
16+
'footer-max-line-length': [2, 'always', 120],
17+
'header-max-length': [2, 'always', 100],
18+
'scope-case': [2, 'always', 'lower-case'],
19+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
20+
'subject-empty': [2, 'never'],
21+
'subject-full-stop': [2, 'never', '.'],
22+
'type-case': [2, 'always', 'lower-case'],
23+
'type-empty': [2, 'never'],
24+
'type-enum': [
25+
2,
26+
'always',
27+
[
28+
'feat', // New feature
29+
'fix', // Bug fix
30+
'perf', // Performance improvement
31+
'docs', // Documentation changes
32+
'style', // Code style update (formatting, missing semi colons, etc)
33+
'deps', // Dependency updates
34+
'refactor', // Code refactoring
35+
'ci', // Continuous integration changes
36+
'test', // Adding missing tests
37+
'revert', // Revert to a previous commit
38+
'build', // Changes that affect the build system
39+
'chore', // Other changes that don't modify src or test files
40+
'security', // Security improvements
41+
],
42+
],
43+
},
44+
}

.github/.cz.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// @see https://cz-git.qbb.sh/config/#configure-template
2+
module.exports = {
3+
alias: { fd: 'docs: fix typos' },
4+
messages: {
5+
type: 'Select the type of change that you\'re committing:',
6+
scope: 'Denote the SCOPE of this change (optional):',
7+
customScope: 'Denote the SCOPE of this change:',
8+
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
9+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
10+
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
11+
footerPrefixesSelect: 'Select the ISSUES type of changeList by this change (optional):',
12+
customFooterPrefix: 'Input ISSUES prefix:',
13+
footer: 'List any ISSUES by this change. E.g.: #31, #34:\n',
14+
generatingByAI: 'Generating your AI commit subject...',
15+
generatedSelectByAI: 'Select suitable subject by AI generated:',
16+
confirmCommit: 'Are you sure you want to proceed with the commit above?'
17+
},
18+
types: [
19+
{ value: 'feat', name: 'feat: A new feature', emoji: ':sparkles:' },
20+
{ value: 'fix', name: 'fix: A bug fix', emoji: ':bug:' },
21+
{ value: 'perf', name: 'perf: A code change that improves performance', emoji: ':zap:' },
22+
{ value: 'docs', name: 'docs: Documentation only changes', emoji: ':memo:' },
23+
{ value: 'style', name: 'style: Changes that do not affect the meaning of the code', emoji: ':lipstick:' },
24+
{ value: 'deps', name: 'deps: A dependency update', emoji: ':package:' },
25+
{ value: 'refactor', name: 'refactor: A code change that neither fixes a bug nor adds a feature', emoji: ':recycle:' },
26+
{ value: 'ci', name: 'ci: Changes to our CI configuration files and scripts', emoji: ':ferris_wheel:' },
27+
{ value: 'test', name: 'test: Adding missing tests or correcting existing tests', emoji: ':white_check_mark:' },
28+
{ value: 'revert', name: 'revert: Reverts a previous commit', emoji: ':rewind:' },
29+
{ value: 'build', name: 'build: Changes that affect the build system or external dependencies', emoji: ':package:' },
30+
{ value: 'chore', name: 'chore: Other changes that don\'t modify src or test files', emoji: ':hammer:' },
31+
{ value: 'security', name: 'security: A code change that fixes a security issue', emoji: ':lock:' }
32+
],
33+
useEmoji: false,
34+
emojiAlign: 'center',
35+
useAI: false,
36+
aiNumber: 1,
37+
themeColorCode: '',
38+
scopes: [],
39+
allowCustomScopes: true,
40+
allowEmptyScopes: true,
41+
customScopesAlign: 'bottom',
42+
customScopesAlias: 'custom',
43+
emptyScopesAlias: 'empty',
44+
upperCaseSubject: false,
45+
markBreakingChangeMode: false,
46+
allowBreakingChanges: ['feat', 'fix'],
47+
breaklineNumber: 100,
48+
breaklineChar: '|',
49+
skipQuestions: [],
50+
issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }],
51+
customIssuePrefixAlign: 'top',
52+
emptyIssuePrefixAlias: 'skip',
53+
customIssuePrefixAlias: 'custom',
54+
allowCustomIssuePrefix: true,
55+
allowEmptyIssuePrefix: true,
56+
confirmColorize: true,
57+
maxHeaderLength: Infinity,
58+
maxSubjectLength: Infinity,
59+
minSubjectLength: 0,
60+
scopeOverrides: undefined,
61+
defaultBody: '',
62+
defaultIssues: '',
63+
defaultScope: '',
64+
defaultSubject: ''
65+
}

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Before you begin, you will need to set up your local development environment. He
2020

2121
- [Pre-commit](https://pre-commit.com) — Automates the running of git pre-commit hooks.
2222
- Installation: `brew install pre-commit` and `make hooks`
23-
- [Commitizen](https://commitizen-tools.github.io/commitizen/#macos) Assists in formatting git commits.
24-
- Installation: `brew install commitizen`
23+
- [Cz-git](https://cz-git.qbb.sh)Commitizen adapter, that assists in formatting git commits.
24+
- Installation: `brew install czg`
2525

2626
<br>
2727

.github/workflows/integrate.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ on: # yamllint disable-line rule:truthy
88
name: 🔍 Continuous integration
99

1010
jobs:
11+
commit-linting:
12+
timeout-minutes: 4
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
pull-requests: read
17+
steps:
18+
- name: 📦 Check out the codebase
19+
uses: actions/checkout@v4.1.1
20+
21+
# See: https://github.com/wagoid/commitlint-github-action
22+
- name: 🧐 Lint commits using "commitlint"
23+
uses: wagoid/commitlint-github-action@v6.0.0
24+
with:
25+
configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs
26+
failOnWarnings: false
27+
failOnErrors: false
28+
helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
29+
1130
code-coverage:
1231
timeout-minutes: 4
1332
runs-on: ${{ matrix.os }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ test-cc: ## Run project php-unit and pest tests in coverage mode and build repor
232232
# Release
233233
# ------------------------------------------------------------------------------------
234234
commit:
235-
cz commit
235+
czg commit --config="./.github/.cz.config.js"
236236
.PHONY: commit
237237

238238
#

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<a href="https://packagist.org/packages/wayofdev/laravel-package-tpl"><img src="https://img.shields.io/packagist/l/wayofdev/laravel-package-tpl?style=flat-square&color=blue" alt="Software License"/></a>
1818
<a href="https://packagist.org/packages/wayofdev/laravel-package-tpl"><img alt="Commits since latest release" src="https://img.shields.io/github/commits-since/wayofdev/laravel-package-tpl/latest?style=flat-square"></a>
1919
<a href="https://packagist.org/packages/wayofdev/laravel-package-tpl"><img alt="PHP Version Require" src="https://poser.pugx.org/wayofdev/laravel-package-tpl/require/php?style=flat-square"></a>
20+
<a href="https://app.codecov.io/gh/wayofdev/laravel-package-tpl"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/wayofdev/laravel-package-tpl?style=flat-square&logo=codecov"></a>
2021
</div>
22+
2123
<br>
2224

2325
# Laravel Package Template

0 commit comments

Comments
 (0)