From aee42aebb71f0c6e96becec14d4f2c46267b99b6 Mon Sep 17 00:00:00 2001 From: Zhoucheng Li Date: Tue, 23 May 2017 13:54:55 -0700 Subject: [PATCH] build(ci): skip tests on CI when only markdown files have changed (#4452) Skip e2e and unit tests for Push/PR build --- scripts/ci/build-and-test.sh | 15 ++++++++++++++- scripts/ci/sources/mode.sh | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/ci/build-and-test.sh b/scripts/ci/build-and-test.sh index 7f4cfff8b5d..e5f343c4270 100755 --- a/scripts/ci/build-and-test.sh +++ b/scripts/ci/build-and-test.sh @@ -10,6 +10,19 @@ cd $(dirname $0)/../.. source scripts/ci/sources/mode.sh source scripts/ci/sources/tunnel.sh +# Get commit diff +if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then + fileDiff=$(git diff --name-only $TRAVIS_COMMIT_RANGE) +else + fileDiff=$(git diff --name-only $TRAVIS_BRANCH...HEAD) +fi + +# Check if tests can be skipped +if [[ ${fileDiff} =~ ^(.*\.md\s*)*$ ]] && (is_e2e || is_unit); then + echo "Skipping e2e and unit tests since only markdown files changed" + exit 0 +fi + start_tunnel wait_for_tunnel @@ -23,7 +36,7 @@ elif is_payload; then $(npm bin)/gulp ci:payload elif is_closure_compiler; then ./scripts/closure-compiler/build-devapp-bundle.sh -else +elif is_unit; then $(npm bin)/gulp ci:test fi diff --git a/scripts/ci/sources/mode.sh b/scripts/ci/sources/mode.sh index 90987771825..d37725919d9 100644 --- a/scripts/ci/sources/mode.sh +++ b/scripts/ci/sources/mode.sh @@ -19,4 +19,8 @@ is_closure_compiler() { is_payload() { [[ "$MODE" = payload ]] -} \ No newline at end of file +} + +is_unit() { + [[ "$MODE" = saucelabs_required || "$MODE" = browserstack_required ]] +}