Linting hardening via pre-commit
Ease linting by using pre-commit to manage execution of all linters. That change does not require any changes for user, they still can trigger the linting using `tox -e pep8`. Also syncs sphinx requirements with global openstaco ones as these were broken but the check job runs only when the file is touched. Change-Id: Ib07e40f1f87a33474ae9412ddf5ba359eb5d5068
This commit is contained in:
parent
1111d4ad0d
commit
6d152eaf98
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
parseable: true
|
||||||
|
skip_list:
|
||||||
|
- ANSIBLE0006
|
||||||
|
- ANSIBLE0012
|
||||||
|
- ANSIBLE0016
|
||||||
|
- '204' # [E204] Lines should be no longer than 120 chars
|
||||||
|
# E602 https://github.com/ansible/ansible-lint/issues/450
|
||||||
|
- '602' # [E602] Don't compare to empty string
|
||||||
|
# E405 is too new and we need to enable it in a separate change
|
||||||
|
- '405' # [E405] Remote package tasks should have a retry
|
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v2.2.3
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- id: check-byte-order-marker
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: debug-statements
|
||||||
|
- id: check-yaml
|
||||||
|
files: .*\.(yaml|yml)$
|
||||||
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
|
rev: '3.7.7'
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
- repo: https://github.com/ansible/ansible-lint
|
||||||
|
rev: v4.1.0a0
|
||||||
|
hooks:
|
||||||
|
- id: ansible-lint
|
||||||
|
files: \.(yaml|yml)$
|
||||||
|
exclude: ^workbooks/
|
||||||
|
entry: ansible-lint --force-color -v
|
||||||
|
- repo: https://github.com/openstack-dev/bashate.git
|
||||||
|
rev: 0.6.0
|
||||||
|
hooks:
|
||||||
|
- id: bashate
|
||||||
|
entry: bashate --error . --verbose --ignore=E006,E040,E042
|
||||||
|
# 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)
|
|
@ -2,7 +2,6 @@ alabaster==0.7.10
|
||||||
appdirs==1.3.0
|
appdirs==1.3.0
|
||||||
asn1crypto==0.23.0
|
asn1crypto==0.23.0
|
||||||
Babel==2.3.4
|
Babel==2.3.4
|
||||||
bashate==0.2
|
|
||||||
cffi==1.7.0
|
cffi==1.7.0
|
||||||
cliff==2.8.0
|
cliff==2.8.0
|
||||||
cmd2==0.8.0
|
cmd2==0.8.0
|
||||||
|
@ -20,11 +19,9 @@ eventlet==0.20.0
|
||||||
extras==1.0.0
|
extras==1.0.0
|
||||||
fasteners==0.7.0
|
fasteners==0.7.0
|
||||||
fixtures==3.0.0
|
fixtures==3.0.0
|
||||||
flake8==2.5.5
|
|
||||||
futures==3.0.0;python_version=='2.7' or python_version=='2.6'
|
futures==3.0.0;python_version=='2.7' or python_version=='2.6'
|
||||||
gitdb==0.6.4
|
gitdb==0.6.4
|
||||||
GitPython==1.0.1
|
GitPython==1.0.1
|
||||||
hacking==0.12.0
|
|
||||||
idna==2.6
|
idna==2.6
|
||||||
imagesize==0.7.1
|
imagesize==0.7.1
|
||||||
iso8601==0.1.11
|
iso8601==0.1.11
|
||||||
|
|
12
setup.cfg
12
setup.cfg
|
@ -170,3 +170,15 @@ mistral.actions =
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
norecursedirs = .git .tox dist
|
norecursedirs = .git .tox dist
|
||||||
log_cli = true
|
log_cli = true
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
show-source = True
|
||||||
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
# W504/W503 are mutually exclusive and we should avoid them until community
|
||||||
|
# will pick a winner.
|
||||||
|
ignore = E123,E125,W503,W504
|
||||||
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,releasenotes
|
||||||
|
builtins = _
|
||||||
|
|
||||||
|
[pycodestyle]
|
||||||
|
exclude = .eggs,.tox
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
openstackdocstheme>=1.18.1 # Apache-2.0
|
openstackdocstheme>=1.18.1 # Apache-2.0
|
||||||
|
|
||||||
hacking>=1.1.0,<1.2.0 # Apache-2.0
|
|
||||||
|
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
docutils>=0.11 # OSI-Approved Open Source, Public Domain
|
docutils>=0.11 # OSI-Approved Open Source, Public Domain
|
||||||
python-subunit>=1.0.0 # Apache-2.0/BSD
|
python-subunit>=1.0.0 # Apache-2.0/BSD
|
||||||
|
@ -18,5 +16,4 @@ testtools>=2.2.0 # MIT
|
||||||
PyYAML>=3.12 # MIT
|
PyYAML>=3.12 # MIT
|
||||||
reno>=2.5.0 # Apache-2.0
|
reno>=2.5.0 # Apache-2.0
|
||||||
urllib3>=1.21.1 # MIT
|
urllib3>=1.21.1 # MIT
|
||||||
bashate>=0.2 # Apache-2.0
|
|
||||||
requests-mock>=1.2.0 # Apache-2.0
|
requests-mock>=1.2.0 # Apache-2.0
|
||||||
|
|
53
tox.ini
53
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
minversion = 3.8
|
minversion = 3.8
|
||||||
envlist = pep8,py37,py36,py27,molecule
|
envlist = linters,py37,py36,py27,molecule
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
@ -30,16 +30,20 @@ deps =
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands = stestr run {posargs}
|
commands = stestr run {posargs}
|
||||||
whitelist_externals = bash
|
whitelist_externals =
|
||||||
|
bash
|
||||||
|
tox
|
||||||
|
|
||||||
[testenv:bindep]
|
[testenv:bindep]
|
||||||
deps = bindep
|
deps = bindep
|
||||||
commands = bash -c "{toxinidir}/scripts/bindep-install"
|
commands = bash -c "{toxinidir}/scripts/bindep-install"
|
||||||
|
|
||||||
|
# deprecated: covered by linters
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
basepython = python3
|
skip_install = true
|
||||||
commands = flake8
|
deps =
|
||||||
bash -c tools/check_duplicate_jinja_blocks.sh
|
commands =
|
||||||
|
tox -e linters -- flake8
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
|
@ -65,22 +69,12 @@ commands = python setup.py build_sphinx
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = oslo_debug_helper {posargs}
|
commands = oslo_debug_helper {posargs}
|
||||||
|
|
||||||
|
# deprecated: covered by linters
|
||||||
[testenv:bashate]
|
[testenv:bashate]
|
||||||
basepython = python3
|
skip_install = true
|
||||||
|
deps =
|
||||||
commands =
|
commands =
|
||||||
# Run bashate check for all bash scripts
|
tox -e linters -- bashate
|
||||||
# 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 "git ls-files | xargs grep --binary-files=without-match \
|
|
||||||
--files-with-match '^.!.*\(ba\)\?sh$' \
|
|
||||||
--exclude-dir .tox \
|
|
||||||
--exclude-dir .git \
|
|
||||||
| xargs bashate --error . --verbose --ignore=E006,E040,E042"
|
|
||||||
|
|
||||||
[testenv:molecule]
|
[testenv:molecule]
|
||||||
deps =
|
deps =
|
||||||
ansi2html
|
ansi2html
|
||||||
|
@ -96,17 +90,12 @@ deps =
|
||||||
commands =
|
commands =
|
||||||
python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs:roles}
|
python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs:roles}
|
||||||
|
|
||||||
[flake8]
|
[testenv:linters]
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
skip_install = true
|
||||||
|
deps = pre-commit
|
||||||
show-source = True
|
commands =
|
||||||
ignore = E123,E125
|
python -m pre_commit run -a {posargs:}
|
||||||
builtins = _
|
bash -c tools/check_duplicate_jinja_blocks.sh
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,releasenotes
|
|
||||||
|
|
||||||
[testenv:releasenotes]
|
|
||||||
basepython = python3
|
|
||||||
commands = bash -c tools/releasenotes_tox.sh
|
|
||||||
|
|
||||||
[testenv:lower-constraints]
|
[testenv:lower-constraints]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
|
@ -115,6 +104,10 @@ deps =
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
|
|
||||||
|
[testenv:releasenotes]
|
||||||
|
basepython = python3
|
||||||
|
commands = bash -c tools/releasenotes_tox.sh
|
||||||
|
|
||||||
[testenv:requirements]
|
[testenv:requirements]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps =
|
deps =
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
- tripleo-standalone-scenarios-full
|
- tripleo-standalone-scenarios-full
|
||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- openstack-tox-pep8
|
- openstack-tox-linters
|
||||||
- openstack-tox-py27
|
- openstack-tox-py27
|
||||||
- openstack-tox-py35
|
- openstack-tox-py35
|
||||||
- openstack-tox-py36
|
- openstack-tox-py36
|
||||||
- openstack-tox-py37
|
- openstack-tox-py37
|
||||||
- tripleo-ci-centos-7-containers-multinode:
|
- tripleo-ci-centos-7-containers-multinode:
|
||||||
dependencies: &deps_unit_lint
|
dependencies: &deps_unit_lint
|
||||||
- openstack-tox-pep8
|
- openstack-tox-linters
|
||||||
- openstack-tox-py27
|
- openstack-tox-py27
|
||||||
- openstack-tox-py35
|
- openstack-tox-py35
|
||||||
- openstack-tox-py36
|
- openstack-tox-py36
|
||||||
|
@ -80,6 +80,7 @@
|
||||||
gate:
|
gate:
|
||||||
queue: tripleo
|
queue: tripleo
|
||||||
jobs:
|
jobs:
|
||||||
|
- openstack-tox-linters
|
||||||
- openstack-tox-lower-constraints
|
- openstack-tox-lower-constraints
|
||||||
- tripleo-ci-centos-7-scenario009-multinode-oooq-container:
|
- tripleo-ci-centos-7-scenario009-multinode-oooq-container:
|
||||||
files:
|
files:
|
||||||
|
|
Loading…
Reference in New Issue