ara/tests/linters.sh
David Moreau Simard 91e731c705
Rename pyproject.toml to .black.toml to address pep517
Tox has brought to our attention that using pyproject.toml along
with setup.py/setup.cfg is confusing.

Since the only thing we're using it for is to configure black,
rename the file and use it as a black-specific configuration file
to address the confusion.

Fixes: https://github.com/ansible-community/ara/issues/33
Change-Id: I8d03927cefcfe076aa88ca6b87d45f055de9a4f4
2019-04-24 21:17:34 -04:00

66 lines
1.7 KiB
Bash
Executable File

#!/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"
ret=0
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 --config ${PROJECT_ROOT}/.black.toml --diff --check "${PROJECT_LIB}"
ret+=$?
banner isort
time isort --recursive --check-only --diff "${PROJECT_LIB}"
ret+=$?
banner flake8
time flake8 "${PROJECT_LIB}"
ret+=$?
# 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
ret+=$?
if [ $ret -gt 0 ]
then
echo
echo "At least one linter detected errors!"
exit 1
fi