2023-02-20 20:37:34 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {customLaunchers} from '../../../browser-providers.conf';
|
|
|
|
|
import {Browser} from '../browser';
|
|
|
|
|
|
|
|
|
|
import {SaucelabsDaemon} from './saucelabs-daemon';
|
|
|
|
|
|
|
|
|
|
const args = process.argv.slice(2);
|
2023-09-11 11:21:09 +00:00
|
|
|
const username = process.env['SAUCE_USERNAME'];
|
|
|
|
|
const accessKey = process.env['SAUCE_ACCESS_KEY'];
|
|
|
|
|
const tunnelIdentifier = process.env['SAUCE_TUNNEL_IDENTIFIER'];
|
2023-02-20 20:37:34 +00:00
|
|
|
|
|
|
|
|
if (!username || !accessKey) {
|
|
|
|
|
throw Error('Please set the `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` variables.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!tunnelIdentifier) {
|
|
|
|
|
throw Error('No tunnel set up. Please set the `SAUCE_TUNNEL_IDENTIFIER` variable.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// First argument is the path to the sauce connect binary. This argument is templated into the bazel
|
|
|
|
|
// binary.
|
|
|
|
|
if (args.length < 1) {
|
|
|
|
|
throw Error(`Path to the sauce connect binary expected as first argument`);
|
|
|
|
|
}
|
|
|
|
|
const sauceConnect = args[0];
|
|
|
|
|
|
|
|
|
|
// Second argument is the number of parallel browsers to start. This argument is user supplied and
|
|
|
|
|
// required.
|
|
|
|
|
if (args.length != 2) {
|
|
|
|
|
throw Error(`Please specify the number of parallel browsers to start on the command line.`);
|
|
|
|
|
}
|
|
|
|
|
const parallelExecutions = parseInt(args[1]);
|
|
|
|
|
if (!parallelExecutions) {
|
|
|
|
|
throw Error(`Please specify a non-zero number of parallel browsers to start.`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start the daemon and launch the given browser
|
|
|
|
|
const daemon = new SaucelabsDaemon(
|
2024-01-16 21:51:06 +00:00
|
|
|
username,
|
|
|
|
|
accessKey,
|
|
|
|
|
process.env['CIRCLE_BUILD_NUM']!,
|
|
|
|
|
Object.values(customLaunchers) as Browser[],
|
|
|
|
|
parallelExecutions,
|
|
|
|
|
sauceConnect,
|
|
|
|
|
{tunnelIdentifier},
|
2023-02-20 20:37:34 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (args.includes('--connect')) {
|
2023-05-07 21:42:01 +00:00
|
|
|
daemon.connectTunnel().catch((err) => {
|
2023-02-20 20:37:34 +00:00
|
|
|
console.error(`Failed to connect to Saucelabs: ${err}`);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
}
|