Skip to content

Commit dcbc5ac

Browse files
jbedarddgp1130
authored andcommitted
test: unit test multiple node versions in separate jobs
(cherry picked from commit 4de9045)
1 parent 4756d7e commit dcbc5ac

File tree

15 files changed

+63
-18
lines changed

15 files changed

+63
-18
lines changed

.circleci/dynamic_config.yml

+35-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ parameters:
2525
var_1: &cache_key v1-angular_devkit-14.19-{{ checksum "yarn.lock" }}
2626
var_1_win: &cache_key_win v1-angular_devkit-win-16.10-{{ checksum "yarn.lock" }}
2727
var_3: &default_nodeversion '14.19'
28+
var_3_major: &default_nodeversion_major '14'
29+
# The major version of node toolchains. See tools/toolchain_info.bzl
30+
# NOTE: entries in this array may be repeated elsewhere in the file, find them before adding more
31+
var_3_all_major: &all_nodeversion_major ['14', '16']
2832
# Workspace initially persisted by the `setup` job, and then enhanced by `setup-and-build-win`.
2933
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
3034
# https://circleci.com/blog/deep-diving-into-circleci-workspaces/
@@ -287,19 +291,39 @@ jobs:
287291
- custom_attach_workspace
288292
- run: yarn bazel build //tests/legacy-cli/...
289293

290-
test:
294+
unit-test:
291295
executor: test-executor
292296
resource_class: xlarge
297+
parameters:
298+
nodeversion:
299+
type: string
300+
default: *default_nodeversion_major
293301
steps:
294302
- custom_attach_workspace
295303
- browser-tools/install-chrome
296304
- setup_bazel_rbe
297305
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
298-
- run:
299-
command: yarn bazel:test
300-
# This timeout provides time for the actual tests to timeout and report status
301-
# instead of CircleCI stopping the job without test failure information.
302-
no_output_timeout: 40m
306+
- when:
307+
# The default nodeversion runs all *excluding* other versions
308+
condition:
309+
equal: [*default_nodeversion_major, << parameters.nodeversion >>]
310+
steps:
311+
- run:
312+
command: yarn bazel test --test_tag_filters=-node16,-node<< parameters.nodeversion >>-broken //packages/...
313+
# This timeout provides time for the actual tests to timeout and report status
314+
# instead of CircleCI stopping the job without test failure information.
315+
no_output_timeout: 40m
316+
- when:
317+
# Non-default nodeversion runs only that specific nodeversion
318+
condition:
319+
not:
320+
equal: [*default_nodeversion_major, << parameters.nodeversion >>]
321+
steps:
322+
- run:
323+
command: yarn bazel test --test_tag_filters=node<< parameters.nodeversion >>,-node<< parameters.nodeversion >>-broken //packages/...
324+
# This timeout provides time for the actual tests to timeout and report status
325+
# instead of CircleCI stopping the job without test failure information.
326+
no_output_timeout: 40m
303327
- fail_fast
304328

305329
snapshot_publish:
@@ -446,7 +470,11 @@ workflows:
446470
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
447471
# will catch any build errors before proceeding to the more lengthy and resource intensive
448472
# Bazel jobs.
449-
- test:
473+
- unit-test:
474+
name: test-node<< matrix.nodeversion >>
475+
matrix:
476+
parameters:
477+
nodeversion: *all_nodeversion_major
450478
requires:
451479
- build
452480

packages/angular/cli/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ ts_library(
152152
jasmine_node_test(
153153
name = "angular-cli_test_" + toolchain_name,
154154
srcs = [":angular-cli_test_lib"],
155+
tags = [toolchain_name],
155156
toolchain = toolchain,
156157
)
157158
for toolchain_name, toolchain in zip(

packages/angular/pwa/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ ts_library(
6666
jasmine_node_test(
6767
name = "pwa_test_" + toolchain_name,
6868
srcs = [":pwa_test_lib"],
69+
tags = [toolchain_name],
6970
toolchain = toolchain,
7071
)
7172
for toolchain_name, toolchain in zip(

packages/angular_devkit/architect/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ ts_library(
9090
jasmine_node_test(
9191
name = "architect_test_" + toolchain_name,
9292
srcs = [":architect_test_lib"],
93+
tags = [toolchain_name],
9394
toolchain = toolchain,
9495
)
9596
for toolchain_name, toolchain in zip(

packages/angular_devkit/benchmark/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ts_library(
6060
jasmine_node_test(
6161
name = "benchmark_test_" + toolchain_name,
6262
srcs = [":benchmark_test_lib"],
63+
tags = [toolchain_name],
6364
toolchain = toolchain,
6465
deps = [
6566
"@npm//jasmine",

packages/angular_devkit/build_angular/BUILD.bazel

+9-3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ ts_library(
213213
jasmine_node_test(
214214
name = "build_angular_test_" + toolchain_name,
215215
srcs = [":build_angular_test_lib"],
216+
tags = [toolchain_name],
216217
toolchain = toolchain,
217218
)
218219
for toolchain_name, toolchain in zip(
@@ -294,8 +295,10 @@ LARGE_SPECS = {
294295
"@npm//puppeteer",
295296
"@npm//ts-node",
296297
],
297-
# NB: does not run on rbe because webdriver manager uses an absolute path to chromedriver
298-
"tags": ["no-remote-exec"],
298+
"tags": [
299+
# TODO: node crashes with an internal error on node16
300+
"node16-broken",
301+
],
299302
},
300303
"dev-server": {
301304
"shards": 10,
@@ -399,7 +402,10 @@ LARGE_SPECS = {
399402
# These tests are resource intensive and should not be over-parallized as they will
400403
# compete for the resources of other parallel tests slowing everything down.
401404
# Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
402-
tags = ["cpu:2"] + LARGE_SPECS[spec].get("tags", []),
405+
tags = [
406+
"cpu:2",
407+
toolchain_name,
408+
] + LARGE_SPECS[spec].get("tags", []),
403409
toolchain = toolchain,
404410
deps = [":build_angular_" + spec + "_test_lib"],
405411
)

packages/angular_devkit/build_webpack/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ ts_library(
9292
jasmine_node_test(
9393
name = "build_webpack_test_" + toolchain_name,
9494
srcs = [":build_webpack_test_lib"],
95+
tags = [toolchain_name],
9596
# Turns off nodejs require patches and turns on the linker, which sets up up node_modules
9697
# so that standard node module resolution work.
9798
templated_args = ["--nobazel_patch_module_resolver"],

packages/angular_devkit/core/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ ts_library(
6565
jasmine_node_test(
6666
name = "core_test_" + toolchain_name,
6767
srcs = [":core_test_lib"],
68+
tags = [toolchain_name],
6869
toolchain = toolchain,
6970
)
7071
for toolchain_name, toolchain in zip(

packages/angular_devkit/core/node/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ ts_library(
5757
jasmine_node_test(
5858
name = "node_test_" + toolchain_name,
5959
srcs = [":node_test_lib"],
60+
tags = [toolchain_name],
6061
toolchain = toolchain,
6162
deps = [
6263
"@npm//chokidar",

packages/angular_devkit/schematics/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ ts_library(
6161
jasmine_node_test(
6262
name = "schematics_test_" + toolchain_name,
6363
srcs = [":schematics_test_lib"],
64+
tags = [toolchain_name],
6465
toolchain = toolchain,
6566
deps = [
6667
"@npm//jasmine",

packages/angular_devkit/schematics/tools/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ts_library(
6262
jasmine_node_test(
6363
name = "tools_test_" + toolchain_name,
6464
srcs = [":tools_test_lib"],
65+
tags = [toolchain_name],
6566
toolchain = toolchain,
6667
deps = [
6768
"@npm//jasmine",

packages/angular_devkit/schematics_cli/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ts_library(
7878
jasmine_node_test(
7979
name = "schematics_cli_test_" + toolchain_name,
8080
srcs = [":schematics_cli_test_lib"],
81+
tags = [toolchain_name],
8182
toolchain = toolchain,
8283
)
8384
for toolchain_name, toolchain in zip(

packages/ngtools/webpack/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ts_library(
6262
jasmine_node_test(
6363
name = "webpack_test_" + toolchain_name,
6464
srcs = [":webpack_test_lib"],
65+
tags = [toolchain_name],
6566
toolchain = toolchain,
6667
deps = [
6768
"@npm//jasmine",

packages/schematics/angular/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ ts_library(
8686
jasmine_node_test(
8787
name = "no_typescript_runtime_dep_test_" + toolchain_name,
8888
srcs = ["no_typescript_runtime_dep_spec.js"],
89+
tags = [toolchain_name],
8990
toolchain = toolchain,
9091
deps = [
9192
":angular",
@@ -129,6 +130,7 @@ ts_library(
129130
jasmine_node_test(
130131
name = "angular_test_" + toolchain_name,
131132
srcs = [":angular_test_lib"],
133+
tags = [toolchain_name],
132134
toolchain = toolchain,
133135
deps = [
134136
"//packages/schematics/angular/third_party/github.com/Microsoft/TypeScript",

tools/toolchain_info.bzl

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
# the order will match against the order in the TOOLCHAIN_VERSION list.
55
TOOLCHAINS_NAMES = [
66
"node14",
7-
# TODO enable one we know more why there is a memory usage increase and app-shell tests work with Node.js 16.
8-
# "node16",
7+
"node16",
98
]
109

1110
# this is the list of toolchains that should be used and are registered with nodejs_register_toolchains in the WORKSPACE file
@@ -15,12 +14,11 @@ TOOLCHAINS_VERSIONS = [
1514
"@bazel_tools//src/conditions:darwin": "@node14_darwin_amd64//:node_toolchain",
1615
"@bazel_tools//src/conditions:windows": "@node14_windows_amd64//:node_toolchain",
1716
}),
18-
# TODO enable one we know more why there is a memory usage increase and app-shell tests work with Node.js 16.
19-
# select({
20-
# "@bazel_tools//src/conditions:linux_x86_64": "@node16_linux_amd64//:node_toolchain",
21-
# "@bazel_tools//src/conditions:darwin": "@node16_darwin_amd64//:node_toolchain",
22-
# "@bazel_tools//src/conditions:windows": "@node16_windows_amd64//:node_toolchain",
23-
# }),
17+
select({
18+
"@bazel_tools//src/conditions:linux_x86_64": "@node16_linux_amd64//:node_toolchain",
19+
"@bazel_tools//src/conditions:darwin": "@node16_darwin_amd64//:node_toolchain",
20+
"@bazel_tools//src/conditions:windows": "@node16_windows_amd64//:node_toolchain",
21+
}),
2422
]
2523

2624
# A default toolchain for use when only one is necessary

0 commit comments

Comments
 (0)