mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: remove inactive browserstack wrapper package (#1991)
* chore: remove inactive browserstack wrapper package No longer uses the "inactive" browserstack wrapper package from npm, which was just responsible for creating the readyfile. We can create the readyfile ourself and get rid of the npm package. * Fix incorrect comments * Don't wait for tunnel if timer exceeded * Fix race conditions * Add empty line before logging that the tunnel is ready.
This commit is contained in:
committed by
tinayuangao
parent
26eb7ceb1e
commit
6534eb0a73
@@ -24,6 +24,7 @@ env:
|
||||
- BROWSER_STACK_ACCESS_KEY=BWCd4SynLzdDcv8xtzsB
|
||||
- ARCH=linux-x64
|
||||
- BROWSER_PROVIDER_READY_FILE=/tmp/angular-material2-build/readyfile
|
||||
- BROWSER_PROVIDER_ERROR_FILE=/tmp/angular-material2-build/errorfile
|
||||
# GITHUB_TOKEN_ANGULAR
|
||||
- secure: "fq/U7VDMWO8O8SnAQkdbkoSe2X92PVqg4d044HmRYVmcf6YbO48+xeGJ8yOk0pCBwl3ISO4Q2ot0x546kxfiYBuHkZetlngZxZCtQiFT9kyId8ZKcYdXaIW9OVdw3Gh3tQyUwDucfkVhqcs52D6NZjyE2aWZ4/d1V4kWRO/LMgo="
|
||||
matrix:
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
"@types/node": "^6.0.34",
|
||||
"@types/run-sequence": "0.0.27",
|
||||
"@types/rx": "^2.5.33",
|
||||
"browserstacktunnel-wrapper": "^2.0.0",
|
||||
"conventional-changelog": "^1.1.0",
|
||||
"express": "^4.14.0",
|
||||
"firebase-tools": "^2.2.1",
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
/**
|
||||
* Start the BrowserStack tunnel. Once its started it creates a file so the callee can wait
|
||||
* for the tunnel to be started.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var http = require('http');
|
||||
var BrowserStackTunnel = require('browserstacktunnel-wrapper');
|
||||
|
||||
var HOSTNAME = 'localhost';
|
||||
var PORTS = [9876, 9877];
|
||||
var ACCESS_KEY = process.env.BROWSER_STACK_ACCESS_KEY;
|
||||
var READY_FILE = process.env.BROWSER_PROVIDER_READY_FILE;
|
||||
var TUNNEL_IDENTIFIER = process.env.TRAVIS_JOB_NUMBER;
|
||||
|
||||
// We need to start fake servers, otherwise the tunnel does not start.
|
||||
var fakeServers = [];
|
||||
var hosts = [];
|
||||
|
||||
PORTS.forEach(function(port) {
|
||||
fakeServers.push(http.createServer(function() {}).listen(port));
|
||||
hosts.push({
|
||||
name: HOSTNAME,
|
||||
port: port,
|
||||
sslFlag: 0
|
||||
});
|
||||
});
|
||||
|
||||
var tunnel = new BrowserStackTunnel({
|
||||
key: ACCESS_KEY,
|
||||
localIdentifier: TUNNEL_IDENTIFIER,
|
||||
hosts: hosts
|
||||
});
|
||||
|
||||
console.log('Starting tunnel on ports', PORTS.join(', '));
|
||||
|
||||
// Emit a `newer_available` event to force an update of the Browserstack binaries (necessary due to Travis caching)
|
||||
// This also starts a new tunnel after the latest binaries are available.
|
||||
tunnel.emit('newer_available');
|
||||
|
||||
tunnel.once('started', function(error) {
|
||||
if (error) {
|
||||
console.error('Can not establish the tunnel', error);
|
||||
} else {
|
||||
console.log('Tunnel established.');
|
||||
fakeServers.forEach(function(server) {
|
||||
server.close();
|
||||
});
|
||||
|
||||
if (READY_FILE) {
|
||||
fs.writeFile(READY_FILE, process.pid);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tunnel.on('error', function(error) {
|
||||
console.error(error);
|
||||
});
|
||||
@@ -1,3 +1,72 @@
|
||||
export BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`
|
||||
#!/bin/bash
|
||||
|
||||
node ./scripts/browserstack/start_tunnel.js &
|
||||
set -e -o pipefail
|
||||
|
||||
# Workaround for Travis CI cookbook https://github.com/travis-ci/travis-ci/issues/4862,
|
||||
# where $PATH will be extended with relative paths to the NPM binaries.
|
||||
PATH=`echo $PATH | sed -e 's/:\.\/node_modules\/\.bin//'`
|
||||
|
||||
TUNNEL_FILE="BrowserStackLocal-linux-x64.zip"
|
||||
TUNNEL_URL="https://www.browserstack.com/browserstack-local/$TUNNEL_FILE"
|
||||
TUNNEL_DIR="/tmp/browserstack-tunnel"
|
||||
TUNNEL_LOG="$LOGS_DIR/browserstack-tunnel.log"
|
||||
|
||||
BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`
|
||||
|
||||
# Cleanup and create the folder structure for the tunnel connector.
|
||||
rm -rf $TUNNEL_DIR $BROWSER_PROVIDER_READY_FILE
|
||||
mkdir -p $TUNNEL_DIR
|
||||
touch $TUNNEL_LOG
|
||||
|
||||
cd $TUNNEL_DIR
|
||||
|
||||
# Download the browserstack local binaries.
|
||||
curl $TUNNEL_URL -o $TUNNEL_FILE 2> /dev/null 1> /dev/null
|
||||
|
||||
# Extract the browserstack local binaries from the tarball.
|
||||
mkdir -p browserstack-tunnel
|
||||
unzip -q $TUNNEL_FILE -d browserstack-tunnel
|
||||
|
||||
# Cleanup the download directory.
|
||||
rm $TUNNEL_FILE
|
||||
|
||||
ARGS=""
|
||||
|
||||
# Set tunnel-id only on Travis, to make local testing easier.
|
||||
if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then
|
||||
ARGS="$ARGS --local-identifier $TRAVIS_JOB_NUMBER"
|
||||
fi
|
||||
|
||||
echo "Starting Browserstack Local in the background, logging into:"
|
||||
echo " $TUNNEL_LOG"
|
||||
echo " ---"
|
||||
echo " $ARGS"
|
||||
|
||||
# Extension to the BrowserStackLocal binaries, because those can't create a readyfile.
|
||||
function create_ready_file {
|
||||
|
||||
# To be able to exit the tail properly we need to have a sub shell spawned, which is
|
||||
# used to track the state of tail.
|
||||
{ sleep 120; touch $BROWSER_PROVIDER_ERROR_FILE; } &
|
||||
|
||||
TIMER_PID=$!
|
||||
|
||||
# Disown the background process, because we don't want to show any messages when killing
|
||||
# the timer.
|
||||
disown
|
||||
|
||||
# When the tail recognizes the `Ctrl-C` log message the BrowserStack Tunnel is up.
|
||||
{
|
||||
tail -n0 -f $TUNNEL_LOG --pid $TIMER_PID | { sed '/Ctrl/q' && kill -9 $TIMER_PID; };
|
||||
} &> /dev/null
|
||||
|
||||
echo
|
||||
echo "BrowserStack Tunnel ready"
|
||||
|
||||
touch $BROWSER_PROVIDER_READY_FILE
|
||||
}
|
||||
|
||||
browserstack-tunnel/BrowserStackLocal -k $BROWSER_STACK_ACCESS_KEY $ARGS &>> $TUNNEL_LOG &
|
||||
|
||||
# Wait for the tunnel to be ready and create the readyfile with the Browserstack PID
|
||||
create_ready_file &
|
||||
|
||||
@@ -5,13 +5,9 @@ set -e -o pipefail
|
||||
|
||||
echo "Shutting down Browserstack tunnel"
|
||||
|
||||
PID=$(cat $BROWSER_PROVIDER_READY_FILE);
|
||||
killall BrowserStackLocal
|
||||
|
||||
# Resolving the PID from the readyfile.
|
||||
kill $PID
|
||||
|
||||
|
||||
while [[ -n `ps -ef | grep $PID | grep -v "grep"` ]]; do
|
||||
while [[ -n `ps -ef | grep "BrowserStackLocal" | grep -v "grep"` ]]; do
|
||||
printf "."
|
||||
sleep .5
|
||||
done
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
TUNNEL_LOG="$LOGS_DIR/browserstack-tunnel.log"
|
||||
|
||||
# Wait for Connect to be ready before exiting
|
||||
# Time out if we wait for more than 2 minutes, so the process won't run forever.
|
||||
let "counter=0"
|
||||
|
||||
# Exit the process if there are errors reported. Print the tunnel log to the console.
|
||||
if [ -f $BROWSER_PROVIDER_ERROR_FILE ]; then
|
||||
echo
|
||||
echo "An error occurred while starting the tunnel. See error:"
|
||||
cat $TUNNEL_LOG
|
||||
exit 5
|
||||
fi
|
||||
|
||||
while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do
|
||||
let "counter++"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user