diff --git a/.travis.yml b/.travis.yml index ff8ce5428..3bdbcfbf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ before_install: - brew update install: - brew reinstall flow watchman xctool + - npm config set spin=false - npm install script: @@ -47,6 +48,9 @@ script: node server/generate.js fi + elif [ "$TEST_TYPE" = e2e ] + then + ./scripts/e2e-test.sh else echo "Unknown test type: $TEST_TYPE" exit 1 @@ -57,6 +61,7 @@ env: - TEST_TYPE=objc - TEST_TYPE=js - TEST_TYPE=build_website + - TEST_TYPE=e2e global: - secure: "HlmG8M2DmBUSBh6KH1yVIe/8gR4iibg4WfcHq1x/xYQxGbvleq7NOo04V6eFHnl9cvZCu+PKH0841WLnGR7c4BBf47GVu/o16nXzggPumHKy++lDzxFPlJ1faMDfjg/5vjbAxRUe7D3y98hQSeGHH4tedc8LvTaFLVu7iiGqvjU=" diff --git a/scripts/e2e-npmrc b/scripts/e2e-npmrc new file mode 100644 index 000000000..6eb1b2726 --- /dev/null +++ b/scripts/e2e-npmrc @@ -0,0 +1,5 @@ +; travis:travis +_auth=dHJhdmlzOnRyYXZpcw== +email=travis@example.com +spin=false +registry=http://localhost:4873/ diff --git a/scripts/e2e-sinopia.config.yml b/scripts/e2e-sinopia.config.yml new file mode 100644 index 000000000..305e9ba2c --- /dev/null +++ b/scripts/e2e-sinopia.config.yml @@ -0,0 +1,21 @@ +storage: /tmp/sinopia-package-cache + +uplinks: + npmjs: + url: https://registry.npmjs.org/ + +packages: + 'react-native': + allow_access: $all + allow_publish: $all + + 'react-native-cli': + allow_access: $all + allow_publish: $all + + '*': + allow_access: $all + proxy: npmjs + +logs: + - {type: file, path: sinopia.log, format: pretty, level: http} diff --git a/scripts/e2e-test.sh b/scripts/e2e-test.sh new file mode 100755 index 000000000..1a988620e --- /dev/null +++ b/scripts/e2e-test.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Abort the mission if any command fails +set -e + +SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +ROOT=$(dirname $SCRIPTS) +TEMP=$(mktemp -d /tmp/react-native-XXXXXXXX) + +# To make sure we actually installed the local version +# of react-native, we will create a temp file inside SampleApp +# and check that it exists after `react-native init` +MARKER=$(mktemp $ROOT/Examples/SampleApp/XXXXXXXX) + +function cleanup { + rm $MARKER + [ $SINOPIA_PID ] && kill -9 $SINOPIA_PID + [ -f ~/.npmrc.bak ] && mv ~/.npmrc.bak ~/.npmrc +} +trap cleanup EXIT + +cd $TEMP + +# sinopia is npm registry proxy, it is used to make npm +# think react-native and react-native-cli are actually +# published on npm +which sinopia || npm install -g sinopia + +# but in order to make npm use sinopia we temporarily +# replace its config file +[ -f ~/.npmrc ] && cp ~/.npmrc ~/.npmrc.bak +cp $SCRIPTS/e2e-npmrc ~/.npmrc + +sinopia --config $SCRIPTS/e2e-sinopia.config.yml & +SINOPIA_PID=$! + +# Make sure to remove old version of react-native in +# case it was cached +npm unpublish react-native --force +npm unpublish react-native-cli --force +npm publish $ROOT +npm publish $ROOT/react-native-cli + + +npm install -g react-native-cli +react-native init EndToEndTest +cd EndToEndTest + +# Make sure we installed local version of react-native +ls `basename $MARKER` > /dev/null + +xctool -scheme EndToEndTest -sdk iphonesimulator test