diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..69cd7c720dffc742458dba0bb432794b160026e4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: python + +python: + - '2.7' + - '3.5' + - '3.6' + +script: + - if [[ $TRAVIS_PYTHON_VERSION != 2.7 ]]; then /bin/bash ./scripts/check_code_style.sh; fi + +notifications: + email: + on_success: change + on_failure: always diff --git a/scripts/check_code_style.sh b/scripts/check_code_style.sh new file mode 100644 index 0000000000000000000000000000000000000000..682b9cd3d19ae7d776a77c5a0b12b36ef8f8a692 --- /dev/null +++ b/scripts/check_code_style.sh @@ -0,0 +1,20 @@ +#!/bin/bash +function abort(){ + echo "Your change doesn't follow PaddleHub's code style." 1>&2 + echo "Please use pre-commit to check what is wrong." 1>&2 + exit 1 +} + +trap 'abort' 0 +set -e + +cd $TRAVIS_BUILD_DIR +export PATH=/usr/bin:$PATH +pre-commit install + +if ! pre-commit run -a ; then + git diff + exit 1 +fi + +trap : 0