diff --git a/.travis.yml b/.travis.yml index a78853e15b15825354ffbc6e1ca8ffb10c5257c6..d3dae9efd416bd92dde9b327424544da401f2025 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: cpp cache: ccache sudo: required dist: trusty +env: + - JOB=DOCS + - JOB=BUILD_AND_TEST addons: apt: packages: @@ -16,6 +19,7 @@ addons: - python2.7-dev - m4 - libprotobuf-dev + - doxygen - protobuf-compiler - python-protobuf - python-numpy @@ -24,12 +28,10 @@ addons: - libgflags-dev - libgtest-dev before_install: - - pip install wheel protobuf + - pip install wheel protobuf sphinx breathe recommonmark - sudo paddle/scripts/travis/before_install.sh script: - - paddle/scripts/travis/build.sh - - paddle/scripts/travis/unittest.sh - - paddle/scripts/travis/make_install.sh + - paddle/scripts/travis/main.sh notifications: email: on_success: change diff --git a/paddle/scripts/travis/build.sh b/paddle/scripts/travis/build_and_test.sh similarity index 60% rename from paddle/scripts/travis/build.sh rename to paddle/scripts/travis/build_and_test.sh index a644f2a4164f870dc88af9b8f357f5a3fb306d7d..3ea633be327027cc2093ad3a68158af1cfb097e7 100755 --- a/paddle/scripts/travis/build.sh +++ b/paddle/scripts/travis/build_and_test.sh @@ -1,5 +1,7 @@ #!/bin/bash -cd `dirname $0` source ./common.sh cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_GPU=OFF -DWITH_DOC=OFF -DWITH_TESTING=ON -DON_TRAVIS=ON make -j `nproc` +env CTEST_OUTPUT_ON_FAILURE=1 make test ARGS="-j `nproc`" +sudo make install +sudo paddle version diff --git a/paddle/scripts/travis/deploy_key.enc b/paddle/scripts/travis/deploy_key.enc new file mode 100644 index 0000000000000000000000000000000000000000..b0aa45c5ac626c735735fd8541a43bf8b099d0a0 Binary files /dev/null and b/paddle/scripts/travis/deploy_key.enc differ diff --git a/paddle/scripts/travis/docs.sh b/paddle/scripts/travis/docs.sh new file mode 100755 index 0000000000000000000000000000000000000000..c2a4809d75b97a9d8d8b83cf197e90bd62b48603 --- /dev/null +++ b/paddle/scripts/travis/docs.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Add set -e, cd to directory. +source ./common.sh + +# Compile Documentation only. +cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_GPU=OFF -DWITH_DOC=ON +make paddle_docs paddle_docs_cn + +# Parse Github URL +REPO=`git config remote.origin.url` +SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} +SHA=`git rev-parse --verify HEAD` + +# Documentation branch name +# gh-pages branch is used for PaddlePaddle.org. The English version of +# documentation in `doc` directory, and the chinese version in `doc_cn` +# directory. +TARGET_BRANCH="gh-pages" + +# Only deploy master branch to build latest documentation. +SOURCE_BRANCH="master" + +# If is not a Github pull request, and in master branch. +if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then + exit 0 +fi + +# Clone the repo to output directory +git clone $REPO output +cd output + +# checkout github page branch +git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH + +# remove old docs. mv new docs. +rm -rf doc doc_cn +mv ../doc_cn/html doc_cn +mv ../doc/html doc + +# Check is there anything changed. +set +e +git diff --exit-code >/dev/null +if [ $? -eq 0 ]; then + echo "No changes to the output on this push; exiting." + exit 0 +fi +set -e + +# Commit +git add . +git config user.name "Travis CI" +git config user.email "paddle-dev@baidu.com" +git commit -m "Deploy to GitHub Pages: ${SHA}" + +# Set ssh private key +openssl aes-256-cbc -K $SSL_KEY -iv $SSL_IV -in ../../paddle/scripts/travis/deploy_key.enc -out deploy_key -d +chmod 600 deploy_key +eval `ssh-agent -s` +ssh-add deploy_key + +# Push +git push $SSH_REPO $TARGET_BRANCH diff --git a/paddle/scripts/travis/main.sh b/paddle/scripts/travis/main.sh new file mode 100755 index 0000000000000000000000000000000000000000..c49d4546c24ac9304cd6f3c5940ed3d1d32ebb3d --- /dev/null +++ b/paddle/scripts/travis/main.sh @@ -0,0 +1,11 @@ +#!/bin/bash +cd `dirname $0` + +if [ ${JOB} == "BUILD_AND_TEST" ]; then + ./build_and_test.sh +elif [ ${JOB} == "DOCS" ]; then + ./docs.sh +else + echo Unknown job ${JOB} + exit 1 +fi diff --git a/paddle/scripts/travis/make_install.sh b/paddle/scripts/travis/make_install.sh deleted file mode 100755 index 08b2a648bb97de2c4f39c64efb9a41829faae0be..0000000000000000000000000000000000000000 --- a/paddle/scripts/travis/make_install.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -cd `dirname $0` -source ./common.sh -sudo make install -sudo paddle version diff --git a/paddle/scripts/travis/unittest.sh b/paddle/scripts/travis/unittest.sh deleted file mode 100755 index 45e8c85c1028efb98433ebc383931def30fae416..0000000000000000000000000000000000000000 --- a/paddle/scripts/travis/unittest.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -cd `dirname $0` -source ./common.sh -env CTEST_OUTPUT_ON_FAILURE=1 make test ARGS="-j `nproc`" -