Skip to content

Commit

Permalink
infra: update the pre-commit hook with linters (#678)
Browse files Browse the repository at this point in the history
* infra: update the pre-commit hook with linters and secrets check

Co-authored-by: Abe Coull <[email protected]>
Co-authored-by: Cody Wang <[email protected]>
  • Loading branch information
3 people authored Sep 15, 2023
1 parent 687f706 commit 5ca2d16
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .git-template/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
if [ -f .pre-commit-config.yaml ]; then
echo 'pre-commit configuration detected, but `pre-commit install` was never run' 1>&2
exit 1
fi
24 changes: 7 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
repos:
- repo: local
hooks:
- id: tox
name: tox
stages: [push]
language: system
entry: tox
types: [python]
pass_filenames: false

- id: tox_integ_tests
name: tox integ tests
stages: [push]
language: system
entry: tox -e integ-tests
types: [python]
pass_filenames: false
- repo: local
hooks:
- id: tox_linters
name: linters
entry: tox -e linters_check
language: system
types: [python]
29 changes: 29 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ commands =
{[testenv:black]commands}
{[testenv:flake8]commands}

# Read only linter env
[testenv:linters_check]
basepython = python3
skip_install = true
deps =
{[testenv:isort_check]deps}
{[testenv:black_check]deps}
{[testenv:flake8]deps}
commands =
{[testenv:isort_check]commands}
{[testenv:black_check]commands}
{[testenv:flake8]commands}

[testenv:flake8]
basepython = python3
skip_install = true
Expand All @@ -60,6 +73,14 @@ deps =
commands =
isort . {posargs}

[testenv:isort_check]
basepython = python3
skip_install = true
deps =
isort
commands =
isort . -c {posargs}

[testenv:black]
basepython = python3
skip_install = true
Expand All @@ -68,6 +89,14 @@ deps =
commands =
black ./ {posargs}

[testenv:black_check]
basepython = python3
skip_install = true
deps =
black
commands =
black --check . {posargs}

[testenv:docs]
basepython = python3
deps =
Expand Down

0 comments on commit 5ca2d16

Please sign in to comment.