Skip to content

Commit b0c301b

Browse files
authored
Merge pull request #94 from wagoid/style/improve-commitlint-rules
style: ignore body-max-line-length rule for deps commits
2 parents 9befae6 + 6f63f52 commit b0c301b

File tree

7 files changed

+92
-23
lines changed

7 files changed

+92
-23
lines changed

.commitlintrc.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
2-
.commitlintrc.yml
32
commitlint.config.js
43
action.yml
54
.github

.github/workflows/commitlint.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,43 @@ jobs:
1010
fetch-depth: 0
1111
- run: sed -i -E "s/(docker:.+)/Dockerfile/" ./action.yml
1212
- run: echo -n '' > .dockerignore
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: '14'
16+
- uses: actions/cache@v2
17+
with:
18+
path: |
19+
~/.npm
20+
**/node_modules
21+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
22+
restore-keys: |
23+
${{ runner.os }}-node-
24+
- run: npm install
1325
- uses: ./
1426
id: run_commitlint
27+
env:
28+
NODE_PATH: ${{ github.workspace }}/node_modules
1529
- name: Show results from JSON output
1630
if: ${{ always() }}
1731
run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }}
18-
commitlint-with-yml-file:
32+
commitlint-pulling-from-docker-hub:
1933
runs-on: ubuntu-latest
2034
steps:
2135
- uses: actions/checkout@v2
2236
with:
2337
fetch-depth: 0
24-
- run: sed -i -E "s/(docker:.+)/Dockerfile/" ./action.yml
25-
- run: echo -n '' > .dockerignore
26-
- uses: ./
38+
- uses: actions/setup-node@v2
2739
with:
28-
configFile: './.commitlintrc.yml'
29-
commitlint-pulling-from-docker-hub:
30-
runs-on: ubuntu-latest
31-
steps:
32-
- uses: actions/checkout@v2
40+
node-version: '14'
41+
- uses: actions/cache@v2
3342
with:
34-
fetch-depth: 0
43+
path: |
44+
~/.npm
45+
**/node_modules
46+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
47+
restore-keys: |
48+
${{ runner.os }}-node-
49+
- run: npm install
3550
- uses: ./
51+
env:
52+
NODE_PATH: ${{ github.workspace }}/node_modules

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
fetch-depth: 0
135135
- uses: actions/setup-node@v1
136136
with:
137-
node-version: '10.x'
137+
node-version: '14'
138138
- run: npm install
139139
# Run the commitlint action, considering its own dependencies and yours as well 🚀
140140
# `github.workspace` is the path to your repository.

commitlint.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
const { maxLineLength } = require('@commitlint/ensure')
2+
3+
const bodyMaxLineLength = 100
4+
5+
const validateBodyMaxLengthIgnoringDeps = parsedCommit => {
6+
const { type, scope, body } = parsedCommit
7+
const isDepsCommit =
8+
type === 'chore' && (scope === 'deps' || scope === 'deps-dev')
9+
10+
return [
11+
isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength),
12+
`body's lines must not be longer than ${bodyMaxLineLength}`,
13+
]
14+
}
15+
116
module.exports = {
217
extends: ['@commitlint/config-conventional'],
18+
plugins: ['commitlint-plugin-function-rules'],
19+
rules: {
20+
'body-max-line-length': [0],
21+
'function-rules/body-max-line-length': [
22+
2,
23+
'always',
24+
validateBodyMaxLengthIgnoringDeps,
25+
],
26+
},
327
}

package-lock.json

Lines changed: 38 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
},
3535
"devDependencies": {
3636
"@commitlint/cli": "^11.0.0",
37+
"@commitlint/ensure": "^11.0.0",
3738
"@commitlint/test": "^9.0.1",
3839
"@commitlint/test-environment": "^9.0.1",
40+
"commitlint-plugin-function-rules": "^1.1.20",
3941
"conventional-changelog-cli": "^2.1.0",
4042
"husky": "^3.1.0",
4143
"jest": "^24.9.0",

0 commit comments

Comments
 (0)