瀏覽代碼

Add lint step to travis

This is to ensure that pull requests fail when they don't obey pep8
enough.
master
David Winterbottom 13 年之前
父節點
當前提交
4d2732d086
共有 3 個文件被更改,包括 28 次插入10 次删除
  1. 1
    3
      .travis.yml
  2. 9
    7
      Makefile
  3. 18
    0
      lint.sh

+ 1
- 3
.travis.yml 查看文件

@@ -4,6 +4,4 @@ python:
4 4
   - 2.7
5 5
 install:
6 6
 script:
7
-  - pip install -r requirements.txt
8
-  - ./setup.py develop
9
-  - ./runtests.py
7
+  - make travis

+ 9
- 7
Makefile 查看文件

@@ -1,5 +1,5 @@
1 1
 # These targets are not files
2
-.PHONY: contribute ci test i18n
2
+.PHONY: contribute ci test i18n lint travis
3 3
 
4 4
 install:
5 5
 	python setup.py develop
@@ -16,16 +16,18 @@ sandbox: install
16 16
 	sites/sandbox/manage.py loaddata countries.json sites/_fixtures/pages.json sites/_fixtures/auth.json
17 17
 	sites/sandbox/manage.py rebuild_index --noinput
18 18
 
19
-ci:
19
+test: 
20
+	./runtests.py tests/
21
+
22
+ci: install lint
20 23
 	# Run continous tests and generate lint reports
21
-	python setup.py develop
22
-	pip install -r requirements.txt
23 24
 	./runtests.py --with-coverage --with-xunit
24 25
 	coverage xml
25
-	flake8 --ignore=W292,E202 oscar | perl -ple "s/: /: [E] /" | grep -v migrations > violations.txt
26 26
 
27
-test:
28
-	./runtests.py
27
+lint:
28
+	./lint.sh
29
+
30
+travis: install test lint
29 31
 
30 32
 i18n:
31 33
 	# Create the .po files used for i18n 

+ 18
- 0
lint.sh 查看文件

@@ -0,0 +1,18 @@
1
+#/usr/bin/env bash
2
+
3
+ERRORFILE="violations.txt"
4
+THRESHOLD=1050
5
+IGNORE="W292,E202"
6
+
7
+flake8 --ignore=$IGNORE oscar | perl -ple "s/: /: [E] /" | grep -v migrations > $ERRORFILE
8
+
9
+# Check that the number of violations is acceptable
10
+NUMERRORS=`cat $ERRORFILE | wc -l`
11
+if [ $NUMERRORS -gt $THRESHOLD ]
12
+then
13
+	echo 
14
+	echo "Too many flake8 errors - maximum allowed is $THRESHOLD, found $NUMERRORS"
15
+	echo 
16
+	echo "To fix, run 'make lint' and examine $ERRORFILE"
17
+	exit 1
18
+fi

Loading…
取消
儲存