Add linting jobs

Add usual linting job for this repo to have some basic testing.

Also, add the normal .gitignore to blacklist .tox and some other files.

Note this change is not self-testing since the repo is a config-project.

Change-Id: Ie54095f39f9bb4d10d6f809c573ea712f3885af6
This commit is contained in:
Andreas Jaeger 2019-02-09 11:13:08 +01:00
parent d16a4b86c8
commit 2fb73ee8fa
4 changed files with 94 additions and 0 deletions

14
.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
*.pyc
*~
# Unit test / coverage reports
.coverage
.tox
.stestr
# Sphinx
doc/build
# pbr generates these
AUTHORS
ChangeLog

19
test-requirements.txt Normal file
View File

@ -0,0 +1,19 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
flake8
zuul
# We need to pin the ansible version directly here; per the
# deprecation policy it should trail the version used by Zuul by 4
# weeks to give people time to update before these roles start
# depending on new features. Also note we can't just include zuul
# here to pull in ansible anyway; pip doesn't actually have a
# dependency solver and the uncapped ansible requirement from
# ansible-lint pull in the latest version.
ansible>=2.5.1,<2.6 # https://review.openstack.org/567007
# We need to pin ansible-lint to before 4.0 which blows up all over the place
ansible-lint<4
bashate>=0.2
zuul-sphinx>=0.1.1
stestr>=1.0.0 # Apache-2.0

53
tox.ini Normal file
View File

@ -0,0 +1,53 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = linters
[testenv]
basepython = python3
install_command = pip install {opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
commands = stestr run {posargs}
stestr slowest
[testenv:py27]
basepython = python2.7
[testenv:docs]
commands =
sphinx-build -E -W -d doc/build/doctrees -b html doc/source/ doc/build/html
[testenv:linters]
passenv =
# NOTE(pabelanger): if you'd like to run tox -elinters locally, you'll need
# to export ANSIBLE_ROLES_PATH pointing to the currect repos.
# see openstack-zuul-jobs-linters job for more information.
ANSIBLE_ROLES_PATH
setenv =
ANSIBLE_LIBRARY= {envsitepackagesdir}/zuul/ansible/library
ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/actiongeneral
whitelist_externals = bash
commands =
flake8 {posargs}
# Ansible lint
# [ANSIBLE0012] Commands should not change things if nothing needs doing
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
xargs -t -n1 -0 ansible-lint -xANSIBLE0012"
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
xargs -t -n1 ansible-lint -xANSIBLE0012'
# Ansible Syntax Check
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
[testenv:venv]
commands = {posargs}
[flake8]
# These are ignored intentionally in openstack-infra projects;
# please don't submit patches that solely correct them or enable them.
# E402 - ansible modules put documentation before imports. Align to ansible.
# W504 - line break after binary operator, we cannot have both
# W503 and W504 enabled
ignore = E125,E129,E402,E741,W504,H
show-source = True
exclude = .venv,.tox,dist,doc,build,*.egg

View File

@ -142,3 +142,11 @@
label: ubuntu-xenial
secrets:
- site_logs
- project:
check:
jobs:
- openstack-zuul-jobs-linters
gate:
jobs:
- openstack-zuul-jobs-linters