Skip to content

Commit 274b8e5

Browse files
committed
ci: Add commitlint job to CI
1 parent f4d87b4 commit 274b8e5

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

.github/workflows/validate.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111

1212
jobs:
1313
linuxNode16:
14-
name: '[Linux] Node.js v16: Lint, Formatting & Unit tests'
14+
name: '[Linux] Node.js v16: Lint, Eventual Commitlint, Eventual Changelog, Formatting & Unit tests'
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
@@ -75,6 +75,16 @@ jobs:
7575
run: npm run prettier-check:updated
7676
- name: Validate ESLint rules
7777
run: npm run lint:updated
78+
- name: Validate commit messages
79+
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
80+
run: npx commitlint -f master
81+
- name: Validate changelog (if new version)
82+
run: |
83+
NEW_VERSION=`git diff -U0 master package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
84+
if [ -n "$NEW_VERSION" ];
85+
then
86+
npx dump-release-notes-from-cc-changelog $NEW_VERSION
87+
fi
7888
- name: Unit tests
7989
run: script -e -c "npm test"
8090

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Changelog
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4-

commitlint.config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
module.exports = {
4+
rules: {
5+
'body-leading-blank': [2, 'always'],
6+
'footer-leading-blank': [2, 'always'],
7+
'header-max-length': [2, 'always', 72],
8+
'scope-enum': [2, 'always', ['', 'Config', 'Log']],
9+
'subject-case': [2, 'always', 'sentence-case'],
10+
'subject-empty': [2, 'never'],
11+
'subject-full-stop': [2, 'never', '.'],
12+
'type-case': [2, 'always', 'lower-case'],
13+
'type-empty': [2, 'never'],
14+
'type-enum': [
15+
2,
16+
'always',
17+
[
18+
'build',
19+
'chore',
20+
'ci',
21+
'docs',
22+
'feat',
23+
'fix',
24+
'perf',
25+
'refactor',
26+
'style',
27+
'test',
28+
],
29+
],
30+
},
31+
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"main": "index.js",
3939
"bin": {},
4040
"scripts": {
41+
"commitlint": "commitlint -f HEAD@{15}",
4142
"format": "prettier --write '{.,lib}/*.{js,md}'",
4243
"lint": "eslint *.js lib/*.js && prettier -c '{.,lib}/*.{js,md}'",
4344
"lint:updated": "pipe-git-updated --ext=js -- eslint",

0 commit comments

Comments
 (0)