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/README.md b/README.md index edebfc2a07e7c043a9a1b2355dbcd8d5ce9ab223..f6aeb27757959f5d28d2ae931a6fd5b9120d66a6 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # 深度学习入门 1. [新手入门](fit_a_line/README.md) -1. [个性化推荐](recommender_system/README.md) 1. [识别数字](recognize_digits/README.md) 1. [图像分类](image_classification/README.md) 1. [词向量](word2vec/README.md) 1. [情感分析](understand_sentiment/README.md) 1. [文本序列标注](label_semantic_roles/README.md) 1. [机器翻译](machine_translation/README.md) +1. [个性化推荐](recommender_system/README.md) 1. [图像自动生成](gan/README.md) 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