summaryrefslogtreecommitdiffstats
path: root/jjb/releng-macros.yaml
diff options
context:
space:
mode:
authorTrevor Bramwell <tbramwell@linuxfoundation.org>2016-04-12 12:06:51 -0700
committerTrevor Bramwell <tbramwell@linuxfoundation.org>2016-04-12 16:11:39 -0700
commit135a03ece1781852e026a4bb3fae1f8cebf61453 (patch)
treec259f233db907fd6b99c61056158602a9424b384 /jjb/releng-macros.yaml
parent81c7a55635d6b64c403a948869064b1d70238ade (diff)
Add Python Linting Job
Triggers a flake8 run against any python code in the repo. JIRA: RELENG-81 Change-Id: Ia57d640b5aacdc4f99620ffa3ee345f208b426ea Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'jjb/releng-macros.yaml')
-rw-r--r--jjb/releng-macros.yaml44
1 files changed, 44 insertions, 0 deletions
diff --git a/jjb/releng-macros.yaml b/jjb/releng-macros.yaml
index 8c1539c8b..3bac38a2a 100644
--- a/jjb/releng-macros.yaml
+++ b/jjb/releng-macros.yaml
@@ -321,6 +321,50 @@
deactivate
- builder:
+ name: lint-python-code
+ builders:
+ - shell: |
+ #!/bin/bash
+ set -o errexit
+ set -o pipefail
+ set -o xtrace
+ export PATH=$PATH:/usr/local/bin/
+
+ virtualenv -p python2.7 $WORKSPACE/releng_flake8
+ source $WORKSPACE/releng_flake8/bin/activate
+
+ # install python packages
+ pip install flake8
+
+ # generate and upload lint log
+ echo "Running flake8 code on $PROJECT ..."
+
+ echo -e "Flake8 Violations\n-----------------" >> lint.log
+ find . -type f -name "*.py" | \
+ xargs flake8 --exit-zero --first >> lint.log
+
+ deactivate
+
+- builder:
+ name: report-lint-result-to-gerrit
+ builders:
+ - shell: |
+ #!/bin/bash
+ set -o errexit
+ set -o pipefail
+ set -o xtrace
+ export PATH=$PATH:/usr/local/bin/
+ if [[ -e lint.log ]] ; then
+ echo -e "\nposting linting report to gerrit...\n"
+ cat lint.log
+ echo
+ ssh -p 29418 gerrit.opnfv.org \
+ "gerrit review -p $GERRIT_PROJECT \
+ -m '$(cat lint.log)' \
+ $GERRIT_PATCHSET_REVISION"
+ fi
+
+- builder:
name: upload-review-docs
builders:
- build-html-and-pdf-docs-output