Skip to content

Commit 6d3a25d

Browse files
devversionkara
authored andcommitted
ci: run acceptance tests on saucelabs with ivy (angular#34277)
Currently we only run Saucelabs on PRs using the legacy View Engine build. Switching that build to Ivy is not trivial and there are various options: 1. Updating the R3 switches to use POST_R3 by default. At first glance, this doesn't look easy because the current ngtsc switch logic seems to be unidirectional (only PRE_R3 to POST_R3). 2. Updating the legacy setup to run with Ivy. This sounds like the easiest solution at first.. but it turns out to be way more complicated. Packages would need to be built with ngtsc using legacy tools (i.e. first building the compiler-cli; and then building packages) and View Engine only tests would need to be determined and filtered out. Basically it will result in re-auditing all test targets. This is contradictory to the fact that we have this information in Bazel already. 3. Creating a new job that runs tests on Saucelabs with Bazel. We specify fine-grained test targets that should run. This would be a good start (e.g. acceptance tests) and also would mean that we do not continue maintaining the legacy setup.. This commit implements the third option as it allows us to move forward with the general Bazel migration. We don't want to spend too much time on our legacy setup since it will be removed anyway in the future. PR Close angular#34277
1 parent 3bbd12d commit 6d3a25d

File tree

13 files changed

+73
-29
lines changed

13 files changed

+73
-29
lines changed

.circleci/bazel.common.rc

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ test --flaky_test_attempts=2
1313

1414
# More details on failures
1515
build --verbose_failures=true
16+
17+
# For saucelabs tests we don't want to enable flaky test attempts. Karma has its own integrated
18+
# retry mechanism and we do not want to retry unnecessarily if Karma already tried multiple times.
19+
test:saucelabs --flaky_test_attempts=1

.circleci/config.yml

+35-8
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ jobs:
330330
# [BUILD.bazel](https://github.com/angular/angular/blob/ef44f51d5/BUILD.bazel#L66-L92)).
331331
#
332332
# NOTE: This is currently limited to master builds only. See the `default_workflow` configuration.
333-
test_saucelabs_bazel:
333+
saucelabs_view_engine:
334334
executor:
335335
name: default-executor
336336
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
@@ -344,9 +344,9 @@ jobs:
344344
- setup_bazel_rbe
345345
- run:
346346
name: Run Bazel tests in saucelabs
347-
# All web tests are contained within a single //:test_web_all target for Saucelabs
348-
# as running each set of tests as a separate target will attempt to acquire too
349-
# many browsers on Saucelabs (7 per target currently) and some tests will always
347+
# All web tests are contained within a single //:saucelabs_unit_tests_poc target
348+
# for Saucelabs as running each set of tests as a separate target will attempt to acquire
349+
# too many browsers on Saucelabs (7 per target currently) and some tests will always
350350
# fail to acquire browsers. For example:
351351
# 14 02 2019 19:52:33.170:WARN [launcher]: chrome beta on SauceLabs have not captured in 180000 ms, killing.
352352
# //packages/forms/test:web_test_sauce TIMEOUT in 315.0s
@@ -355,11 +355,34 @@ jobs:
355355
--tunnel-id angular-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_INDEX} \
356356
--username $SAUCE_USERNAME \
357357
--key $(echo $SAUCE_ACCESS_KEY | rev) \
358-
yarn bazel test //:test_web_all
358+
yarn bazel test //:saucelabs_unit_tests_poc --config=saucelabs
359359
no_output_timeout: 20m
360360
- notify_webhook_on_fail:
361361
webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
362362

363+
saucelabs_ivy:
364+
executor:
365+
name: default-executor
366+
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
367+
# container for this job. This is necessary because we launch a lot of browsers concurrently
368+
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
369+
resource_class: xlarge
370+
steps:
371+
- custom_attach_workspace
372+
- init_environment
373+
- setup_circleci_bazel_config
374+
- setup_bazel_rbe
375+
- run:
376+
name: Run Bazel tests on Saucelabs
377+
# Runs the //:saucelabs_tests target with Saucelabs and Ivy.
378+
command: |
379+
./scripts/saucelabs/run-bazel-via-tunnel.sh \
380+
--tunnel-id angular-${CIRCLE_BUILD_NUM}-${CIRCLE_NODE_INDEX} \
381+
--username $SAUCE_USERNAME \
382+
--key $(echo $SAUCE_ACCESS_KEY | rev) \
383+
-- yarn bazel test //:saucelabs_unit_tests --config=ivy --config=saucelabs
384+
no_output_timeout: 20m
385+
363386
test_aio:
364387
# Needed because the AIO tests and the PWA score test depend on Chrome being available.
365388
executor: browsers-executor
@@ -819,11 +842,14 @@ workflows:
819842
- legacy-unit-tests-saucelabs:
820843
requires:
821844
- setup
822-
- test_saucelabs_bazel:
845+
- saucelabs_ivy:
846+
requires:
847+
- test_ivy_aot
848+
- saucelabs_view_engine:
823849
# This job is currently a PoC and a subset of `legacy-unit-tests-saucelabs`. Running on
824850
# master only to avoid wasting resources.
825-
#
826-
# TODO: Run this job on all branches (including PRs) as soon as it is not a PoC.
851+
# TODO: Run this job on all branches (including PRs) as soon as it is not a PoC and
852+
# we can remove the legacy saucelabs job.
827853
<<: *only_on_master
828854
requires:
829855
- setup
@@ -876,6 +902,7 @@ workflows:
876902
- test
877903
- test_ivy_aot
878904
- integration_test
905+
- saucelabs_ivy
879906
# Only publish if `aio`/`docs` tests using the locally built Angular packages pass
880907
- test_aio_local
881908
- test_aio_local_viewengine

BUILD.bazel

+22-11
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,36 @@ filegroup(
4747
],
4848
)
4949

50-
# To run a karma_web_test target locally on SauceLabs:
51-
# 1) have SAUCE_USERNAME, SAUCE_ACCESS_KEY (and optionally a SAUCE_TUNNEL_IDENTIFIER) set in your environment
52-
# 2) open a sauce connection with `./scripts/saucelabs/start-tunnel.sh`
53-
# NOTE: start-tunnel.sh uses `node_modules/sauce-connect` which is current linux specific:
54-
# "sauce-connect": "https://saucelabs.com/downloads/sc-4.5.3-linux.tar.gz".
55-
# On OSX or Windows you'll need to use the appropriate sauce-connect binary.
56-
# 3) run target with `yarn bazel test --config=saucelabs <target>`
57-
# NOTE: --config=saucelabs is required as it makes the SAUCE_XXX environment variables available to
58-
# the action. See /.bazelrc.
50+
# To run a karma_web_test target manually, run the "./scripts/saucelabs/run-bazel-via-tunnel.sh"
51+
# script. Note: If you are on MacOS or Windows, you need to manually start the Saucelabs tunnel
52+
# because the script only supports the linux Saucelabs tunnel binary. We combine all tests into
53+
# a single "karma_web_test" target because running them as separate targets in parallel can result
54+
# in to too many browsers being acquired at the same time. This will then result in tests being
55+
# flaky. This target runs in CI with Saucelabs and Ivy.
5956
karma_web_test(
60-
name = "test_web_all",
57+
name = "saucelabs_unit_tests",
58+
tags = [
59+
"local",
60+
"manual",
61+
"saucelabs",
62+
],
63+
deps = [
64+
"//packages/core/test/acceptance:acceptance_lib",
65+
],
66+
)
67+
68+
karma_web_test(
69+
# This target runs in CI with View Engine as a Saucelabs and Bazel proof-of-concept. It's a
70+
# subset of the legacy saucelabs tests.
71+
name = "saucelabs_unit_tests_poc",
6172
tags = [
6273
"local",
6374
"manual",
6475
"saucelabs",
6576
],
6677
deps = [
6778
# We combine all tests into a single karma_web_test target
68-
# as running them as seperate targets in parallel leads to too many
79+
# as running them as separate targets in parallel leads to too many
6980
# browsers being acquired at once in SauceLabs and the tests flake out
7081
# TODO: this is an example subset of tests below, add all remaining angular tests
7182
"//packages/common/http/test:test_lib",

packages/common/http/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ts_library(
66
srcs = glob(
77
["**/*.ts"],
88
),
9-
# Visible to //:test_web_all target
9+
# Visible to //:saucelabs_unit_tests_poc target
1010
visibility = ["//:__pkg__"],
1111
deps = [
1212
"//packages/common/http",

packages/common/http/testing/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ts_library(
66
srcs = glob(
77
["**/*.ts"],
88
),
9-
# Visible to //:test_web_all target
9+
# Visible to //:saucelabs_unit_tests_poc target
1010
visibility = ["//:__pkg__"],
1111
deps = [
1212
"//packages/common/http",

packages/common/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ts_library(
66
srcs = glob(
77
["**/*.ts"],
88
),
9-
# Visible to //:test_web_all target
9+
# Visible to //:saucelabs_unit_tests_poc target
1010
visibility = ["//:__pkg__"],
1111
deps = [
1212
"//packages/common",

packages/core/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ts_library(
1111
"**/*_node_only_spec.ts",
1212
],
1313
),
14-
# Visible to //:test_web_all target
14+
# Visible to //:saucelabs_unit_tests_poc target
1515
visibility = ["//:__pkg__"],
1616
deps = [
1717
"//packages/animations",

packages/core/test/acceptance/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ts_library(
88
srcs = glob(
99
["**/*.ts"],
1010
),
11+
# Visible to //:saucelabs_unit_tests
12+
visibility = ["//:__pkg__"],
1113
deps = [
1214
"//packages/animations",
1315
"//packages/animations/browser",

packages/forms/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ts_library(
44
name = "test_lib",
55
testonly = True,
66
srcs = glob(["**/*.ts"]),
7-
# Visible to //:test_web_all target
7+
# Visible to //:saucelabs_unit_tests_poc target
88
visibility = ["//:__pkg__"],
99
deps = [
1010
"//packages/common",

packages/http/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ts_library(
44
name = "test_lib",
55
testonly = True,
66
srcs = glob(["**/*.ts"]),
7-
# Visible to //:test_web_all target
7+
# Visible to //:saucelabs_unit_tests_poc target
88
visibility = ["//:__pkg__"],
99
deps = [
1010
"//packages/common",

packages/router/test/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ts_library(
44
name = "test_lib",
55
testonly = True,
66
srcs = glob(["**/*.ts"]),
7-
# Visible to //:test_web_all target
7+
# Visible to //:saucelabs_unit_tests_poc target
88
visibility = ["//:__pkg__"],
99
deps = [
1010
"//packages/common",

packages/zone.js/test/karma_test.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps,
127127
":assets/import.html",
128128
],
129129
tags = ["zone_karma_test"],
130-
# Visible to //:test_web_all target
130+
# Visible to //:saucelabs_unit_tests_poc target
131131
visibility = ["//:__pkg__"],
132132
runtime_deps = [
133133
"@npm//karma-browserstack-launcher",

scripts/saucelabs/run-bazel-via-tunnel.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ set +e
158158
cd $GIT_ROOT_DIR && \
159159
# Run bazel command with saucelabs specific environment variables passed to the action
160160
# The KARMA_WEB_TEST_MODE and SAUCE_TUNNEL_IDENTIFIER environment variables provide
161-
# envirnment variables to be read in the karma configuration file to set correct
161+
# environment variables to be read in the karma configuration file to set correct
162162
# configurations for karma saucelabs and browser configs.
163-
# Usage of these envirnment variables can be seen in this repo in
163+
# Usage of these environment variables can be seen in this repo in
164164
# /karma-js.conf.js and /browser-providers.conf.js
165165
eval "$USER_COMMAND --define=KARMA_WEB_TEST_MODE=SL_REQUIRED \
166166
--action_env=SAUCE_USERNAME=$SAUCE_USERNAME \

0 commit comments

Comments
 (0)