summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-05-11 16:11:19 +0200
committeralalazo <massimiliano.culpo@googlemail.com>2016-05-11 16:11:19 +0200
commit78ae5d7723df810e65fe69b4fb0d7773e748e085 (patch)
tree4ab1421b4e3edb44e28441f9a3394a3fe6be7fc5 /share
parent22bb0562fea525afb329d5710970785189d3af63 (diff)
parent3d3a520a7d79f40f167f2856c5787ef94739eedc (diff)
downloadspack-78ae5d7723df810e65fe69b4fb0d7773e748e085.tar.gz
spack-78ae5d7723df810e65fe69b4fb0d7773e748e085.tar.bz2
spack-78ae5d7723df810e65fe69b4fb0d7773e748e085.tar.xz
spack-78ae5d7723df810e65fe69b4fb0d7773e748e085.zip
Merge branch 'develop' of https://github.com/LLNL/spack into features/custom_modulefile_from_config
Conflicts: lib/spack/spack/config.py
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/qa/run-flake855
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