From 80102c56cf4ba35e181d9dd1c38c5cfc3310e025 Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Fri, 10 Apr 2015 19:07:56 -0700 Subject: [PATCH] Add end-to-end test --- .travis.yml | 4 +++ scripts/.gitignore | 1 + scripts/e2e-npmrc | 5 ++++ scripts/e2e-sinopia.config.yml | 21 +++++++++++++++ scripts/e2e-test.sh | 47 ++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 scripts/.gitignore create mode 100644 scripts/e2e-npmrc create mode 100644 scripts/e2e-sinopia.config.yml create mode 100755 scripts/e2e-test.sh diff --git a/.travis.yml b/.travis.yml index ff8ce5428..819314fa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,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 +60,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/.gitignore b/scripts/.gitignore new file mode 100644 index 000000000..de3a58987 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +.published-packages 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..71c69e798 --- /dev/null +++ b/scripts/e2e-sinopia.config.yml @@ -0,0 +1,21 @@ +storage: .published-packages + +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..512c73c86 --- /dev/null +++ b/scripts/e2e-test.sh @@ -0,0 +1,47 @@ +#!/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 { + kill -9 $SINOPIA_PID + mv ~/.npmrc.bak ~/.npmrc + rm $MARKER +} +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 + +[ -d $SCRIPTS/.published-packages ] && rm -r $SCRIPTS/.published-packages +sinopia --config $SCRIPTS/e2e-sinopia.config.yml & +SINOPIA_PID=$! + +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 iphonesimulator8.2 test