Merge "Run all linters via pre-commit"

This commit is contained in:
Zuul 2019-01-17 22:02:39 +00:00 committed by Gerrit Code Review
commit 4be3d7012e
19 changed files with 77 additions and 62 deletions

View File

@ -1,5 +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

View File

@ -1,7 +1,42 @@
---
repos:
- repo: https://github.com/willthames/ansible-lint.git
rev: v3.5.1
hooks:
- id: ansible-lint
entry: env ANSIBLE_LIBRARY=./library ansible-lint
files: \.(yaml|yml)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: end-of-file-fixer
- 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: flake8
additional_dependencies:
- hacking<1.2.0,>=1.1.0
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.14.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/ansible/ansible-lint
rev: v4.0.1
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
entry: env ANSIBLE_LIBRARY=./library 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
# 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)

View File

@ -1,10 +1,12 @@
---
extends: default
rules:
document-start: disable
line-length:
max: 999
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
key-duplicates: enable
ignore: |
.tox
.tox

View File

@ -199,4 +199,3 @@
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.

View File

@ -1,5 +1,5 @@
---
- name: image-build
src: https://github.com/redhat-openstack/ansible-role-tripleo-image-build
scm: git
version: master

View File

@ -20,4 +20,3 @@ pipelining = True
control_path = %(directory)s/%%h-%%r
ssh_args = -o ControlMaster=auto -o ControlPersist=270s -o ServerAliveInterval=30 -o GSSAPIAuthentication=no
retries = 3

View File

@ -204,4 +204,3 @@ bash $BASE_QUICKSTART_DIR/ci-scripts/full-deploy.sh $RELEASE $BUILD_SYS $CONFIG
popd

View File

@ -125,5 +125,3 @@ The full documentation is in the ``doc/source`` directory, it can be built
using::
tox -e docs

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@ -41,4 +41,4 @@ An example invocation of TripleO-Quickstart::
./quickstart.sh -R rhos-11-rhn-baseos-undercloud -E baseos_rhel_libvirt --tags all $VIRTHOST
[1] `product subscription documentation <https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/sub-cli.html>`_
[1] `product subscription documentation <https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/sub-cli.html>`_

View File

@ -18,4 +18,4 @@ the directory.
Alternatively, you can manually remove the directory before executing
``quickstart.sh``.
rm -r ~/.quickstart
rm -r ~/.quickstart

View File

@ -15,6 +15,9 @@
# generate_baremetal_macs method ripped from
# openstack/tripleo-incubator/scripts/configure-vm
import math
import random
DOCUMENTATION = '''
---
module: generate_macs
@ -24,9 +27,6 @@ description:
- Generate a list of Ethernet MAC addresses suitable for baremetal testing.
'''
import math
import random
MAX_NUM_MACS = math.trunc(0xff / 2)
@ -86,6 +86,8 @@ def main():
module.exit_json(**result)
# see http://docs.ansible.com/developing_modules.html#common-module-boilerplate
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import AnsibleModule # noqa
if __name__ == '__main__':
main()

View File

@ -39,4 +39,3 @@ other:
- Undercloud deploy role moved to tripleo-quickstart-extras
- Added repo configuration to the release configs for usage by the repo-setup
role in tripleo-quickstart-extras

View File

@ -23,4 +23,3 @@ deprecations:
tested into featureset files. For example, the old
minimal.yml file was split into no_netiso.yml and
1ctlr_1comp.yml

View File

@ -2,4 +2,4 @@
- name: Include VBMC setup if enabled
include_tasks: configure-vbmc.yml
when: enable_vbmc|bool
when: enable_vbmc|bool

View File

@ -37,3 +37,9 @@ universal = 1
[pbr]
skip_authors = True
skip_changelog = True
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
builtins = _

View File

@ -1,9 +1,6 @@
openstackdocstheme>=1.11.0 # Apache-2.0
hacking<0.11,>=0.10
bashate>=0.2 # Apache-2.0
docutils>=0.11
sphinx>=1.6.2 # BSD
reno>=1.8.0 # Apache-2.0
yamllint # GPLv3
pre-commit # MIT
pre-commit # MIT

44
tox.ini
View File

@ -26,49 +26,27 @@ basepython = python3
commands = python setup.py build_sphinx
[testenv:bashate]
envdir = {toxworkdir}/linters
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 "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"
python -m pre_commit run bashate -a
[testenv:pep8]
basepython = python3
envdir = {toxworkdir}/linters
commands =
# Run hacking/flake8 check for all python files
bash -c "git ls-files | xargs grep --binary-files=without-match \
--files-with-match '^.!.*python$' \
--exclude-dir .tox \
--exclude-dir .git \
--exclude-dir .eggs \
--exclude-dir *.egg-info \
--exclude-dir dist \
--exclude-dir *lib/python* \
--exclude-dir doc \
| xargs flake8 --verbose"
python -m pre_commit run flake8 -a
[testenv:ansible-lint]
basepython=python2
setenv =
ANSIBLE_LIBRARY=./library
envdir = {toxworkdir}/linters
commands =
python -m pre_commit run --all-files
python -m pre_commit run ansible-lint -a
[testenv:linters]
basepython = python3
commands =
python -m yamllint .
{[testenv:bashate]commands}
{[testenv:pep8]commands}
{[testenv:ansible-lint]commands}
# check only modified files:
python -m pre_commit run -a
[testenv:releasenotes]
basepython = python3
@ -79,9 +57,3 @@ commands = bash -c ci-scripts/releasenotes_tox.sh
changedir = {toxinidir}
commands =
{posargs:echo done}
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
builtins = _

View File

@ -1,3 +1,4 @@
---
- project:
templates:
- tripleo-undercloud-jobs