Skip to content

Commit 78a30b7

Browse files
author
Alan Christie
committed
build: Use of pre-commit
1 parent b03560f commit 78a30b7

File tree

7 files changed

+170
-14
lines changed

7 files changed

+170
-14
lines changed

.cz.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
# Commitizen custom configuration.
3+
# Here we extend it to add all our recognised types into the changelog.
4+
# The default ignores pretty-much anything other than 'feat' and 'fix'.
5+
#
6+
# See the default at...
7+
# https://github.com/commitizen-tools/commitizen/
8+
# blob/095f02e6c419b60c90aa84b8cebc9e9eacc8a391/commitizen/defaults.py#L83
9+
commitizen:
10+
name: cz_customize
11+
# What's the first revision we're interested imn?
12+
# For us it's the revision we started using
13+
# enforcing the use of conventional commits.
14+
# Prior to 0.4.0 we weren't using it on every commit
15+
# and didn't have everything ready for change-logs.
16+
changelog_start_rev: 1.7.0
17+
customize:
18+
schema_pattern: "^(?P<change_type>feat|fix|perf|refactor|remove|style|test|build|docs|ci|BREAKING CHANGE)(?:\\((?P<scope>[^()\\r\\n]*)\\)|\\()?(?P<breaking>!)?:\\s(?P<message>.*)?"
19+
commit_parser: "^(?P<change_type>feat|fix|perf|refactor|remove|style|test|build|docs|ci|BREAKING CHANGE)(?:\\((?P<scope>[^()\\r\\n]*)\\)|\\()?(?P<breaking>!)?:\\s(?P<message>.*)?"
20+
# The changelog_pattern identifies the commit types
21+
# that will be included.
22+
# Build the changelog with 'cz ch' on the staging or production branches.
23+
changelog_pattern: "^(feat|fix|perf|refactor|remove|style|test|build|docs|ci)?"
24+
# A mapping of type to its group name in the changelog.
25+
# We call 'feat' commits 'New Features'
26+
change_type_map:
27+
build: Build
28+
docs: Documentation
29+
feat: New Features
30+
fix: Bug Fixes
31+
perf: Performance Improvements
32+
refactor: Refactoring
33+
remove: Removed
34+
style: Stylistic Changes
35+
ci: CI/CD
36+
test: Testing
37+
# The order of commit types in the changelog...
38+
change_type_order:
39+
- "feat"
40+
- "fix"
41+
- "perf"
42+
- "refactor"
43+
- "remove"
44+
- "style"
45+
- "test"
46+
- "build"
47+
- "ci"
48+
- "docs"

.github/workflows/build.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ jobs:
4242
python -m pip install --upgrade pip
4343
pip install -r requirements.txt
4444
pip install -r build-requirements.txt
45-
pip install -r package-requirements.txt
4645
- name: Test
4746
run: |
47+
pre-commit run --all-files
4848
pytest --cov=decoder
49-
pyroma .
50-
pylint decoder
51-
mypy decoder --install-types --non-interactive
5249
- name: Build
5350
run: |
54-
python setup.py bdist_wheel
51+
python -m build --sdist --wheel --outdir dist/

.github/workflows/publish.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ jobs:
4040
run: |
4141
python -m pip install --upgrade pip
4242
pip install -r build-requirements.txt
43-
pip install -r package-requirements.txt
4443
- name: Build
4544
run: |
46-
pyroma .
47-
python setup.py bdist_wheel
45+
python -m build --sdist --wheel --outdir dist/
4846
- name: Publish
4947
uses: pypa/gh-action-pypi-publish@release/v1
5048
with:

.pre-commit-config.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
minimum_pre_commit_version: 2.18.1
3+
4+
repos:
5+
6+
# commit-msg hooks
7+
# ----------
8+
9+
# Conventional Commit message checker (commitizen)
10+
- repo: https://github.com/commitizen-tools/commitizen
11+
rev: v2.23.0
12+
hooks:
13+
- id: commitizen
14+
stages:
15+
- commit-msg
16+
17+
# pre-commit hooks
18+
# ----------
19+
20+
# Standard pre-commit rules
21+
- repo: https://github.com/pre-commit/pre-commit-hooks
22+
rev: v4.1.0
23+
hooks:
24+
- id: check-case-conflict
25+
- id: check-docstring-first
26+
- id: check-executables-have-shebangs
27+
- id: check-shebang-scripts-are-executable
28+
- id: check-toml
29+
- id: detect-private-key
30+
- id: end-of-file-fixer
31+
- id: requirements-txt-fixer
32+
- id: trailing-whitespace
33+
args:
34+
- --markdown-linebreak-ext=md
35+
# Black (uncompromising) Python code formatter
36+
- repo: https://github.com/psf/black
37+
rev: 22.3.0
38+
hooks:
39+
- id: black
40+
args:
41+
- --target-version
42+
- py39
43+
# MyPy
44+
- repo: https://github.com/pre-commit/mirrors-mypy
45+
rev: v0.942
46+
hooks:
47+
- id: mypy
48+
files: ^decoder
49+
args:
50+
- --install-types
51+
- --non-interactive
52+
# YAML Lint
53+
- repo: https://github.com/adrienverge/yamllint
54+
rev: v1.26.3
55+
hooks:
56+
- id: yamllint
57+
# Pyroma
58+
- repo: https://github.com/regebro/pyroma
59+
rev: "4.0"
60+
hooks:
61+
- id: pyroma
62+
63+
# Local hooks (requires a suitable env)
64+
# -----
65+
# The following expect 'pip install -r requirements.txt'
66+
67+
# Pylint
68+
- repo: local
69+
hooks:
70+
- id: pylint
71+
name: pylint
72+
entry: pylint
73+
language: system
74+
files: ^decoder/.*\.py$

.yamllint

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
yaml-files:
4+
- '*.yaml'
5+
- '*.yml'
6+
- '.yamllint'
7+
8+
ignore: |
9+
.github/
10+
11+
rules:
12+
indentation:
13+
spaces: 2
14+
indent-sequences: no
15+
trailing-spaces: {}
16+
truthy:
17+
allowed-values:
18+
- 'yes'
19+
- 'no'
20+
- 'true'
21+
- 'false'
22+
new-lines:
23+
type: unix
24+
new-line-at-end-of-file: enable
25+
key-duplicates: {}
26+
hyphens:
27+
max-spaces-after: 1
28+
empty-lines:
29+
max: 2
30+
document-start:
31+
present: yes
32+
document-end:
33+
present: no
34+
colons:
35+
max-spaces-before: 0
36+
max-spaces-after: 1
37+
commas:
38+
max-spaces-before: 0
39+
min-spaces-after: 1
40+
max-spaces-after: 1

build-requirements.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pylint
2-
pyroma
3-
pytest
4-
pytest-cov
5-
mypy
1+
black == 22.3.0
2+
pre-commit == 2.18.1
3+
pytest == 7.1.1
4+
pytest-cov == 3.0.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
jsonschema == 3.2.0
21
jinja2 == 3.0.3
2+
jsonschema == 3.2.0
33
pyyaml == 5.4.1

0 commit comments

Comments
 (0)