Skip to content

Commit f7240de

Browse files
authored
Running Linter as Part of CI Jobs (#27)
* Adding Travis config * Added CI badge * Running linters with CI * Anchoring pylint version to 1.6.4; More recent versions have a bug where they mistakenly issue warnings for imports like google.auth (pylint-dev/pylint#1084) * Running linter only on Python 2 * More argument validation and other best practices for bash commands
1 parent 42b2bad commit f7240de

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ python:
55
- "3.5"
66
# command to install dependencies
77
install: "pip install -r requirements.txt"
8+
before_script:
9+
- export PY_VERSION=`python -c 'import sys; print sys.version_info.major'`
10+
- if [[ "$PY_VERSION" == '2' ]]; then ./lint.sh all; fi
811
# command to run tests
912
script: pytest

lint.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,27 @@ function lintChangedFiles () {
2828
done
2929
}
3030

31+
set -o errexit
32+
set -o nounset
33+
3134
SKIP_FOR_TESTS="redefined-outer-name,protected-access,missing-docstring"
3235

33-
if [[ $1 = "all" ]]
36+
if [[ "$#" -eq 1 && "$1" = "all" ]]
37+
then
38+
CHECK_ALL=true
39+
elif [[ "$#" -eq 0 ]]
40+
then
41+
CHECK_ALL=false
42+
else
43+
echo "Usage: ./lint.sh [all]"
44+
exit 1
45+
fi
46+
47+
if [[ "$CHECK_ALL" = true ]]
3448
then
35-
lintAllFiles firebase_admin
36-
lintAllFiles tests $SKIP_FOR_TESTS
49+
lintAllFiles "firebase_admin" ""
50+
lintAllFiles "tests" "$SKIP_FOR_TESTS"
3751
else
38-
lintChangedFiles firebase_admin
39-
lintChangedFiles tests $SKIP_FOR_TESTS
52+
lintChangedFiles "firebase_admin" ""
53+
lintChangedFiles "tests" "$SKIP_FOR_TESTS"
4054
fi

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pylint >= 1.6.4
1+
pylint == 1.6.4
22
pytest >= 3.0.6
33
pytest-cov >= 2.4.0
44
tox >= 2.6.0

0 commit comments

Comments
 (0)