Browse files

Add lint step to travis

This is to ensure that pull requests fail when they don't obey pep8
enough.
  • Loading branch information...
1 parent 64e2946 commit 4d2732d086fbeba3444f56b799625312bb250068 @codeinthehole codeinthehole committed Sep 24, 2012
Showing with 28 additions and 10 deletions.
  1. +1 −3 .travis.yml
  2. +9 −7 Makefile
  3. +18 −0 lint.sh
View
4 .travis.yml
@@ -4,6 +4,4 @@ python:
- 2.7
install:
script:
- - pip install -r requirements.txt
- - ./setup.py develop
- - ./runtests.py
+ - make travis
View
16 Makefile
@@ -1,5 +1,5 @@
# These targets are not files
-.PHONY: contribute ci test i18n
+.PHONY: contribute ci test i18n lint travis
install:
python setup.py develop
@@ -16,16 +16,18 @@ sandbox: install
sites/sandbox/manage.py loaddata countries.json sites/_fixtures/pages.json sites/_fixtures/auth.json
sites/sandbox/manage.py rebuild_index --noinput
-ci:
+test:
+ ./runtests.py tests/
+
+ci: install lint
# Run continous tests and generate lint reports
- python setup.py develop
- pip install -r requirements.txt
./runtests.py --with-coverage --with-xunit
coverage xml
- flake8 --ignore=W292,E202 oscar | perl -ple "s/: /: [E] /" | grep -v migrations > violations.txt
-test:
- ./runtests.py
+lint:
+ ./lint.sh
+
+travis: install test lint
i18n:
# Create the .po files used for i18n
View
18 lint.sh
@@ -0,0 +1,18 @@
+#/usr/bin/env bash
+
+ERRORFILE="violations.txt"
+THRESHOLD=1050
+IGNORE="W292,E202"
+
+flake8 --ignore=$IGNORE oscar | perl -ple "s/: /: [E] /" | grep -v migrations > $ERRORFILE
+
+# Check that the number of violations is acceptable
+NUMERRORS=`cat $ERRORFILE | wc -l`
+if [ $NUMERRORS -gt $THRESHOLD ]
+then
+ echo
+ echo "Too many flake8 errors - maximum allowed is $THRESHOLD, found $NUMERRORS"
+ echo
+ echo "To fix, run 'make lint' and examine $ERRORFILE"
+ exit 1
+fi

0 comments on commit 4d2732d

Please sign in to comment.