feat(): Dartanalyzer running on travis.

This commit is contained in:
Hans Larsen
2016-01-29 14:01:19 -08:00
parent f167934875
commit 3a1d518df0
25 changed files with 905 additions and 290 deletions
+12
View File
@@ -0,0 +1,12 @@
# Continuous Integration Scripts
This directory contains scripts that are related to CI only.
### `build-and-test.sh`
The main script. Setup the tests environment, build the files using the `angular-cli` tool and run the tests.
### `install_dart.sh`
Only run in Dart environments. Install Dart locally on the CI.
+15 -45
View File
@@ -1,57 +1,27 @@
#!/usr/bin/env bash
set -ex
echo "======= Starting build-and-test.sh ========================================"
# Go to project dir
SCRIPT_DIR=$(dirname $0)
cd ${SCRIPT_DIR}/../..
cd $(dirname $0)/../..
# Include sources.
source scripts/ci/sources/mode.sh
source scripts/ci/sources/tunnel.sh
start_tunnel() {
case "$MODE" in
saucelabs*)
./scripts/sauce/sauce_connect_setup.sh
;;
browserstack*)
./scripts/browserstack/start_tunnel.sh
;;
*)
;;
esac
}
wait_for_tunnel() {
case "$MODE" in
saucelabs*)
./scripts/sauce/sauce_connect_block.sh
;;
browserstack*)
./scripts/browserstack/waitfor_tunnel.sh
;;
*)
;;
esac
sleep 10
}
teardown_tunnel() {
case "$MODE" in
saucelabs*)
./scripts/sauce/sauce_connect_teardown.sh
;;
browserstack*)
# ./scripts/browserstack/teardown_tunnel.sh
;;
*)
;;
esac
}
# Setup environment.
is_dart && source scripts/ci/sources/env_dart.sh
start_tunnel
wait_for_tunnel
npm run build
karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots'
is_dart && pub install
wait_for_tunnel
if is_dart; then
# npm run dartanalyzer
echo 'TODO(hans): Implement dartanalyzer'
else
karma start test/karma.conf.js --single-run --no-auto-watch --reporters='dots'
fi
teardown_tunnel
+12
View File
@@ -0,0 +1,12 @@
import {analyze} from '../../tools/build/dart_analyzer';
import {detect} from '../../tools/build/dart';
const command = detect()['ANALYZER'];
analyze('dist/dart', command, true)
.then(() => {
console.log('Done.');
}, (err) => {
console.error('Error:', err);
});
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
set -e -x
if [ -z "${DART_CHANNEL}" -o -z "${DART_VERSION}" -o -z "${ARCH}" ]; then
echo "No Dart necessary. Not installing."
exit 0
fi
AVAILABLE_DART_VERSION=$(curl "https://storage.googleapis.com/dart-archive/channels/${DART_CHANNEL}/release/${DART_VERSION}/VERSION" | python -c \
'import sys, json; print(json.loads(sys.stdin.read())["version"])')
echo Fetch Dart channel: ${DART_CHANNEL}
URL_PREFIX=https://storage.googleapis.com/dart-archive/channels/${DART_CHANNEL}/release/${DART_VERSION}
DART_SDK_URL="$URL_PREFIX/sdk/dartsdk-$ARCH-release.zip"
DARTIUM_URL="$URL_PREFIX/dartium/dartium-$ARCH-release.zip"
download_and_unzip() {
ZIPFILE=${1/*\//}
curl -O -L $1 && unzip -q $ZIPFILE && rm $ZIPFILE
}
# TODO: do these downloads in parallel
download_and_unzip $DART_SDK_URL
download_and_unzip $DARTIUM_URL
echo Fetched new dart version $(<dart-sdk/version)
if [[ -n $DARTIUM_URL ]]; then
mv dartium-* chromium
fi
+95
View File
@@ -0,0 +1,95 @@
#!/bin/bash
set -e -o pipefail
if [[ -z $ENV_SET ]]; then
export ENV_SET=1
unset DART
PLATFORM="$(uname -s)"
case "$PLATFORM" in
(Darwin)
path=$(readlink ${BASH_SOURCE[0]}||echo './scripts/env.sh')
export NGDART_SCRIPT_DIR=$(dirname $path)
;;
(Linux)
export NGDART_SCRIPT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
;;
(*)
echo Unsupported platform $PLATFORM. Exiting ... >&2
exit 3
;;
esac
export NGDART_BASE_DIR=$(dirname $NGDART_SCRIPT_DIR)
# Try to find the SDK alongside the dart command first.
if [[ -z "$DART_SDK" ]]; then
DART=$(which dart) || true
if [[ -x "$DART" ]]; then
DART_SDK="${DART/dart-sdk\/*/dart-sdk}"
if [[ ! -e "$DART_SDK" ]]; then
unset DART DART_SDK
fi
fi
fi
# Fallback: Assume it's alongside the current directory (e.g. Travis).
if [[ -z "$DART_SDK" ]]; then
DART_SDK="$(pwd)/dart-sdk"
fi
: "${DART:=$DART_SDK/bin/dart}"
if [[ ! -x "$DART" ]]; then
echo Unable to locate the dart binary / SDK. Exiting >&2
exit 3
fi
if [[ -z "$DARTIUM" ]]; then
dartiumRoot="$DART_SDK/../chromium"
if [[ -e "$dartiumRoot" ]]; then
case "$PLATFORM" in
(Linux) export DARTIUM="$dartiumRoot/chrome" ;;
(Darwin) export DARTIUM="$dartiumRoot/Chromium.app/Contents/MacOS/Chromium" ;;
(*) echo Unsupported platform $PLATFORM. Exiting ... >&2 ; exit 3 ;;
esac
fi
fi
case "$PLATFORM" in
(Linux) export DART_SDK_LIB_SEARCH_PATH="$DART_SDK" ;;
(Darwin) export DART_SDK_LIB_SEARCH_PATH="$DART_SDK/libexec" ;;
(*) echo Unsupported platform $PLATFORM. Exiting ... >&2 ; exit 3 ;;
esac
export DART_SDK
export DARTSDK
export DART
export PUB=${PUB:-"$DART_SDK/bin/pub"}
if [ -z "$PUB_CACHE" ]; then
export PUB_CACHE=$DART_SDK/pub-cache
fi
export DARTANALYZER=${DARTANALYZER:-"$DART_SDK/bin/dartanalyzer"}
export DARTDOC=${DARTDOC:-"$DART_SDK/bin/dartdoc"}
export DART_DOCGEN=${DART_DOCGEN:-"$DART_SDK/bin/docgen"}
export DART_VM_OPTIONS="--old_gen_heap_size=2048"
export DARTIUM_BIN=${DARTIUM_BIN:-"$DARTIUM"}
export CHROME_BIN=${CHROME_BIN:-"google-chrome"}
export PATH=$PATH:$DART_SDK/bin
echo '*********'
echo '** ENV **'
echo '*********'
echo DART_SDK=$DART_SDK
echo DART_SDK_LIB_SEARCH_PATH=$DART_SDK_LIB_SEARCH_PATH
echo DART=$DART
echo PUB=$PUB
echo DARTANALYZER=$DARTANALYZER
echo DARTDOC=$DARTDOC
echo DART_DOCGEN=$DART_DOCGEN
echo DARTIUM_BIN=$DARTIUM_BIN
echo CHROME_BIN=$CHROME_BIN
echo PATH=$PATH
echo NGDART_BASE_DIR=$NGDART_BASE_DIR
echo NGDART_SCRIPT_DIR=$NGDART_SCRIPT_DIR
fi
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
source ./scripts/ci/sources/tunnel.sh
is_dart() {
[[ "$MODE" = dart* ]]
}
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
start_tunnel() {
case "$MODE" in
saucelabs*)
./scripts/sauce/sauce_connect_setup.sh
;;
browserstack*)
./scripts/browserstack/start_tunnel.sh
;;
*)
;;
esac
}
wait_for_tunnel() {
case "$MODE" in
saucelabs*)
./scripts/sauce/sauce_connect_block.sh
;;
browserstack*)
./scripts/browserstack/waitfor_tunnel.sh
;;
*)
;;
esac
sleep 10
}
teardown_tunnel() {
case "$MODE" in
saucelabs*)
./scripts/sauce/sauce_connect_teardown.sh
;;
browserstack*)
# ./scripts/browserstack/teardown_tunnel.sh
;;
*)
;;
esac
}