Skip to content

Commit d2bdd25

Browse files
author
Yibing Liu
authored
Merge pull request #355 from PaddlePaddle/update_master
Update master
2 parents 522efca + 77a456b commit d2bdd25

File tree

116 files changed

+9868
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+9868
-0
lines changed

.clang-format

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file is used by clang-format to autoformat paddle source code
2+
#
3+
# The clang-format is part of llvm toolchain.
4+
# It need to install llvm and clang to format source code style.
5+
#
6+
# The basic usage is,
7+
# clang-format -i -style=file PATH/TO/SOURCE/CODE
8+
#
9+
# The -style=file implicit use ".clang-format" file located in one of
10+
# parent directory.
11+
# The -i means inplace change.
12+
#
13+
# The document of clang-format is
14+
# http://clang.llvm.org/docs/ClangFormat.html
15+
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
16+
---
17+
Language: Cpp
18+
BasedOnStyle: Google
19+
IndentWidth: 2
20+
TabWidth: 2
21+
ContinuationIndentWidth: 4
22+
MaxEmptyLinesToKeep: 2
23+
AccessModifierOffset: -2 # The private/protected/public has no indent in class
24+
Standard: Cpp11
25+
AllowAllParametersOfDeclarationOnNextLine: true
26+
BinPackParameters: false
27+
BinPackArguments: false
28+
...
29+

.clang_format.hook

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
readonly VERSION="3.9"
5+
6+
version=$(clang-format -version)
7+
8+
if ! [[ $version == *"$VERSION"* ]]; then
9+
echo "clang-format version check failed."
10+
echo "a version contains '$VERSION' is needed, but get '$version'"
11+
echo "you can install the right version, and make an soft-link to '\$PATH' env"
12+
exit -1
13+
fi
14+
15+
clang-format $@

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
*.pyc

.pre-commit-config.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
- repo: https://github.com/pre-commit/mirrors-yapf.git
2+
sha: v0.16.0
3+
hooks:
4+
- id: yapf
5+
files: \.py$
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
sha: a11d9314b22d8f8c7556443875b731ef05965464
8+
hooks:
9+
- id: check-merge-conflict
10+
- id: check-symlinks
11+
- id: detect-private-key
12+
files: (?!.*paddle)^.*$
13+
- id: end-of-file-fixer
14+
files: \.md$
15+
- id: trailing-whitespace
16+
files: \.md$
17+
- repo: https://github.com/Lucas-C/pre-commit-hooks
18+
sha: v1.0.1
19+
hooks:
20+
- id: forbid-crlf
21+
files: \.md$
22+
- id: remove-crlf
23+
files: \.md$
24+
- id: forbid-tabs
25+
files: \.md$
26+
- id: remove-tabs
27+
files: \.md$
28+
- repo: local
29+
hooks:
30+
- id: clang-format
31+
name: clang-format
32+
description: Format files with ClangFormat
33+
entry: bash .clang_format.hook -i
34+
language: system
35+
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$

.style.yapf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[style]
2+
based_on_style = pep8
3+
column_limit = 80

.travis.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
language: cpp
2+
cache: ccache
3+
sudo: required
4+
dist: trusty
5+
services:
6+
- docker
7+
os:
8+
- linux
9+
env:
10+
- JOB=PRE_COMMIT
11+
12+
addons:
13+
apt:
14+
packages:
15+
- git
16+
- python
17+
- python-pip
18+
- python2.7-dev
19+
20+
before_install:
21+
- sudo pip install -U virtualenv pre-commit pip
22+
- docker pull paddlepaddle/paddle:latest
23+
24+
script:
25+
- exit_code=0
26+
- .travis/precommit.sh || exit_code=$(( exit_code | $? ))
27+
- docker run -i --rm -v "$PWD:/py_unittest" paddlepaddle/paddle:latest /bin/bash -c
28+
'cd /py_unittest; sh .travis/unittest.sh' || exit_code=$(( exit_code | $? ))
29+
exit $exit_code
30+
31+
notifications:
32+
email:
33+
on_success: change
34+
on_failure: always

.travis/precommit.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
function abort(){
3+
echo "Your commit not fit PaddlePaddle code style" 1>&2
4+
echo "Please use pre-commit scripts to auto-format your code" 1>&2
5+
exit 1
6+
}
7+
8+
trap 'abort' 0
9+
set -e
10+
cd `dirname $0`
11+
cd ..
12+
export PATH=/usr/bin:$PATH
13+
pre-commit install
14+
15+
if ! pre-commit run -a ; then
16+
ls -lh
17+
git diff --exit-code
18+
exit 1
19+
fi
20+
21+
trap : 0

.travis/unittest.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
abort(){
4+
echo "Run unittest failed" 1>&2
5+
echo "Please check your code" 1>&2
6+
exit 1
7+
}
8+
9+
unittest(){
10+
cd $1 > /dev/null
11+
if [ -f "setup.sh" ]; then
12+
sh setup.sh
13+
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
14+
fi
15+
if [ $? != 0 ]; then
16+
exit 1
17+
fi
18+
find . -name 'tests' -type d -print0 | \
19+
xargs -0 -I{} -n1 bash -c \
20+
'python -m unittest discover -v -s {}'
21+
cd - > /dev/null
22+
}
23+
24+
trap 'abort' 0
25+
set -e
26+
27+
unittest .
28+
29+
trap : 0

0 commit comments

Comments
 (0)