zuul-jobs/tox.ini
Saul Wold e9d96699c7 Add speclint and associated zuul job
This adds the scripts for checking RPM Specfiles and a
zuul project template to be added to the StarlingX repos.
Additionally a tox.ini entry will be required to launch
the check via tox.

See the tox.ini for the rpm-packaging-lint entry.

Depends-On: https://review.opendev.org/677739
Change-Id: I844491aaab34159941e6dd2f1a4528ad5e87f789
Signed-off-by: Saul Wold <sgw@linux.intel.com>
2019-08-26 20:40:27 +00:00

109 lines
3.4 KiB
INI

[tox]
minversion = 1.6
skipsdist = True
envlist = linters
[testenv]
basepython = python3
install_command = pip install {opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
[testenv:bindep]
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
# separately, outside of the requirements files.
deps = bindep
commands = bindep test
[testenv:docs]
whitelist_externals = bash
commands =
bash -c 'if [ -d doc ]; then \
python setup.py build_sphinx; \
fi'
[testenv:linters]
whitelist_externals = bash
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/base/library
ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/base/actiongeneral
commands =
flake8 {posargs}
# Ansible lint
# [ANSIBLE0012] Commands should not change things if nothing needs doing
bash -c 'if [ -d playbooks ]; then \
find playbooks -type f -regex ".*\.ya?ml" -print0 | xargs -t -n1 -0 \
ansible-lint -xANSIBLE0012; \
fi'
bash -c 'if [ -d roles ]; then \
find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | xargs -t -n1 \
ansible-lint -xANSIBLE0012; \
fi'
# Ansible Syntax Check
bash -c 'if [ -d playbooks ]; then \
find playbooks -type f -regex ".*\.ya?ml" -print0 | xargs -t -n1 -0 \
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory; \
fi'
# Check Shell Scripts Syntax
bash -c 'if [ -d scripts ]; then \
find {toxinidir} \
-not \( -type d -name .?\* -prune \) \
-type f \
-not -name \*~ \
-not -name \*.md \
\( \
-name \*.sh \
-or -not -wholename \*/devstack/files/\* \
-wholename \*/devstack/\* \
\) \
-print0 | xargs -t -n1 -0 \
bashate -v -iE006; \
fi'
[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.
ignore = E125,E129,H
show-source = True
exclude = .venv,.tox,dist,doc,build,*.egg
[testenv:pep8]
basepython = python3
usedevelop = False
skip_install = True
deps =
hacking
flake8-bugbear<=19.3.0
flake8<3.6.0
commands =
flake8
[testenv:rpm-packaging-lint]
basepython = python3
setenv =
VIRTUAL_ENV={envdir}
LC_ALL=en_US.utf-8
install_command = pip install -U \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt} \
{opts} {packages}
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals = bash
commands =
bash -c 'if [ -d {toxinidir}/../zuul-jobs ]; then jobsdir={toxinidir}/../zuul-jobs; \
else jobsdir={toxinidir}/../stx-zuul-jobs; \
fi; \
find . \
-not \( -type d -name .?\* -prune \) \
-not \( -type d -name centos -prune \) \
-type f -name \*.spec \
-print0 | xargs -t -0 $jobsdir/tools/spec-tools/speclint.sh'