diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2f8a3b96..f76aca78 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -43,3 +43,12 @@ jobs: key: pip|${{ hashFiles('setup.py') }}|${{ hashFiles('tox.ini') }} - run: pip install tox - run: tox -e docs + style: + runs-on: ubuntu-latest + steps: + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }} + - run: pip install tox + - run: tox -e style diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..db5d5feb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +--- +repos: + - repo: https://github.com/asottile/reorder_python_imports + rev: v3.1.0 + hooks: + - id: reorder-python-imports + args: ["--application-directories", "src"] + - repo: https://github.com/psf/black + rev: 22.6.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-byte-order-marker + - id: trailing-whitespace + - id: end-of-file-fixer diff --git a/setup.cfg b/setup.cfg index 2a633da1..aa401da6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [tox:tox] -envlist = py37,py38,py39,py310,docs +envlist = py37,py38,py39,py310,docs,style [testenv] deps = --editable .[test] @@ -15,5 +15,10 @@ source-dir = docs/source build-dir = docs/build all_files = 1 +[testenv:style] +deps = pre-commit +skip_install = true +commands = pre-commit run --all-files --show-diff-on-failure + [upload_sphinx] upload-dir = docs/build/html