diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2edd051db681da02979e05411225cd07c3bb76f4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +- repo: https://github.com/Lucas-C/pre-commit-hooks.git + sha: c25201a00e6b0514370501050cf2a8538ac12270 + hooks: + - id: remove-crlf +- repo: https://github.com/reyoung/mirrors-yapf.git + sha: v0.13.2 + hooks: + - id: yapf + files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ # Bazel BUILD files follow Python syntax. +- repo: https://github.com/pre-commit/pre-commit-hooks + sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469 + hooks: + - id: check-added-large-files + - id: check-merge-conflict + - id: check-symlinks + - id: detect-private-key + - id: end-of-file-fixer diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000000000000000000000000000000000000..4741fb4f3bbc6681088cf9e960321e7b857a93a8 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,3 @@ +[style] +based_on_style = pep8 +column_limit = 80 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..f5409798d0baed1d518ff8c85c84fcad0d0fa701 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: cpp +cache: ccache +sudo: required +dist: trusty +os: + - linux +env: + - JOB=PRE_COMMIT + +addons: + apt: + packages: + - git + - python + - python-pip + - python2.7-dev +before_install: + - pip install virtualenv pre-commit +script: + - travis/precommit.sh +notifications: + email: + on_success: change + on_failure: always diff --git a/travis/precommit.sh b/travis/precommit.sh new file mode 100755 index 0000000000000000000000000000000000000000..204ee0533ebfdf93dd19c7a6af2353c30a10abb8 --- /dev/null +++ b/travis/precommit.sh @@ -0,0 +1,19 @@ +#!/bin/bash +function abort(){ + echo "Your commit not fit PaddlePaddle code style" 1>&2 + echo "Please use pre-commit scripts to auto-format your code" 1>&2 + exit 1 +} + +trap 'abort' 0 +set -e +cd `dirname $0` +cd .. +export PATH=/usr/bin:$PATH +pre-commit install + +if ! pre-commit run -a ; then + git diff --exit-code +fi + +trap : 0