Merge "Merge the tox-pep8 and tox-format jobs and use tox-linters"

This commit is contained in:
Zuul 2018-10-17 14:59:04 +00:00 committed by Gerrit Code Review
commit a6f7b40d4a
5 changed files with 62 additions and 20 deletions

View File

@ -10,6 +10,7 @@
vars:
tox_envlist: py3
# TODO: Delete this, all linters have been merged into tox-linters
- job:
name: tox-format
parent: tox

View File

@ -7,12 +7,9 @@
jobs:
- ara-server-ansible-integration:
voting: false
- tox-format
- tox-linters
- tox-py3
- tox-pep8
gate:
jobs:
- tox-format
- tox-linters
- tox-py3
- tox-pep8

View File

@ -40,8 +40,8 @@ Documentation
git clone https://github.com/openstack/ara-server
cd ara-server
# Install tox
pip install tox # (or the tox python library from your distro packages)
# Install tox from pip or from your distro packages
pip install tox
# Run an Ansible playbook integrated ara-server, ara-clients and ara-plugins
# This will exercise all three components and record real data from Ansible
@ -51,8 +51,8 @@ Documentation
tox -e runserver
# Run actual tests or get coverage
tox -e pep8
tox -e py35
tox -e linters
tox -e py3
tox -e cover
# Build docs

53
tests/linters.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
# Copyright (c) 2018 Red Hat, Inc.
#
# This file is part of ARA: Ansible Run Analysis.
#
# ARA is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ARA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ARA. If not, see <http://www.gnu.org/licenses/>.
# The parent directory of this script
tests=$(dirname $0)
export PROJECT_ROOT=$(cd `dirname $tests` && pwd -P)
export PROJECT_LIB="${PROJECT_ROOT}/ara"
function banner() {
echo
printf '#%.0s' {1..50}
echo
echo "# ${1}"
printf '#%.0s' {1..50}
echo
}
# Let this script work even though it might not be run by tox
if [ -z "${VIRTUAL_ENV}" ]; then
pushd "${PROJECT_ROOT}"
tox -e linters --notest
source .tox/linters/bin/activate
popd
fi
banner black
time black --diff --check "${PROJECT_LIB}"
banner isort
time isort --recursive --check-only --diff "${PROJECT_LIB}"
banner flake8
time flake8 "${PROJECT_LIB}"
# B303 - Use of insecure MD2, MD4, or MD5 hash function.
# We're using sha1 to generate a hash of file contents.
banner bandit
time bandit -r "${PROJECT_LIB}" --skip B303

13
tox.ini
View File

@ -17,12 +17,8 @@ commands = {posargs}
[testenv:docs]
commands = sphinx-build -W -b html doc/source doc/build/html
[testenv:pep8]
# B303 - Use of insecure MD2, MD4, or MD5 hash function.
# We're using sha1 to generate a hash of file contents.
commands =
flake8 ara hacking
bandit -r ara --skip B303
[testenv:linters]
commands = {toxinidir}/tests/linters.sh
[testenv:py3]
commands = python manage.py test ara
@ -57,8 +53,3 @@ commands =
coverage run {toxinidir}/manage.py test ara/server
coverage run -a {toxinidir}/manage.py test ara/api
coverage html
[testenv:format]
commands =
black --diff --check ara
isort --recursive --check-only --diff --virtual-env {envdir} ara