diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..c6c053b7e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +--- +repos: + - repo: https://github.com/openstack-dev/bashate.git + rev: 0.6.0 + hooks: + - id: bashate + entry: bashate --error . --verbose --ignore=E006,E040 + # Run bashate check for all bash scripts + # Ignores the following rules: + # E006: Line longer than 79 columns (as many scripts use jinja + # templating, this is very difficult) + # E040: Syntax error determined using `bash -n` (as many scripts + # use jinja templating, this will often fail and the syntax + # error will be discovered in execution anyway) diff --git a/test-requirements.txt b/test-requirements.txt index 698abc9fb..402a18ad8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,7 @@ openstackdocstheme>=1.11.0 # Apache-2.0 hacking<0.11,>=0.10 -bashate>=0.2 # Apache-2.0 +pre-commit>=1.10 # MIT License ansible-lint>=3.5.0 sphinx>=1.6.2 # BSD reno>=1.8.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 1e44d15c3..747da8e09 100644 --- a/tox.ini +++ b/tox.ini @@ -23,18 +23,7 @@ commands = python setup.py build_sphinx [testenv:bashate] commands = -# Run bashate check for all bash scripts -# Ignores the following rules: -# E006: Line longer than 79 columns (as many scripts use jinja -# templating, this is very difficult) -# E040: Syntax error determined using `bash -n` (as many scripts -# use jinja templating, this will often fail and the syntax -# error will be discovered in execution anyway) - bash -c "grep --recursive --binary-files=without-match \ - --files-with-match '^.!.*\(ba\)\?sh$' \ - --exclude-dir .tox \ - --exclude-dir .git \ - {toxinidir} | xargs bashate --error . --verbose --ignore=E006,E040" + python -m pre_commit run bashate --all-files [testenv:pep8] commands =