Bladeren bron

Add lint step to travis

This is to ensure that pull requests fail when they don't obey pep8
enough.
master
David Winterbottom 13 jaren geleden
bovenliggende
commit
4d2732d086
3 gewijzigde bestanden met toevoegingen van 28 en 10 verwijderingen
  1. 1
    3
      .travis.yml
  2. 9
    7
      Makefile
  3. 18
    0
      lint.sh

+ 1
- 3
.travis.yml Bestand weergeven

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

+ 9
- 7
Makefile Bestand weergeven

1
 # These targets are not files
1
 # These targets are not files
2
-.PHONY: contribute ci test i18n
2
+.PHONY: contribute ci test i18n lint travis
3
 
3
 
4
 install:
4
 install:
5
 	python setup.py develop
5
 	python setup.py develop
16
 	sites/sandbox/manage.py loaddata countries.json sites/_fixtures/pages.json sites/_fixtures/auth.json
16
 	sites/sandbox/manage.py loaddata countries.json sites/_fixtures/pages.json sites/_fixtures/auth.json
17
 	sites/sandbox/manage.py rebuild_index --noinput
17
 	sites/sandbox/manage.py rebuild_index --noinput
18
 
18
 
19
-ci:
19
+test: 
20
+	./runtests.py tests/
21
+
22
+ci: install lint
20
 	# Run continous tests and generate lint reports
23
 	# Run continous tests and generate lint reports
21
-	python setup.py develop
22
-	pip install -r requirements.txt
23
 	./runtests.py --with-coverage --with-xunit
24
 	./runtests.py --with-coverage --with-xunit
24
 	coverage xml
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
 i18n:
32
 i18n:
31
 	# Create the .po files used for i18n 
33
 	# Create the .po files used for i18n 

+ 18
- 0
lint.sh Bestand weergeven

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

Laden…
Annuleren
Opslaan