fixed linters
- workaround for ansible-lint failure with new setuptools - bumping linters - consolidated linters configuration Partial-Bug: https://bugs.launchpad.net/tripleo/+bug/1848512 Change-Id: Ic763d5b39d5059526ee5de99fec82bec7524d460
This commit is contained in:
parent
2d6989b812
commit
6bd8a4df1e
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v2.0.0
|
rev: v2.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
@ -15,14 +15,14 @@ repos:
|
|||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
files: .*\.(yaml|yml)$
|
files: .*\.(yaml|yml)$
|
||||||
- repo: https://github.com/adrienverge/yamllint.git
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
rev: v1.13.0
|
rev: v1.18.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
files: \.(yaml|yml)$
|
files: \.(yaml|yml)$
|
||||||
types: [file, yaml]
|
types: [file, yaml]
|
||||||
entry: yamllint --strict -f parsable
|
entry: yamllint --strict -f parsable
|
||||||
- repo: https://github.com/ansible/ansible-lint
|
- repo: https://github.com/ansible/ansible-lint
|
||||||
rev: v3.5.1
|
rev: v4.1.1a0
|
||||||
hooks:
|
hooks:
|
||||||
- id: ansible-lint
|
- id: ansible-lint
|
||||||
files: \.(yaml|yml)$
|
files: \.(yaml|yml)$
|
||||||
@ -31,7 +31,6 @@ repos:
|
|||||||
rev: 0.6.0
|
rev: 0.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: bashate
|
- id: bashate
|
||||||
entry: bashate --error . --verbose --ignore=E006,E040
|
|
||||||
# Run bashate check for all bash scripts
|
# Run bashate check for all bash scripts
|
||||||
# Ignores the following rules:
|
# Ignores the following rules:
|
||||||
# E006: Line longer than 79 columns (as many scripts use jinja
|
# E006: Line longer than 79 columns (as many scripts use jinja
|
||||||
@ -39,3 +38,4 @@ repos:
|
|||||||
# E040: Syntax error determined using `bash -n` (as many scripts
|
# E040: Syntax error determined using `bash -n` (as many scripts
|
||||||
# use jinja templating, this will often fail and the syntax
|
# use jinja templating, this will often fail and the syntax
|
||||||
# error will be discovered in execution anyway)
|
# error will be discovered in execution anyway)
|
||||||
|
entry: bashate --error . --verbose --ignore=E006,E040
|
||||||
|
3
bindep.txt
Normal file
3
bindep.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# debian requirements (linters)
|
||||||
|
libffi-dev [platform:dpkg]
|
||||||
|
libssl-dev [platform:dpkg]
|
@ -1,53 +0,0 @@
|
|||||||
# Copyright Red Hat, Inc. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from ansiblelint import AnsibleLintRule
|
|
||||||
|
|
||||||
|
|
||||||
def incorrect_task(task, cmd):
|
|
||||||
if 'shell' not in task:
|
|
||||||
return False
|
|
||||||
if 'register' in task:
|
|
||||||
return False
|
|
||||||
if task.get('ignore_errors'):
|
|
||||||
return False
|
|
||||||
|
|
||||||
if isinstance(task['shell'], dict):
|
|
||||||
args = task['shell']['cmd'].split()
|
|
||||||
else:
|
|
||||||
args = task['shell'].split()
|
|
||||||
if not set(args).isdisjoint(cmd) and 'pipefail' not in args:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class ShellPipefail(AnsibleLintRule):
|
|
||||||
id = 'OOOQ0001'
|
|
||||||
shortdesc = 'Shell should have a pipefail'
|
|
||||||
description = 'Shell commands should have "set -o pipefail" if using PIPE'
|
|
||||||
tags = ['shell']
|
|
||||||
cmd = ["|", "timestamper_cmd"]
|
|
||||||
|
|
||||||
def matchplay(self, file, play):
|
|
||||||
ret = []
|
|
||||||
if play.get('block') and not play.get('ignore_errors'):
|
|
||||||
block = play['block']
|
|
||||||
for task in block:
|
|
||||||
if incorrect_task(task, self.cmd):
|
|
||||||
ret.append((file, self.shortdesc))
|
|
||||||
else:
|
|
||||||
if incorrect_task(play, self.cmd):
|
|
||||||
ret.append((file, self.shortdesc))
|
|
||||||
return ret
|
|
12
setup.cfg
12
setup.cfg
@ -36,3 +36,15 @@ universal = 1
|
|||||||
[pbr]
|
[pbr]
|
||||||
skip_authors = True
|
skip_authors = True
|
||||||
skip_changelog = True
|
skip_changelog = True
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
# E402 module level import not at top of file
|
||||||
|
# E501 line too long
|
||||||
|
# F403 'from ansible.module_utils.basic import *' used; unable to detect undefined names
|
||||||
|
# H303 No wildcard (*) import
|
||||||
|
# H301 one import per line
|
||||||
|
# F405 ... may be undefined, or defined from star imports:
|
||||||
|
show-source = True
|
||||||
|
ignore = E123,E125,E402,E501,F403,H303,H301,F405
|
||||||
|
builtins = _
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
openstackdocstheme>=1.11.0 # Apache-2.0
|
openstackdocstheme>=1.11.0 # Apache-2.0
|
||||||
|
|
||||||
pre-commit>=1.10 # MIT License
|
|
||||||
sphinx>=1.6.2 # BSD
|
sphinx>=1.6.2 # BSD
|
||||||
reno>=1.8.0 # Apache-2.0
|
reno>=1.8.0 # Apache-2.0
|
||||||
jinja2
|
jinja2
|
||||||
|
56
tox.ini
56
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 2.0
|
minversion = 3.4.0
|
||||||
envlist = linters
|
envlist = linters
|
||||||
skipdist = True
|
skipdist = True
|
||||||
|
|
||||||
@ -7,6 +7,15 @@ skipdist = True
|
|||||||
usedevelop = True
|
usedevelop = True
|
||||||
install_command = pip install -U {opts} {packages}
|
install_command = pip install -U {opts} {packages}
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
|
passenv =
|
||||||
|
ANSIBLE_*
|
||||||
|
CURL_CA_BUNDLE
|
||||||
|
DOCKER_*
|
||||||
|
MOLECULE_*
|
||||||
|
REQUESTS_CA_BUNDLE
|
||||||
|
SSH_AUTH_SOCK
|
||||||
|
SSL_CERT_FILE
|
||||||
|
TERM
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
|
|
||||||
@ -23,21 +32,6 @@ commands = bindep test
|
|||||||
basepython = python3
|
basepython = python3
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx
|
||||||
|
|
||||||
[testenv:bashate]
|
|
||||||
envdir = {toxworkdir}/linters
|
|
||||||
commands =
|
|
||||||
python -m pre_commit run bashate --all-files
|
|
||||||
|
|
||||||
[testenv:pep8]
|
|
||||||
basepython = python3
|
|
||||||
envdir = {toxworkdir}/linters
|
|
||||||
commands =
|
|
||||||
python -m pre_commit run flake8 --all-files
|
|
||||||
|
|
||||||
[testenv:ansible-lint]
|
|
||||||
envdir = {toxworkdir}/linters
|
|
||||||
commands =
|
|
||||||
python -m pre_commit run ansible-lint -a
|
|
||||||
|
|
||||||
[testenv:releasenotes]
|
[testenv:releasenotes]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
@ -46,30 +40,16 @@ commands = bash -c ci-scripts/releasenotes_tox.sh
|
|||||||
|
|
||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
|
deps =
|
||||||
|
# workaround for https://github.com/ansible/ansible-lint/issues/590
|
||||||
|
virtualenv==16.3.0 # 16.7.6 not working
|
||||||
|
jinja2
|
||||||
|
pre-commit
|
||||||
commands =
|
commands =
|
||||||
# check only modified files:
|
python -m pre_commit run -a
|
||||||
python -m pre_commit run --source HEAD^ --origin HEAD
|
# TODO(ssbarnea) make is a real pre-commit hook so we can reuse it
|
||||||
# in the future we may want to check entire repository:
|
python ci-scripts/validate_jinja2.py
|
||||||
# python -m pre_commit run yamllint --all-files
|
|
||||||
{[testenv:validate-jinja]commands}
|
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[flake8]
|
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
|
||||||
# E402 module level import not at top of file
|
|
||||||
# E501 line too long
|
|
||||||
# F403 'from ansible.module_utils.basic import *' used; unable to detect undefined names
|
|
||||||
# H303 No wildcard (*) import
|
|
||||||
# H301 one import per line
|
|
||||||
# F405 ... may be undefined, or defined from star imports:
|
|
||||||
show-source = True
|
|
||||||
ignore = E123,E125,E402,E501,F403,H303,H301,F405
|
|
||||||
builtins = _
|
|
||||||
|
|
||||||
[testenv:validate-jinja]
|
|
||||||
basepython=python2
|
|
||||||
commands =
|
|
||||||
python ci-scripts/validate_jinja2.py
|
|
||||||
|
Loading…
Reference in New Issue
Block a user