Skip to content

Commit aee42ae

Browse files
choucleetinayuangao
authored andcommitted
build(ci): skip tests on CI when only markdown files have changed (#4452)
Skip e2e and unit tests for Push/PR build
1 parent 13524c1 commit aee42ae

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

scripts/ci/build-and-test.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ cd $(dirname $0)/../..
1010
source scripts/ci/sources/mode.sh
1111
source scripts/ci/sources/tunnel.sh
1212

13+
# Get commit diff
14+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
15+
fileDiff=$(git diff --name-only $TRAVIS_COMMIT_RANGE)
16+
else
17+
fileDiff=$(git diff --name-only $TRAVIS_BRANCH...HEAD)
18+
fi
19+
20+
# Check if tests can be skipped
21+
if [[ ${fileDiff} =~ ^(.*\.md\s*)*$ ]] && (is_e2e || is_unit); then
22+
echo "Skipping e2e and unit tests since only markdown files changed"
23+
exit 0
24+
fi
25+
1326
start_tunnel
1427
wait_for_tunnel
1528

@@ -23,7 +36,7 @@ elif is_payload; then
2336
$(npm bin)/gulp ci:payload
2437
elif is_closure_compiler; then
2538
./scripts/closure-compiler/build-devapp-bundle.sh
26-
else
39+
elif is_unit; then
2740
$(npm bin)/gulp ci:test
2841
fi
2942

scripts/ci/sources/mode.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ is_closure_compiler() {
1919

2020
is_payload() {
2121
[[ "$MODE" = payload ]]
22-
}
22+
}
23+
24+
is_unit() {
25+
[[ "$MODE" = saucelabs_required || "$MODE" = browserstack_required ]]
26+
}

0 commit comments

Comments
 (0)