2017-05-25 22:37:24 +02:00
|
|
|
#!/bin/bash
|
2016-01-08 15:42:23 -08:00
|
|
|
|
2017-07-10 20:38:09 +02:00
|
|
|
# Script that runs in the testing build stage of Travis and is responsible for testing
|
|
|
|
|
# the project in different Travis jobs of the current build stage.
|
|
|
|
|
|
2017-06-29 19:32:00 +02:00
|
|
|
# The script should immediately exit if any command in the script fails.
|
2017-05-25 22:37:24 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Building sources and running tests. Running mode: ${MODE}"
|
|
|
|
|
echo ""
|
2016-01-08 15:42:23 -08:00
|
|
|
|
|
|
|
|
# Go to project dir
|
2016-01-29 14:01:19 -08:00
|
|
|
cd $(dirname $0)/../..
|
2016-01-08 15:42:23 -08:00
|
|
|
|
2016-01-29 14:01:19 -08:00
|
|
|
# Include sources.
|
|
|
|
|
source scripts/ci/sources/mode.sh
|
|
|
|
|
source scripts/ci/sources/tunnel.sh
|
2016-01-14 11:29:50 -08:00
|
|
|
|
2017-05-23 13:54:55 -07:00
|
|
|
# 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
|
|
|
|
|
|
2016-01-14 11:29:50 -08:00
|
|
|
start_tunnel
|
2016-01-29 14:01:19 -08:00
|
|
|
wait_for_tunnel
|
2017-03-09 03:09:57 +01:00
|
|
|
|
2016-04-03 14:23:17 -07:00
|
|
|
if is_lint; then
|
2016-08-19 10:59:45 -07:00
|
|
|
$(npm bin)/gulp ci:lint
|
2016-04-03 14:23:17 -07:00
|
|
|
elif is_e2e; then
|
2016-08-19 10:59:45 -07:00
|
|
|
$(npm bin)/gulp ci:e2e
|
2017-01-03 18:27:24 +01:00
|
|
|
elif is_aot; then
|
|
|
|
|
$(npm bin)/gulp ci:aot
|
2017-01-03 22:31:49 +01:00
|
|
|
elif is_payload; then
|
|
|
|
|
$(npm bin)/gulp ci:payload
|
2017-03-29 20:13:19 +02:00
|
|
|
elif is_closure_compiler; then
|
|
|
|
|
./scripts/closure-compiler/build-devapp-bundle.sh
|
2017-05-23 13:54:55 -07:00
|
|
|
elif is_unit; then
|
2016-08-19 10:59:45 -07:00
|
|
|
$(npm bin)/gulp ci:test
|
2017-05-25 16:51:11 -07:00
|
|
|
elif is_prerender; then
|
2017-05-30 18:22:18 +02:00
|
|
|
$(npm bin)/gulp ci:prerender
|
2016-01-29 14:01:19 -08:00
|
|
|
fi
|
2017-03-09 03:09:57 +01:00
|
|
|
|
2017-03-10 19:41:49 +01:00
|
|
|
# Upload coverage results if those are present.
|
|
|
|
|
if [ -f dist/coverage/coverage-summary.json ]; then
|
2017-03-09 03:09:57 +01:00
|
|
|
$(npm bin)/gulp ci:coverage
|
|
|
|
|
fi
|
|
|
|
|
|
2016-01-14 11:29:50 -08:00
|
|
|
teardown_tunnel
|