Run bashate via pre-commit
Migrates bashate linting task to pre-commit in order to allow fast and transparent execution before uploading changes to gerrit. Other linters can be run as well, including flake8 and ansible-linter. This also lowers the footprint on developer machines because each linter/version is stored only once on disk, regardless how many repositories are using it. Only action needed for enabling pre-commit as a developer is to run `pip install pre-commit`, everything else is done transparently after. Partial-Bug: #1786286 Change-Id: I6ad834bbfbaf7645c542e4f922e89bc4449247c3
This commit is contained in:
parent
a472345db1
commit
1c6cfa1e46
|
@ -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)
|
|
@ -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
|
||||
|
|
13
tox.ini
13
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 =
|
||||
|
|
Loading…
Reference in New Issue