Skip to content

Commit f89d9f3

Browse files
gregmagolanmhevery
authored andcommitted
test: saucelab targets for all karma tests (angular#35516)
PR Close angular#35516
1 parent 3400af6 commit f89d9f3

File tree

3 files changed

+71
-120
lines changed

3 files changed

+71
-120
lines changed

.circleci/config.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,6 @@ jobs:
343343
path: dist/bin/packages/core/test/bundling/todo/bundle.min.js.br
344344
destination: core/todo/bundle.br
345345

346-
# This job is currently a PoC for running tests on SauceLabs via bazel. It runs a subset of the
347-
# tests in `legacy-unit-tests-saucelabs` (see
348-
# [BUILD.bazel](https://github.com/angular/angular/blob/ef44f51d5/BUILD.bazel#L66-L92)).
349-
#
350346
# NOTE: This is currently limited to master builds only. See the `default_workflow` configuration.
351347
saucelabs_view_engine:
352348
executor:
@@ -360,16 +356,18 @@ jobs:
360356
- init_environment
361357
- init_saucelabs_environment
362358
- run:
363-
name: Run Bazel tests on Saucelabs
359+
name: Run Bazel tests on Saucelabs with ViewEngine
364360
# See /tools/saucelabs/README.md for more info
365361
command: |
366362
yarn bazel run //tools/saucelabs:sauce_service_setup
367-
yarn bazel test //:saucelabs_unit_tests_poc_suite --config=saucelabs
363+
TESTS=$(./node_modules/.bin/bazel query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs", ...)')
364+
yarn bazel test --config=saucelabs ${TESTS}
368365
yarn bazel run //tools/saucelabs:sauce_service_stop
369-
no_output_timeout: 20m
366+
no_output_timeout: 40m
370367
- notify_webhook_on_fail:
371368
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
372369

370+
# NOTE: This is currently limited to master builds only. See the `default_workflow` configuration.
373371
saucelabs_ivy:
374372
executor:
375373
name: default-executor
@@ -382,13 +380,16 @@ jobs:
382380
- init_environment
383381
- init_saucelabs_environment
384382
- run:
385-
name: Run Bazel tests on Saucelabs
383+
name: Run Bazel tests on Saucelabs with Ivy
386384
# See /tools/saucelabs/README.md for more info
387385
command: |
388386
yarn bazel run //tools/saucelabs:sauce_service_setup
389-
yarn bazel test //:saucelabs_unit_tests --config=saucelabs --config=ivy
387+
TESTS=$(./node_modules/.bin/bazel query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs", ...)')
388+
yarn bazel test --config=saucelabs --config=ivy ${TESTS}
390389
yarn bazel run //tools/saucelabs:sauce_service_stop
391-
no_output_timeout: 20m
390+
no_output_timeout: 40m
391+
- notify_webhook_on_fail:
392+
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
392393

393394
test_aio:
394395
executor: default-executor
@@ -840,13 +841,22 @@ workflows:
840841
requires:
841842
- setup
842843
- saucelabs_ivy:
844+
# Testing saucelabs via Bazel currently taking longer than the legacy saucelabs job as it
845+
# each karma_web_test target is provisioning and tearing down browsers which is adding
846+
# a lot of overhead. Running on master only to avoid wasting resources and slowing down
847+
# CI for PRs.
848+
# TODO: Run this job on all branches (including PRs) once karma_web_test targets can
849+
# share provisioned browsers and we can remove the legacy saucelabs job.
850+
<<: *only_on_master
843851
requires:
844-
- test_ivy_aot
852+
- setup
845853
- saucelabs_view_engine:
846-
# This job is currently a PoC and a subset of `legacy-unit-tests-saucelabs`. Running on
847-
# master only to avoid wasting resources.
848-
# TODO: Run this job on all branches (including PRs) as soon as it is not a PoC and
849-
# we can remove the legacy saucelabs job.
854+
# Testing saucelabs via Bazel currently taking longer than the legacy saucelabs job as it
855+
# each karma_web_test target is provisioning and tearing down browsers which is adding
856+
# a lot of overhead. Running on master only to avoid wasting resources and slowing down
857+
# CI for PRs.
858+
# TODO: Run this job on all branches (including PRs) once karma_web_test targets can
859+
# share provisioned browsers and we can remove the legacy saucelabs job.
850860
<<: *only_on_master
851861
requires:
852862
- setup
@@ -899,6 +909,7 @@ workflows:
899909
- test
900910
- test_ivy_aot
901911
- integration_test
912+
- saucelabs_view_engine
902913
- saucelabs_ivy
903914
# Only publish if `aio`/`docs` tests using the locally built Angular packages pass
904915
- test_aio_local

BUILD.bazel

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "karma_web_test")
4-
53
exports_files([
64
"LICENSE",
75
"protractor-perf.conf.js",
@@ -46,76 +44,3 @@ filegroup(
4644
"@npm//:node_modules/angular-mocks-1.6/angular-mocks.js",
4745
],
4846
)
49-
50-
# To run manually:
51-
# Setup your SAUCE_USERNAME, SAUCE_ACCESS_KEY & SAUCE_TUNNEL_IDENTIFIER.
52-
# If on OSX, also set SAUCE_CONNECT to the path of your `sc` binary.
53-
# environment variables and run:
54-
# ```
55-
# yarn bazel run //tools/saucelabs:sauce_service_setup
56-
# yarn bazel test //:saucelabs_unit_tests --config=saucelabs --config=ivy
57-
# ```
58-
# See /tools/saucelabs/README.md for more info on karma Saucelabs tests under Bazel.
59-
karma_web_test(
60-
name = "saucelabs_unit_tests",
61-
# Default timeout is moderate (5min). This causes the test to be terminated while
62-
# Saucelabs browsers keep running. Ultimately resulting in failing tests and browsers
63-
# unnecessarily being acquired. Our specified Saucelabs idle timeout is 10min, so we use
64-
# Bazel's long timeout (15min). This ensures that Karma can shut down properly.
65-
timeout = "long",
66-
karma = "//tools/saucelabs:karma-saucelabs",
67-
tags = [
68-
"manual",
69-
"no-remote-exec",
70-
"saucelabs",
71-
],
72-
deps = [
73-
"//packages/core/test/acceptance:acceptance_lib",
74-
],
75-
)
76-
77-
SAUCE_TEST_SUITE_TARGETS = [
78-
"packages/common/http/test:test_lib",
79-
"packages/common/http/testing/test:test_lib",
80-
"packages/common/test:test_lib",
81-
"packages/core/test:test_lib",
82-
"packages/forms/test:test_lib",
83-
"packages/http/test:test_lib",
84-
]
85-
86-
[
87-
# These target runs in CI with View Engine as a Saucelabs and Bazel proof-of-concept. It's a
88-
# subset of the legacy saucelabs tests.
89-
karma_web_test(
90-
name = "saucelabs_unit_tests_poc_%s" % test.replace("/", "_").replace(":", "_").replace(".", "_"),
91-
# Default timeout is moderate (5min). This causes the test to be terminated while
92-
# Saucelabs browsers keep running. Ultimately resulting in failing tests and browsers
93-
# unnecessarily being acquired. Our specified Saucelabs idle timeout is 10min, so we use
94-
# Bazel's long timeout (15min). This ensures that Karma can shut down properly.
95-
timeout = "long",
96-
karma = "//tools/saucelabs:karma-saucelabs",
97-
tags = [
98-
"exclusive",
99-
"manual",
100-
"no-remote-exec",
101-
"saucelabs",
102-
],
103-
deps = ["//%s" % test],
104-
)
105-
for test in SAUCE_TEST_SUITE_TARGETS
106-
]
107-
108-
# To run manually:
109-
# Setup your SAUCE_USERNAME, SAUCE_ACCESS_KEY & SAUCE_TUNNEL_IDENTIFIER.
110-
# If on OSX, also set SAUCE_CONNECT to the path of your `sc` binary.
111-
# environment variables and run:
112-
# ```
113-
# yarn bazel run //tools/saucelabs:sauce_service_setup
114-
# yarn bazel test //:saucelabs_unit_tests_poc_suite --config=saucelabs
115-
# ```
116-
# See /tools/saucelabs/README.md for more info on karma Saucelabs tests under Bazel.
117-
test_suite(
118-
name = "saucelabs_unit_tests_poc_suite",
119-
tags = ["manual"],
120-
tests = ["//:saucelabs_unit_tests_poc_%s" % test.replace("/", "_").replace(":", "_").replace(".", "_") for test in SAUCE_TEST_SUITE_TARGETS],
121-
)

tools/defaults.bzl

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -214,54 +214,69 @@ def pkg_npm(name, substitutions = {}, **kwargs):
214214
visibility = visibility,
215215
)
216216

217-
def karma_web_test(bootstrap = [], deps = [], data = [], runtime_deps = [], **kwargs):
218-
"""Default values for karma_web_test"""
219-
if not bootstrap:
220-
bootstrap = ["//:web_test_bootstrap_scripts"]
221-
local_deps = [
217+
def karma_web_test_suite(name, **kwargs):
218+
"""Default values for karma_web_test_suite"""
219+
220+
# Default value for bootstrap
221+
bootstrap = kwargs.pop("bootstrap", [
222+
"//:web_test_bootstrap_scripts",
223+
])
224+
225+
# Add common deps
226+
deps = kwargs.pop("deps", []) + [
222227
"@npm//karma-browserstack-launcher",
223228
"@npm//karma-sauce-launcher",
224229
"@npm//:node_modules/tslib/tslib.js",
225230
"//tools/rxjs:rxjs_umd_modules",
226231
"//packages/zone.js:npm_package",
227-
] + deps
228-
local_runtime_deps = [
232+
]
233+
234+
# Add common runtime deps
235+
runtime_deps = kwargs.pop("runtime_deps", []) + [
229236
"//tools/testing:browser",
230-
] + runtime_deps
237+
]
238+
239+
data = kwargs.pop("data", [])
240+
tags = kwargs.pop("tags", [])
231241

242+
_karma_web_test_suite(
243+
name = name,
244+
runtime_deps = runtime_deps,
245+
bootstrap = bootstrap,
246+
deps = deps,
247+
browsers = ["//tools/browsers:chromium"],
248+
data = data,
249+
tags = tags,
250+
**kwargs
251+
)
252+
253+
# Add a saucelabs target for these karma tests
232254
_karma_web_test(
233-
runtime_deps = local_runtime_deps,
255+
name = "saucelabs_%s" % name,
256+
# Default timeout is moderate (5min). This causes the test to be terminated while
257+
# Saucelabs browsers keep running. Ultimately resulting in failing tests and browsers
258+
# unnecessarily being acquired. Our specified Saucelabs idle timeout is 10min, so we use
259+
# Bazel's long timeout (15min). This ensures that Karma can shut down properly.
260+
timeout = "long",
261+
runtime_deps = runtime_deps,
234262
bootstrap = bootstrap,
235263
config_file = "//:karma-js.conf.js",
236-
deps = local_deps,
264+
deps = deps,
237265
data = data + [
238266
"//:browser-providers.conf.js",
239267
"//tools:jasmine-seed-generator.js",
240268
],
269+
karma = "//tools/saucelabs:karma-saucelabs",
270+
tags = tags + [
271+
"exclusive",
272+
"manual",
273+
"no-remote-exec",
274+
"saucelabs",
275+
],
241276
configuration_env_vars = ["KARMA_WEB_TEST_MODE"],
242277
**kwargs
243278
)
244279

245-
def karma_web_test_suite(bootstrap = [], deps = [], runtime_deps = [], **kwargs):
246-
"""Default values for karma_web_test_suite"""
247-
if not bootstrap:
248-
bootstrap = ["//:web_test_bootstrap_scripts"]
249-
local_deps = [
250-
"@npm//:node_modules/tslib/tslib.js",
251-
"//tools/rxjs:rxjs_umd_modules",
252-
] + deps
253-
local_runtime_deps = [
254-
"//tools/testing:browser",
255-
] + runtime_deps
256-
257-
_karma_web_test_suite(
258-
runtime_deps = local_runtime_deps,
259-
bootstrap = bootstrap,
260-
deps = local_deps,
261-
browsers = ["//tools/browsers:chromium"],
262-
**kwargs
263-
)
264-
265280
def protractor_web_test_suite(**kwargs):
266281
"""Default values for protractor_web_test_suite"""
267282

0 commit comments

Comments
 (0)