Skip to content

Commit

Permalink
Add pre-commit (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
lundberg authored Sep 26, 2022
1 parent 0c896f6 commit 04d45e4
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 176 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,14 @@ jobs:
build:
name: Build & Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Pip cache
uses: actions/cache@v1
- uses: actions/checkout@v3
uses: actions/setup-python@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: |
${{ runner.os }}-pip
python-version: "3.10"
- run: pip install nox
- name: Build
run: |
pip install --upgrade nox
nox -s docs
run: nox -N -s docs
- name: Publish
if: github.repository_owner == 'lundberg'
run: |
Expand Down
71 changes: 35 additions & 36 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: test

on:
pull_request:
branches:
- master
push:
branches:
- master
pull_request:

env:
FORCE_COLOR: 1
Expand All @@ -15,51 +13,52 @@ jobs:
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: lint
strategy:
max-parallel: 5
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: |
${{ runner.os }}-pip
- run: pip install nox
- name: Test
run: |
pip install --upgrade nox
nox -s test-${{ matrix.python-version }}
- name: Upload report
uses: codecov/codecov-action@v1
run: nox -N -s test-${{ matrix.python-version }} -- -v
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
name: Python ${{ matrix.python-version }}
files: ./coverage.xml
fail_ci_if_error: true

lint:
name: Check Linting
uses: less-action/reusables/.github/workflows/pre-commit.yaml@v6
with:
python-version: "3.10"

check-types:
name: Check Typing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Pip cache
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: |
${{ runner.os }}-pip
- name: Lint
run: |
pip install --upgrade nox
nox -k "check + docs"
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.7"
- run: pip install nox
- name: Run mypy
run: nox -N -s mypy

check-docs:
name: Check Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install nox
- name: Run mypy
run: nox -N -s docs
98 changes: 98 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements
- id: detect-private-key
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args:
- --py37-plus
- --keep-runtime-typing
- repo: https://github.com/myint/autoflake
rev: v1.5.3
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --ignore-init-module-imports
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-tidy-imports
- flake8-print
- flake8-pytest-style
- flake8-datetimez
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.18.2
hooks:
- id: check-github-workflows
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-tidy-imports
- flake8-print
- flake8-pytest-style
- flake8-datetimez
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
hooks:
- id: prettier
alias: format-markdown
types: [markdown]
args:
- --parser=markdown
- --print-width=88
- --prose-wrap=always
- repo: https://github.com/mgedmin/check-manifest
rev: "0.48"
hooks:
- id: check-manifest
args: ["--no-build-isolation"]

exclude: |
(?x)(
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.pytest_cache
| \.nox
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| docs
| LICENSE\.md
)
Loading

0 comments on commit 04d45e4

Please sign in to comment.