Skip to content

Commit 4f36007

Browse files
CI: Setup precommit (#29)
1 parent 04db804 commit 4f36007

11 files changed

+480
-53
lines changed

.auto-changelog-template.hbs

Lines changed: 156 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
11
# Changelog
22

3+
{{!--
4+
Introduction
5+
• This template tries to follow conventional commits format https://www.conventionalcommits.org/en/v1.0.0/
6+
• The template uses regex to filter commit types into their own headings (this is more than just fixes and features headings)
7+
• It also uses the replaceText function in package.json to remove the commit type text from the message, because the headers are shown instead.
8+
• The text 'Breaking:' or 'Breaking changes:' can be located anywhere in the commit.
9+
• The types feat:, fix:, chore:, docs:, refactor:, test:, style:, perf: must be at the beginning of the commit subject with an : on end.
10+
• They can optionally have a scope set to outline the module or component that is affected eg feat(bldAssess):
11+
• There is a short hash on the end of every commit that is currently commented out so that change log did not grow too long (due to some system's file size limitations). You can uncomment if you wish [`{{shorthash}}`]({{href}})
12+
Example Definitions
13+
• feat: A new feature
14+
• fix: A bug fix
15+
• perf: A code change that improves performance
16+
• refactor: A code change that neither fixes a bug nor adds a feature
17+
• style: Changes that do not affect the meaning of the code (white-space, formatting, spelling mistakes, missing semi-colons, etc)
18+
• test: Adding missing tests or correcting existing tests
19+
• docs: Adding/updating documentation
20+
• chore: Something like updating a library version, or moving files to be in a better location and updating all file refs
21+
--}}
22+
23+
24+
{{!-- In package.json need to add this to remove label text from the change log output (because the markdown headers are now used to group them).
25+
NOTES • Individual brackets have been escaped twice to be Json compliant.
26+
• For items that define a scope eg feat(bldAssess): We remove the 1st bracket and then re-add it so we can select the right piece of text
27+
{
28+
"name": "my-awesome-package",
29+
"auto-changelog": {
30+
"replaceText": {
31+
"([bB]reaking:)": "",
32+
"([bB]reaking change:)": "",
33+
"(^[fF]eat:)": "",
34+
"(^[fF]eat\\()": "\\(",
35+
"(^[fF]ix:)": "",
36+
"(^[fF]ix\\()": "\\(",
37+
"(^[cC]hore:)": "",
38+
"(^[cC]hore\\()": "\\(",
39+
"(^[dD]ocs:)": "",
40+
"(^[dD]ocs\\()": "\\(",
41+
"(^[rR]efactor:)": "",
42+
"(^[rR]efactor\\()": "\\(",
43+
"(^[tT]est:)": "",
44+
"(^[tT]est\\()": "\\(",
45+
"(^[sS]tyle:)": "",
46+
"(^[sS]tyle\\()": "\\(",
47+
"(^[pP]erf:)": "",
48+
"(^[pP]erf\\()": "\\("
49+
}
50+
}
51+
}
52+
--}}
53+
54+
{{!--
55+
Regex reminders
56+
^ = starts with
57+
\( = ( character (otherwise it is interpreted as a regex lookup group)
58+
* = zero or more of the previous character
59+
\s = whitespace
60+
. = any character except newline
61+
| = or
62+
[aA] = charcter a or character A
63+
--}}
64+
65+
366
{{#each releases}}
467
{{#if href}}
568
## [{{title}}]({{href}})
@@ -13,14 +76,101 @@
1376
{{summary}}
1477
{{/if}}
1578

16-
{{#each merges}}
17-
- {{#if commit.breaking}}**Breaking change:** {{/if}}{{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
18-
{{/each}}
79+
{{! List commits that fix a given issues}}
1980
{{#each fixes}}
2081
- {{#if commit.breaking}}**Breaking change:** {{/if}}{{commit.subject}}{{#each fixes}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}}){{/each}}
2182
{{/each}}
22-
{{#each commits}}
23-
- {{#if breaking}}**Breaking change:** {{/if}}{{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
24-
{{/each}}
83+
84+
{{! List commits with 'breaking:' or 'Breaking change:' anywhere in the message under a heading}}
85+
{{#commit-list merges heading='### Breaking Changes :warning:' message='[bB]reaking [cC]hange:|[bB]reaking:' exclude='\[skip-changelog\]'}}
86+
- {{message}} @{{author}} <!--[`#{{id}}`]({{href}}) -->
87+
{{/commit-list}}
88+
89+
{{! List commits organised under a heading, but not those already listed in the breaking section }}
90+
{{#commit-list merges heading='### New Features' message='^[fF]eat:|[fF]eat\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
91+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
92+
{{/commit-list}}
93+
94+
{{#commit-list merges heading='### Fixes' message='^[fF]ix:|^[fF]ix\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
95+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
96+
{{/commit-list}}
97+
98+
{{#commit-list merges heading='### Chores And Housekeeping' message='^[cC]hore:|^[cC]hore\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
99+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
100+
{{/commit-list}}
101+
102+
{{#commit-list merges heading='### Documentation Changes' message='^[dD]ocs:|^[dD]ocs\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
103+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
104+
{{/commit-list}}
105+
106+
{{#commit-list merges heading='### Refactoring and Updates' message='^[rR]efactor:|^[rR]efactor\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
107+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
108+
{{/commit-list}}
109+
110+
{{#commit-list merges heading='### Changes to Test Assests' message='^[tT]est:|^[tT]est\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
111+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
112+
{{/commit-list}}
113+
114+
{{#commit-list merges heading='### Tidying of Code eg Whitespace' message='^[sS]tyle:|^[sS]tyle\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
115+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
116+
{{/commit-list}}
117+
118+
{{#commit-list merges heading='### Performance Improvements' message='^[pP]erf:|^[pP]erf\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
119+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
120+
{{/commit-list}}
121+
122+
{{#commit-list merges heading='### CI Improvements' message='^[cC][iI]:|^[cC][iI]\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
123+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
124+
{{/commit-list}}
125+
126+
{{#commit-list merges heading='### Uncategorized Changes' exclude='[bB]reaking [cC]hange:|[bB]reaking:|^[fF]eat:|^[fF]eat\(|^[fF]ix:|^[fF]ix\(|^[cC]hore:|^[cC]hore\(|^[cC][iI]:|^[cC][iI]\(|^[dD]ocs:|^[dD]ocs\(|^[rR]efactor:|^[rR]efactor\(|^[tT]est:|^[tT]est\(|^[sS]tyle:|^[sS]tyle\(|^[pP]erf:|^[pP]erf\(|\[skip-changelog\]'}}
127+
- {{message}} ({{author}}{{#if href}} - [#{{id}}]({{href}}){{/if}})
128+
{{/commit-list}}
129+
130+
{{! List commits with 'breaking:' or 'Breaking change:' anywhere in the message under a heading}}
131+
{{#commit-list commits heading='### Breaking Changes :warning:' message='[bB]reaking [cC]hange:|[bB]reaking:' exclude='\[skip-changelog\]'}}
132+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
133+
{{/commit-list}}
134+
135+
{{! List commits organised under a heading, but not those already listed in the breaking section }}
136+
{{#commit-list commits heading='### New Features' message='^[fF]eat:|[fF]eat\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
137+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
138+
{{/commit-list}}
139+
140+
{{#commit-list commits heading='### Fixes' message='^[fF]ix:|^[fF]ix\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
141+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
142+
{{/commit-list}}
143+
144+
{{#commit-list commits heading='### Chores And Housekeeping' message='^[cC]hore:|^[cC]hore\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
145+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
146+
{{/commit-list}}
147+
148+
{{#commit-list commits heading='### Documentation Changes' message='^[dD]ocs:|^[dD]ocs\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
149+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
150+
{{/commit-list}}
151+
152+
{{#commit-list commits heading='### Refactoring and Updates' message='^[rR]efactor:|^[rR]efactor\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
153+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
154+
{{/commit-list}}
155+
156+
{{#commit-list commits heading='### Changes to Test Assests' message='^[tT]est:|^[tT]est\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
157+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
158+
{{/commit-list}}
159+
160+
{{#commit-list commits heading='### Tidying of Code eg Whitespace' message='^[sS]tyle:|^[sS]tyle\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
161+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
162+
{{/commit-list}}
163+
164+
{{#commit-list commits heading='### Performance Improvements' message='^[pP]erf:|^[pP]erf\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
165+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
166+
{{/commit-list}}
167+
168+
{{#commit-list commits heading='### CI Improvements' message='^[cC][iI]:|^[cC][iI]\(' exclude='[bB]reaking [cC]hange:|[bB]reaking:|\[skip-changelog\]'}}
169+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
170+
{{/commit-list}}
171+
172+
{{#commit-list commits heading='### Uncategorized Changes' exclude='[bB]reaking [cC]hange:|[bB]reaking:|^[fF]eat:|^[fF]eat\(|^[fF]ix:|^[fF]ix\(|^[cC]hore:|^[cC]hore\(|^[cC][iI]:|^[cC][iI]\(|^[dD]ocs:|^[dD]ocs\(|^[rR]efactor:|^[rR]efactor\(|^[tT]est:|^[tT]est\(|^[sS]tyle:|^[sS]tyle\(|^[pP]erf:|^[pP]erf\(|\[skip-changelog\]'}}
173+
- {{subject}} ({{author}}{{#if href}} - [{{shorthash}}]({{href}}){{/if}})
174+
{{/commit-list}}
25175

26176
{{/each}}

.codespellrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[codespell]
2+
skip = .git/*

.pre-commit-config.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
default_language_version:
2+
python: python3.8
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.3.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-case-conflict
9+
- id: check-merge-conflict
10+
- id: check-symlinks
11+
- id: check-yaml
12+
- id: debug-statements
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace
15+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
16+
rev: v8.0.0
17+
hooks:
18+
- id: commitlint
19+
stages:
20+
- commit-msg
21+
additional_dependencies: ['conventional-changelog-conventionalcommits']
22+
- repo: https://github.com/pycqa/isort
23+
rev: 5.10.1
24+
hooks:
25+
- id: isort
26+
- repo: https://github.com/psf/black
27+
rev: 22.3.0
28+
hooks:
29+
- id: black
30+
- repo: https://github.com/codespell-project/codespell
31+
rev: v2.1.0
32+
hooks:
33+
- id: codespell
34+
- repo: https://github.com/PyCQA/pydocstyle
35+
rev: 6.1.1
36+
hooks:
37+
- id: pydocstyle
38+
additional_dependencies: ["toml"]
39+
- repo: https://github.com/PyCQA/flake8
40+
rev: 4.0.1
41+
hooks:
42+
- id: flake8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def external_validation_function(df, output_path, *args, **kwargs):
6767

6868

6969
class ValidationTask2(dvf.task.SetValidationTask):
70-
"""In some cases you might want to keep the docstring to describe what a developper
70+
"""In some cases you might want to keep the docstring to describe what a developer
7171
needs to know, not the end-user. In this case, you can use the ``__specifications__``
7272
attribute to store the specifications."""
7373

commitlint.config.js

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
module.exports = {
2+
parserPreset: 'conventional-changelog-conventionalcommits',
3+
rules: {
4+
'body-leading-blank': [1, 'always'],
5+
'body-max-line-length': [2, 'always', 100],
6+
'footer-leading-blank': [1, 'always'],
7+
'footer-max-line-length': [2, 'always', 100],
8+
'header-max-length': [2, 'always', 100],
9+
'header-case': [2, 'always', 'sentence-case'],
10+
'scope-case': [2, 'always', 'lower-case'],
11+
'subject-case': [2, 'always', 'sentence-case'],
12+
'subject-empty': [1, 'never'],
13+
'subject-full-stop': [2, 'never', '.'],
14+
'type-case': [2, 'always', 'start-case'],
15+
'type-empty': [1, 'never'],
16+
'type-enum': [
17+
2,
18+
'always',
19+
[
20+
'Build',
21+
'Chore',
22+
'CI',
23+
'Docs',
24+
'Feat',
25+
'Fix',
26+
'Perf',
27+
'Refactor',
28+
'Revert',
29+
'Style',
30+
'Test',
31+
],
32+
],
33+
},
34+
prompt: {
35+
questions: {
36+
type: {
37+
description: "Select the type of change that you're committing",
38+
enum: {
39+
Feat: {
40+
description: 'A new feature',
41+
title: 'Features',
42+
emoji: '✨',
43+
},
44+
Fix: {
45+
description: 'A bug fix',
46+
title: 'Bug Fixes',
47+
emoji: '🐛',
48+
},
49+
Docs: {
50+
description: 'Documentation only changes',
51+
title: 'Documentation',
52+
emoji: '📚',
53+
},
54+
Style: {
55+
description:
56+
'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
57+
title: 'Styles',
58+
emoji: '💎',
59+
},
60+
Refactor: {
61+
description:
62+
'A code change that neither fixes a bug nor adds a feature',
63+
title: 'Code Refactoring',
64+
emoji: '📦',
65+
},
66+
Perf: {
67+
description: 'A code change that improves performance',
68+
title: 'Performance Improvements',
69+
emoji: '🚀',
70+
},
71+
Test: {
72+
description: 'Adding missing tests or correcting existing tests',
73+
title: 'Tests',
74+
emoji: '🚨',
75+
},
76+
Build: {
77+
description:
78+
'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
79+
title: 'Builds',
80+
emoji: '🛠',
81+
},
82+
CI: {
83+
description:
84+
'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
85+
title: 'Continuous Integrations',
86+
emoji: '⚙️',
87+
},
88+
Chore: {
89+
description: "Other changes that don't modify src or test files",
90+
title: 'Chores',
91+
emoji: '♻️',
92+
},
93+
Revert: {
94+
description: 'Reverts a previous commit',
95+
title: 'Reverts',
96+
emoji: '🗑',
97+
},
98+
},
99+
},
100+
scope: {
101+
description:
102+
'What is the scope of this change (e.g. component or file name)',
103+
},
104+
subject: {
105+
description:
106+
'Write a short, imperative tense description of the change',
107+
},
108+
body: {
109+
description: 'Provide a longer description of the change',
110+
},
111+
isBreaking: {
112+
description: 'Are there any breaking changes?',
113+
},
114+
breakingBody: {
115+
description:
116+
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself',
117+
},
118+
breaking: {
119+
description: 'Describe the breaking changes',
120+
},
121+
isIssueAffected: {
122+
description: 'Does this change affect any open issues?',
123+
},
124+
issuesBody: {
125+
description:
126+
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
127+
},
128+
issues: {
129+
description: 'Add issue references (e.g. "fix #123", "re #123".)',
130+
},
131+
},
132+
},
133+
};

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "data-validation-framework",
3+
"auto-changelog": {
4+
"replaceText": {
5+
"([bB]reaking: ?)": "",
6+
"([bB]reaking change: ?)": "",
7+
"(^[bB]uild: ?)": "",
8+
"(^[bB]uild\\((.*)\\): ?)": "\\($2\\)",
9+
"(^[cC]hore: ?)": "",
10+
"(^[cC]hore\\((.*)\\): ?)": "\\($2\\)",
11+
"(^[cC][iI]: ?)": "",
12+
"(^[cC][iI]\\((.*)\\): ?)": "\\($2\\)",
13+
"(^[dD]ocs: ?)": "",
14+
"(^[dD]ocs\\((.*)\\): ?)": "\\($2\\)",
15+
"(^[fF]eat: ?)": "",
16+
"(^[fF]eat\\((.*)\\): ?)": "\\($2\\)",
17+
"(^[fF]ix: ?)": "",
18+
"(^[fF]ix\\((.*)\\): ?)": "\\($2\\)",
19+
"(^[pP]erf: ?)": "",
20+
"(^[pP]erf\\((.*)\\): ?)": "\\($2\\)",
21+
"(^[rR]efactor: ?)": "",
22+
"(^[rR]efactor\\((.*)\\): ?)": "\\($2\\)",
23+
"(^[rR]evert: ?)": "",
24+
"(^[rR]evert\\((.*)\\): ?)": "\\($2\\)",
25+
"(^[sS]tyle: ?)": "",
26+
"(^[sS]tyle\\((.*)\\): ?)": "\\($2\\)",
27+
"(^[tT]est: ?)": "",
28+
"(^[tT]est\\((.*)\\): ?)": "\\($2\\)"
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)