From 2a5a8e79e5e01c99670cd647d7083ea00cbaf0ec Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Mon, 12 Dec 2016 14:15:46 +0800 Subject: [PATCH] Fix Travis-CI when using rebase. * The $TRAVIS_COMMIT_RANGE could be not existed, because the git history can be changed and rebased. Here we alway run Travis-CI when `git diff` cannot return the modified files. * Also do not push docs update if is not PaddlePaddle/Paddle. --- .travis.yml | 11 +++++++---- paddle/scripts/travis/docs.sh | 31 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6215060e33..145d22c308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,10 +42,13 @@ addons: before_install: - | if [ ${JOB} == "BUILD_AND_TEST" ]; then - if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(\.rst$)|(\.jpg$)|(\.png$)' - then - echo "Only markdown docs were updated, stopping build process." - exit + local change_list=`git diff --name-only $TRAVIS_COMMIT_RANGE` + if [ $? -eq 0 ]; then # if git diff return no zero, then rerun unit test. + if ! echo ${change_list} | grep -qvE '(\.md$)|(\.rst$)|(\.jpg$)|(\.png$)' + then + echo "Only markdown docs were updated, stopping build process." + exit + fi fi fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi diff --git a/paddle/scripts/travis/docs.sh b/paddle/scripts/travis/docs.sh index c2a4809d75..0bbb76a8a3 100755 --- a/paddle/scripts/travis/docs.sh +++ b/paddle/scripts/travis/docs.sh @@ -47,17 +47,20 @@ if [ $? -eq 0 ]; then 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 +if [ -n $SSL_KEY ]; then # Only push updated docs for github.com/PaddlePaddle/Paddle. + # 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 + +fi -- GitLab