Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
pre-commit and travis for book
Browse files Browse the repository at this point in the history
  • Loading branch information
luotao1 committed Dec 27, 2016
1 parent 5bfec9a commit 7622d88
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[style]
based_on_style = pep8
column_limit = 80
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: python
cache: ccache
sudo: required
dist: trusty
os:
- linux
env:
- JOB=PRE_COMMIT

addons:
apt:
packages:
- git
- python
- python-pip
- python2.7-dev
- python-wheel
before_install:
- pip install wheel virtualenv pre-commit
script:
- travis/precommit.sh
notifications:
email:
on_success: change
on_failure: always
18 changes: 18 additions & 0 deletions travis/precommit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/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 ..
export PATH=/usr/bin:$PATH
pre-commit install

if ! pre-commit run -a ; then
git diff --exit-code
fi

trap : 0

0 comments on commit 7622d88

Please sign in to comment.