Skip to content

Commit b79e217

Browse files
committed
ci: Fix the commit and repo spell checker
Rework the commit linter job to actually spell check commit messages as well. The issue is that it needs a plugin that the action is not taking into account, so we revert to running the actual linter locally. To do this, we need to install the plugin in the runner. Also, we add an extra option to separate the footer from the body, as the default parsing for `commitlint` assumes only the `BREAKING CHANGE` as the separation keyword of the body and footer. Additionally, we skip lines containing backticks, or triple backticks (for code fences). This is a minor downside, but it is nice to be able to include example code blocks in commit messages to showcase the functionality of the patch. If we want to include terms that are not in common dictionaries in commit messages, we should include them in backticks. Finally, we remove typos and replace it with `cspell`, as it seems a bit better in catching typos. Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
1 parent 5ff52e9 commit b79e217

File tree

8 files changed

+458
-25
lines changed

8 files changed

+458
-25
lines changed

.github/linters/.cspell.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": "0.2",
3+
"dictionaryDefinitions": [
4+
{
5+
"name": "project-dict",
6+
"path": "urunc-dict.txt"
7+
}
8+
],
9+
"dictionaries": ["project-dict"],
10+
"words": [ ],
11+
"ignorePaths": [
12+
"node_modules",
13+
"vendor",
14+
"dist",
15+
"build",
16+
"out",
17+
"coverage",
18+
"**/*.lock",
19+
"**/*.pb.go",
20+
"**/*.pb.cc",
21+
"**/*.pb.h",
22+
"**/*.min.js",
23+
"**/*.svg",
24+
"**/*.png",
25+
"**/*.jpg",
26+
"**/*.jpeg",
27+
"**/*.gif",
28+
"**/*.woff",
29+
"**/*.woff2",
30+
"**/*.ttf",
31+
"**/*.eot",
32+
"**/third_party/**",
33+
"**/go.mod",
34+
"**/go.sum"
35+
],
36+
"files": [
37+
"**/**/*",
38+
"**/*",
39+
"*.{go,py,sh,makefile,md,yaml,yml,json}"
40+
],
41+
"ignoreRegExpList": [
42+
"http[s]?://\\S+",
43+
"`[^`]+`",
44+
"\\$[^\\s]+",
45+
"/^Signed-off-by:.*$/gm",
46+
"/^Reviewed-by:.*$/gm",
47+
"/^Approved-by:.*$/gm",
48+
"/^Co-authored-by:.*$/gm",
49+
"/^Tested-by:.*$/gm",
50+
"/^Acked-by:.*$/gm",
51+
"`[^`]+`",
52+
"```[\\s\\S]*?```"
53+
]
54+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const spellcheckPlugin = require('@somehow-digital/commitlint-plugin-spellcheck').default;
2+
3+
module.exports = {
4+
extends: ['@commitlint/config-conventional'],
5+
plugins: [spellcheckPlugin ],
6+
rules: {
7+
'header-max-length': [2, 'always', 72],
8+
'body-max-line-length': [2, 'always', 80],
9+
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
10+
'trailer-exists': [2, 'always', 'Signed-off-by:'],
11+
'spellcheck/subject': [2, 'always'],
12+
'spellcheck/body': [2, 'always'],
13+
'spellcheck/type': [2, 'always'],
14+
'spellcheck/footer': [0, 'always']
15+
},
16+
parserPreset: {
17+
parserOpts: {
18+
noteKeywords: ['Signed-off-by', 'PR'],
19+
},
20+
},
21+
spellcheck: {
22+
config: "./.cspell.json",
23+
skipWords: ['commitlint'], // We add words we would like to ignore here
24+
suggestions: true,
25+
},
26+
};

.github/linters/commitlint.config.mjs

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

.github/linters/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "linters",
3+
"private": true,
4+
"devDependencies": {
5+
"@commitlint/config-conventional": "^18.0.0",
6+
"@somehow-digital/commitlint-plugin-spellcheck": "^1.1.0",
7+
"commitlint": "^18.0.0",
8+
"cspell": "^8.19.4"
9+
}
10+
}
11+

0 commit comments

Comments
 (0)