diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-05-11 02:26:07 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2016-05-11 02:26:07 -0700 |
commit | 9030541e4bc3a77f90d16969b6fff0afa387847c (patch) | |
tree | 0934a772d3fb381e8108fbc9c22200e26de5c3d6 /share | |
parent | 98faee1d5c24ddacaeb1bc630ff8c31ba0d74f9b (diff) | |
parent | 78d25ad337e2faaa8cfd589607801acb78aec4d9 (diff) | |
download | spack-9030541e4bc3a77f90d16969b6fff0afa387847c.tar.gz spack-9030541e4bc3a77f90d16969b6fff0afa387847c.tar.bz2 spack-9030541e4bc3a77f90d16969b6fff0afa387847c.tar.xz spack-9030541e4bc3a77f90d16969b6fff0afa387847c.zip |
Merge pull request #929 from epfl-scitas/differentiate_framework_from_packages
QA : make qa checking less painful
Diffstat (limited to 'share')
-rwxr-xr-x | share/spack/qa/run-flake8 | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8 new file mode 100755 index 0000000000..722c7fcba6 --- /dev/null +++ b/share/spack/qa/run-flake8 @@ -0,0 +1,55 @@ +#!/bin/bash +# +# This script runs source code style checks on Spack. +# +# It should be executed from the top-level directory of the repo, +# e.g.: +# +# share/spack/qa/run-flake8 +# +# To run it, you'll need to have the Python flake8 installed locally. +# +PYTHONPATH=./lib/spack:$PYTHONPATH + +flake8="$(which flake8)" +if [[ ! $flake8 ]]; then + echo "ERROR: flake8 is required to run this script." + exit 1 +fi + +# Check if changed files are flake8 conformant [framework] +changed=$(git diff --name-only develop... | grep '.py$') + +# Exempt url lines in changed packages from overlong line errors. +for file in $changed; do + if [[ $file = *package.py ]]; then + perl -i~ -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file; + fi +done + +return_code=0 +if [[ $changed ]]; then + echo ======================================================= + echo flake8: running flake8 code checks on spack. + echo + echo Modified files: + echo $changed | perl -pe 's/^/ /;s/ +/\n /g' + echo ======================================================= + if flake8 --format pylint $changed; then + echo "Flake8 checks were clean." + else + echo "Flake8 found errors." + return_code=1 + fi +else + echo No core framework files modified. +fi + +# Restore original package files after modifying them. +for file in $changed; do + if [[ $file = *package.py ]]; then + mv "${file}~" "${file}" + fi +done + +exit $return_code |