From 732c1985efde2ef0ef1e0c57c2e0ef464be6a2e9 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Mon, 22 Aug 2016 10:22:42 -0500 Subject: Overhaul Spack's CI Infrastructure --- share/spack/qa/run-doc-tests | 4 ++ share/spack/qa/run-flake8 | 86 ----------------------------------------- share/spack/qa/run-flake8-tests | 86 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 86 deletions(-) create mode 100755 share/spack/qa/run-doc-tests delete mode 100755 share/spack/qa/run-flake8 create mode 100755 share/spack/qa/run-flake8-tests (limited to 'share') diff --git a/share/spack/qa/run-doc-tests b/share/spack/qa/run-doc-tests new file mode 100755 index 0000000000..e5b684fe59 --- /dev/null +++ b/share/spack/qa/run-doc-tests @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# pass +exit 0 diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8 deleted file mode 100755 index ffc82313a5..0000000000 --- a/share/spack/qa/run-flake8 +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# -# This script runs source code style checks on Spack. -# -# 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 - -# Move to Spack root; allows script to be run from anywhere -cd "$(dirname "$0")/../../.." - -# Add changed files that have been committed since branching off of develop -changed=($(git diff --name-only --find-renames develop... -- '*.py')) -# Add changed files that have been staged but not yet committed -changed+=($(git diff --name-only --find-renames --cached -- '*.py')) -# Add changed files that are unstaged -changed+=($(git diff --name-only --find-renames -- '*.py')) -# Add new files that are untracked -changed+=($(git ls-files --exclude-standard --other -- '*.py')) - -# Ensure that each file in the array is unique -changed=($(printf '%s\n' "${changed[@]}" | sort -u)) - -function cleanup { - # Restore original package files after modifying them. - for file in "${changed[@]}"; do - if [[ -e "${file}.sbak~" ]]; then - mv "${file}.sbak~" "${file}" - fi - done -} - -# Cleanup temporary files upon exit or when script is killed -trap cleanup EXIT SIGINT SIGTERM - -# Add approved style exemptions to the changed packages. -for file in "${changed[@]}"; do - # Make a backup to restore later - cp "$file" "$file.sbak~" - - # - # Exemptions for package.py files - # - if [[ $file = *package.py ]]; then - # Exempt lines with urls and descriptions from overlong line errors. - perl -i -pe 's/^(\s*homepage\s*=.*)$/\1 # NOQA: ignore=E501/' $file - perl -i -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file - perl -i -pe 's/^(\s*version\(.*\).*)$/\1 # NOQA: ignore=E501/' $file - perl -i -pe 's/^(\s*variant\(.*\).*)$/\1 # NOQA: ignore=E501/' $file - perl -i -pe 's/^(\s*depends_on\(.*\).*)$/\1 # NOQA: ignore=E501/' $file - perl -i -pe 's/^(\s*extends\(.*\).*)$/\1 # NOQA: ignore=E501/' $file - - # Exempt '@when' decorated functions from redefinition errors. - perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1 # NOQA: ignore=F811/' $file - fi - - # - # Exemptions for all files - # - perl -i -pe 's/^(.*(https?|file)\:.*)$/\1 # NOQA: ignore=E501/' $file -done - -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." - exit 1 - fi -else - echo No core framework files modified. -fi - -exit 0 diff --git a/share/spack/qa/run-flake8-tests b/share/spack/qa/run-flake8-tests new file mode 100755 index 0000000000..9556b0d250 --- /dev/null +++ b/share/spack/qa/run-flake8-tests @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# This script runs source code style checks on Spack. +# +# 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 + +# Move to Spack root; allows script to be run from anywhere +cd "$(dirname "$0")/../../.." + +# Add changed files that have been committed since branching off of develop +changed=($(git diff --name-only --find-renames develop... -- '*.py')) +# Add changed files that have been staged but not yet committed +changed+=($(git diff --name-only --find-renames --cached -- '*.py')) +# Add changed files that are unstaged +changed+=($(git diff --name-only --find-renames -- '*.py')) +# Add new files that are untracked +changed+=($(git ls-files --exclude-standard --other -- '*.py')) + +# Ensure that each file in the array is unique +changed=($(printf '%s\n' "${changed[@]}" | sort -u)) + +function cleanup { + # Restore original package files after modifying them. + for file in "${changed[@]}"; do + if [[ -e "${file}.sbak~" ]]; then + mv "${file}.sbak~" "${file}" + fi + done +} + +# Cleanup temporary files upon exit or when script is killed +trap cleanup EXIT SIGINT SIGTERM + +# Add approved style exemptions to the changed packages. +for file in "${changed[@]}"; do + # Make a backup to restore later + cp "$file" "$file.sbak~" + + # + # Exemptions for package.py files + # + if [[ $file = *package.py ]]; then + # Exempt lines with urls and descriptions from overlong line errors. + perl -i -pe 's/^(\s*homepage\s*=.*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*version\(.*\).*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*variant\(.*\).*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*depends_on\(.*\).*)$/\1 # NOQA: ignore=E501/' $file + perl -i -pe 's/^(\s*extends\(.*\).*)$/\1 # NOQA: ignore=E501/' $file + + # Exempt '@when' decorated functions from redefinition errors. + perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1 # NOQA: ignore=F811/' $file + fi + + # + # Exemptions for all files + # + perl -i -pe 's/^(.*(https?|file)\:.*)$/\1 # NOQA: ignore=E501/' $file +done + +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." + exit 1 + fi +else + echo No core framework files modified. +fi + +exit 0 -- cgit v1.2.3-60-g2f50