Merge the tox-pep8 and tox-format jobs and use tox-linters
black and isort fit into the category of linters. Let's run everything from the same job so we can avoid wasting time and resources from the CI infrastructure. Previously, tox would exit immediately if there was an error with black, preventing isort from running. You could then run into a situation where you also had an issue picked up by isort. Now bash will run all linters and return the appropriate return code at the end. Change-Id: I81abe61be65bd9f4f828cfc5f0b7a1d9f1eb1f22
This commit is contained in:
parent
53118108f7
commit
1f205e2ad9
@ -10,6 +10,7 @@
|
|||||||
vars:
|
vars:
|
||||||
tox_envlist: py3
|
tox_envlist: py3
|
||||||
|
|
||||||
|
# TODO: Delete this, all linters have been merged into tox-linters
|
||||||
- job:
|
- job:
|
||||||
name: tox-format
|
name: tox-format
|
||||||
parent: tox
|
parent: tox
|
||||||
|
@ -7,12 +7,9 @@
|
|||||||
jobs:
|
jobs:
|
||||||
- ara-server-ansible-integration:
|
- ara-server-ansible-integration:
|
||||||
voting: false
|
voting: false
|
||||||
- tox-format
|
- tox-linters
|
||||||
- tox-py3
|
- tox-py3
|
||||||
- tox-pep8
|
|
||||||
gate:
|
gate:
|
||||||
jobs:
|
jobs:
|
||||||
- tox-format
|
- tox-linters
|
||||||
- tox-py3
|
- tox-py3
|
||||||
- tox-pep8
|
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ Documentation
|
|||||||
git clone https://github.com/openstack/ara-server
|
git clone https://github.com/openstack/ara-server
|
||||||
cd ara-server
|
cd ara-server
|
||||||
|
|
||||||
# Install tox
|
# Install tox from pip or from your distro packages
|
||||||
pip install tox # (or the tox python library from your distro packages)
|
pip install tox
|
||||||
|
|
||||||
# Run an Ansible playbook integrated ara-server, ara-clients and ara-plugins
|
# Run an Ansible playbook integrated ara-server, ara-clients and ara-plugins
|
||||||
# This will exercise all three components and record real data from Ansible
|
# This will exercise all three components and record real data from Ansible
|
||||||
@ -51,8 +51,8 @@ Documentation
|
|||||||
tox -e runserver
|
tox -e runserver
|
||||||
|
|
||||||
# Run actual tests or get coverage
|
# Run actual tests or get coverage
|
||||||
tox -e pep8
|
tox -e linters
|
||||||
tox -e py35
|
tox -e py3
|
||||||
tox -e cover
|
tox -e cover
|
||||||
|
|
||||||
# Build docs
|
# Build docs
|
||||||
|
53
tests/linters.sh
Executable file
53
tests/linters.sh
Executable 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
13
tox.ini
@ -17,12 +17,8 @@ commands = {posargs}
|
|||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
commands = sphinx-build -W -b html doc/source doc/build/html
|
commands = sphinx-build -W -b html doc/source doc/build/html
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:linters]
|
||||||
# B303 - Use of insecure MD2, MD4, or MD5 hash function.
|
commands = {toxinidir}/tests/linters.sh
|
||||||
# We're using sha1 to generate a hash of file contents.
|
|
||||||
commands =
|
|
||||||
flake8 ara hacking
|
|
||||||
bandit -r ara --skip B303
|
|
||||||
|
|
||||||
[testenv:py3]
|
[testenv:py3]
|
||||||
commands = python manage.py test ara
|
commands = python manage.py test ara
|
||||||
@ -57,8 +53,3 @@ commands =
|
|||||||
coverage run {toxinidir}/manage.py test ara/server
|
coverage run {toxinidir}/manage.py test ara/server
|
||||||
coverage run -a {toxinidir}/manage.py test ara/api
|
coverage run -a {toxinidir}/manage.py test ara/api
|
||||||
coverage html
|
coverage html
|
||||||
|
|
||||||
[testenv:format]
|
|
||||||
commands =
|
|
||||||
black --diff --check ara
|
|
||||||
isort --recursive --check-only --diff --virtual-env {envdir} ara
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user