Skip to content

Commit

Permalink
build(bazel): upgrade benchmarks to protractor_web_test_suite for CI …
Browse files Browse the repository at this point in the history
…without local chrome
  • Loading branch information
gregmagolan committed Nov 7, 2018
1 parent ff2ee64 commit 99732ae
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
6 changes: 2 additions & 4 deletions modules/benchmarks/src/largetable/render3/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
load("//packages/bazel:index.bzl", "protractor_web_test")
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")

ng_module(
Expand Down Expand Up @@ -50,7 +50,7 @@ ts_devserver(
tags = ["ivy-only"],
)

protractor_web_test(
protractor_web_test_suite(
name = "perf",
configuration = "//:protractor-perf.conf.js",
data = [
Expand All @@ -64,8 +64,6 @@ protractor_web_test(
on_prepare = ":protractor.on_prepare.js",
server = ":devserver",
tags = [
"fixme-ivy-aot",
"fixme-ivy-jit",
"ivy-only",
],
deps = [
Expand Down
6 changes: 2 additions & 4 deletions modules/benchmarks/src/tree/render3/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
load("//packages/bazel:index.bzl", "protractor_web_test")
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")

ng_module(
Expand Down Expand Up @@ -48,7 +48,7 @@ ts_devserver(
tags = ["ivy-only"],
)

protractor_web_test(
protractor_web_test_suite(
name = "perf",
configuration = "//:protractor-perf.conf.js",
data = [
Expand All @@ -58,8 +58,6 @@ protractor_web_test(
on_prepare = ":protractor.on_prepare.js",
server = ":devserver",
tags = [
"fixme-ivy-aot",
"fixme-ivy-jit",
"ivy-only",
],
deps = [
Expand Down
39 changes: 32 additions & 7 deletions packages/bazel/src/protractor/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* 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
*/

const path = require('path');

const DEBUG = false;

const configPath = 'TMPL_config';
Expand All @@ -32,15 +29,43 @@ function setConf(conf, name, value, msg) {
conf[name] = value;
}

function mergeCapabilities(conf, capabilities) {
if (conf.capabilities) {
if (conf.capabilities.browserName === capabilities.browserName) {
// there are capabilities to merge
if (capabilities.browserName === 'chrome') {
conf.capabilities.chromeOptions = conf.capabilities.chromeOptions || {};
conf.capabilities.chromeOptions.binary = capabilities.chromeOptions.binary;
conf.capabilities.chromeOptions.args = conf.capabilities.chromeOptions.args || [];
conf.capabilities.chromeOptions.args.push(...capabilities.chromeOptions.args);
console.warn(
`Your protractor configuration specifies capabilities for browser '${conf.capabilities.browserName}'
which will be merged with capabilities provided by Bazel resulting in:`,
JSON.stringify(conf.capabilities, null, 2));
} else {
// TODO(gmagolan): implement firefox support for protractor
throw new Error(
`Unexpected browserName ${capabilities.browserName} for capabilities merging`);
}
} else {
console.warn(
`Your protractor configuration specifies capabilities for browser '${conf.capabilities.browserName}' which will be overwritten by Bazel`);
}
} else {
conf.capabilities = capabilities;
}
}

let conf = {};

// Import the user's base protractor configuration if specified
if (configPath) {
const baseConf = require(configPath);
if (!baseConf.config) {
throw new Error('Invalid base protractor configration. Expected config to be exported.');
throw new Error('Invalid base protractor configuration. Expected config to be exported.');
}
conf = baseConf.config;
if (DEBUG) console.info(`Base protractor configuration: ${JSON.stringify(conf, null, 2)}`);
}

// Import the user's on prepare function if specified
Expand Down Expand Up @@ -109,8 +134,8 @@ if (process.env['WEB_TEST_METADATA']) {
}
setConf(conf, 'directConnect', true, 'is set to true for chrome');
setConf(conf, 'chromeDriver', chromeDriver, 'is determined by the browsers attribute');
setConf(
conf, 'capabilities', {
mergeCapabilities(
conf, {
browserName: 'chrome',
chromeOptions: {
binary: chromeBin,
Expand All @@ -131,7 +156,7 @@ if (process.env['WEB_TEST_METADATA']) {
// }
// setConf(conf, 'seleniumAddress', process.env.WEB_TEST_HTTP_SERVER.trim() + "/wd/hub", 'is
// configured by Bazel for firefox browser')
// setConf(conf, 'capabilities', {
// mergeCapabilities(conf, {
// browserName: "firefox",
// 'moz:firefoxOptions': {
// binary: firefoxBin,
Expand Down

0 comments on commit 99732ae

Please sign in to comment.