Skip to content

Commit 04d45e4

Browse files
authored
Add pre-commit (#219)
1 parent 0c896f6 commit 04d45e4

18 files changed

+406
-176
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@ jobs:
1111
build:
1212
name: Build & Publish
1313
runs-on: ubuntu-latest
14-
1514
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: 3.7
21-
- name: Pip cache
22-
uses: actions/cache@v1
15+
- uses: actions/checkout@v3
16+
uses: actions/setup-python@v4
2317
with:
24-
path: ~/.cache/pip
25-
key: ${{ runner.os }}-pip
26-
restore-keys: |
27-
${{ runner.os }}-pip
18+
python-version: "3.10"
19+
- run: pip install nox
2820
- name: Build
29-
run: |
30-
pip install --upgrade nox
31-
nox -s docs
21+
run: nox -N -s docs
3222
- name: Publish
3323
if: github.repository_owner == 'lundberg'
3424
run: |

.github/workflows/test.yml

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
name: test
22

33
on:
4-
pull_request:
5-
branches:
6-
- master
74
push:
85
branches:
96
- master
7+
pull_request:
108

119
env:
1210
FORCE_COLOR: 1
@@ -15,51 +13,52 @@ jobs:
1513
test:
1614
name: Test Python ${{ matrix.python-version }}
1715
runs-on: ubuntu-latest
18-
needs: lint
1916
strategy:
20-
max-parallel: 5
17+
max-parallel: 4
2118
matrix:
2219
python-version: ["3.7", "3.8", "3.9", "3.10"]
2320
steps:
24-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2522
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v4
2724
with:
2825
python-version: ${{ matrix.python-version }}
29-
- name: Pip cache
30-
uses: actions/cache@v1
31-
with:
32-
path: ~/.cache/pip
33-
key: ${{ runner.os }}-pip
34-
restore-keys: |
35-
${{ runner.os }}-pip
26+
- run: pip install nox
3627
- name: Test
37-
run: |
38-
pip install --upgrade nox
39-
nox -s test-${{ matrix.python-version }}
40-
- name: Upload report
41-
uses: codecov/codecov-action@v1
28+
run: nox -N -s test-${{ matrix.python-version }} -- -v
29+
- name: Upload coverage report
30+
uses: codecov/codecov-action@v3
4231
with:
43-
token: ${{secrets.CODECOV_TOKEN}}
4432
name: Python ${{ matrix.python-version }}
33+
files: ./coverage.xml
34+
fail_ci_if_error: true
4535

4636
lint:
4737
name: Check Linting
38+
uses: less-action/reusables/.github/workflows/pre-commit.yaml@v6
39+
with:
40+
python-version: "3.10"
41+
42+
check-types:
43+
name: Check Typing
4844
runs-on: ubuntu-latest
4945
steps:
50-
- uses: actions/checkout@v2
51-
- name: Set up Python
52-
uses: actions/setup-python@v2
53-
with:
54-
python-version: 3.7
55-
- name: Pip cache
56-
uses: actions/cache@v1
57-
with:
58-
path: ~/.cache/pip
59-
key: ${{ runner.os }}-pip
60-
restore-keys: |
61-
${{ runner.os }}-pip
62-
- name: Lint
63-
run: |
64-
pip install --upgrade nox
65-
nox -k "check + docs"
46+
- uses: actions/checkout@v3
47+
- uses: actions/setup-python@v4
48+
with:
49+
python-version: "3.7"
50+
- run: pip install nox
51+
- name: Run mypy
52+
run: nox -N -s mypy
53+
54+
check-docs:
55+
name: Check Docs
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v3
59+
- uses: actions/setup-python@v4
60+
with:
61+
python-version: "3.10"
62+
- run: pip install nox
63+
- name: Run mypy
64+
run: nox -N -s docs

.pre-commit-config.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
default_language_version:
2+
python: python3.10
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-toml
11+
- id: end-of-file-fixer
12+
- id: trailing-whitespace
13+
- id: debug-statements
14+
- id: detect-private-key
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v2.37.3
17+
hooks:
18+
- id: pyupgrade
19+
args:
20+
- --py37-plus
21+
- --keep-runtime-typing
22+
- repo: https://github.com/myint/autoflake
23+
rev: v1.5.3
24+
hooks:
25+
- id: autoflake
26+
args:
27+
- --in-place
28+
- --remove-all-unused-imports
29+
- --ignore-init-module-imports
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.10.1
32+
hooks:
33+
- id: isort
34+
- repo: https://github.com/psf/black
35+
rev: 22.8.0
36+
hooks:
37+
- id: black
38+
- repo: https://github.com/PyCQA/flake8
39+
rev: 5.0.4
40+
hooks:
41+
- id: flake8
42+
additional_dependencies:
43+
- flake8-bugbear
44+
- flake8-comprehensions
45+
- flake8-tidy-imports
46+
- flake8-print
47+
- flake8-pytest-style
48+
- flake8-datetimez
49+
- repo: https://github.com/sirosen/check-jsonschema
50+
rev: 0.18.2
51+
hooks:
52+
- id: check-github-workflows
53+
- repo: https://github.com/asottile/yesqa
54+
rev: v1.4.0
55+
hooks:
56+
- id: yesqa
57+
additional_dependencies:
58+
- flake8-bugbear
59+
- flake8-comprehensions
60+
- flake8-tidy-imports
61+
- flake8-print
62+
- flake8-pytest-style
63+
- flake8-datetimez
64+
- repo: https://github.com/pre-commit/mirrors-prettier
65+
rev: "v2.7.1"
66+
hooks:
67+
- id: prettier
68+
alias: format-markdown
69+
types: [markdown]
70+
args:
71+
- --parser=markdown
72+
- --print-width=88
73+
- --prose-wrap=always
74+
- repo: https://github.com/mgedmin/check-manifest
75+
rev: "0.48"
76+
hooks:
77+
- id: check-manifest
78+
args: ["--no-build-isolation"]
79+
80+
exclude: |
81+
(?x)(
82+
/(
83+
\.eggs
84+
| \.git
85+
| \.hg
86+
| \.mypy_cache
87+
| \.pytest_cache
88+
| \.nox
89+
| \.tox
90+
| \.venv
91+
| _build
92+
| buck-out
93+
| build
94+
| dist
95+
)/
96+
| docs
97+
| LICENSE\.md
98+
)

0 commit comments

Comments
 (0)