check_style.sh 749 字节
Newer Older
Y
Yu Yang 已提交
1
#!/bin/bash
Y
Yu Yang 已提交
2
function abort(){
Y
Yi Wang 已提交
3
    echo "Your change doesn't follow PaddlePaddle's code style." 1>&2
H
Helin Wang 已提交
4
    echo "Please use pre-commit to check what is wrong." 1>&2
Y
Yu Yang 已提交
5 6 7 8
    exit 1
}

trap 'abort' 0
Y
Yu Yang 已提交
9
set -e
Y
Yi Wang 已提交
10

11 12 13 14 15 16
# install glide
curl https://glide.sh/get | bash
eval "$(GIMME_GO_VERSION=1.8.3 gimme)"
go get -u github.com/alecthomas/gometalinter
gometalinter --install

Y
Yi Wang 已提交
17
cd $TRAVIS_BUILD_DIR
Y
Yu Yang 已提交
18
export PATH=/usr/bin:$PATH
Y
Yu Yang 已提交
19
pre-commit install
Y
Yu Yang 已提交
20
clang-format --version
21

H
Helin Wang 已提交
22 23 24 25 26
# set up go environment for running gometalinter
mkdir -p $GOPATH/src/github.com/PaddlePaddle/
ln -sf $TRAVIS_BUILD_DIR $GOPATH/src/github.com/PaddlePaddle/Paddle
cd  $GOPATH/src/github.com/PaddlePaddle/Paddle/go; glide install; cd -

27
if ! pre-commit run -a ; then
H
Helin Wang 已提交
28 29
    git diff
    exit 1
30
fi
Y
Yu Yang 已提交
31 32

trap : 0