Skip to content

Commit

Permalink
Running Linter as Part of CI Jobs (#27)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hiranya911 committed May 19, 2017
1 parent 42b2bad commit f7240de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ python:
- "3.5"
# command to install dependencies
install: "pip install -r requirements.txt"
before_script:
- export PY_VERSION=`python -c 'import sys; print sys.version_info.major'`
- if [[ "$PY_VERSION" == '2' ]]; then ./lint.sh all; fi
# command to run tests
script: pytest
24 changes: 19 additions & 5 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,27 @@ function lintChangedFiles () {
done
}

set -o errexit
set -o nounset

SKIP_FOR_TESTS="redefined-outer-name,protected-access,missing-docstring"

if [[ $1 = "all" ]]
if [[ "$#" -eq 1 && "$1" = "all" ]]
then
CHECK_ALL=true
elif [[ "$#" -eq 0 ]]
then
CHECK_ALL=false
else
echo "Usage: ./lint.sh [all]"
exit 1
fi

if [[ "$CHECK_ALL" = true ]]
then
lintAllFiles firebase_admin
lintAllFiles tests $SKIP_FOR_TESTS
lintAllFiles "firebase_admin" ""
lintAllFiles "tests" "$SKIP_FOR_TESTS"
else
lintChangedFiles firebase_admin
lintChangedFiles tests $SKIP_FOR_TESTS
lintChangedFiles "firebase_admin" ""
lintChangedFiles "tests" "$SKIP_FOR_TESTS"
fi
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint >= 1.6.4
pylint == 1.6.4
pytest >= 3.0.6
pytest-cov >= 2.4.0
tox >= 2.6.0
Expand Down

0 comments on commit f7240de

Please sign in to comment.