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/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8664da7d29c45f04abbefe4cd2050e768f139821 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pre-commit +yapf == 0.28.0 diff --git a/scripts/check_code_style.sh b/scripts/check_code_style.sh new file mode 100644 index 0000000000000000000000000000000000000000..481d5ad1c96096914a2888ef0f3904638e40919b --- /dev/null +++ b/scripts/check_code_style.sh @@ -0,0 +1,20 @@ +#!/bin/bash +function abort(){ + echo "Your change doesn't follow X2Paddle'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