Skip to content

Commit 481e5e9

Browse files
committed
test: unit test multiple node versions in separate jobs
1 parent 5172bd3 commit 481e5e9

File tree

15 files changed

+65
-18
lines changed

15 files changed

+65
-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/
@@ -291,19 +295,39 @@ jobs:
291295
- custom_attach_workspace
292296
- run: yarn bazel build //tests/legacy-cli/...
293297

294-
test:
298+
unit-test:
295299
executor: test-executor
296300
resource_class: xlarge
301+
parameters:
302+
nodeversion:
303+
type: string
304+
default: *default_nodeversion_major
297305
steps:
298306
- custom_attach_workspace
299307
- browser-tools/install-chrome
300308
- setup_bazel_rbe
301309
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
302-
- run:
303-
command: yarn bazel:test
304-
# This timeout provides time for the actual tests to timeout and report status
305-
# instead of CircleCI stopping the job without test failure information.
306-
no_output_timeout: 40m
310+
- when:
311+
# The default nodeversion runs all *excluding* other versions
312+
condition:
313+
equal: [*default_nodeversion_major, << parameters.nodeversion >>]
314+
steps:
315+
- run:
316+
command: yarn bazel test --test_tag_filters=-node16,-node<< parameters.nodeversion >>-broken //packages/...
317+
# This timeout provides time for the actual tests to timeout and report status
318+
# instead of CircleCI stopping the job without test failure information.
319+
no_output_timeout: 40m
320+
- when:
321+
# Non-default nodeversion runs only that specific nodeversion
322+
condition:
323+
not:
324+
equal: [*default_nodeversion_major, << parameters.nodeversion >>]
325+
steps:
326+
- run:
327+
command: yarn bazel test --test_tag_filters=node<< parameters.nodeversion >>,-node<< parameters.nodeversion >>-broken //packages/...
328+
# This timeout provides time for the actual tests to timeout and report status
329+
# instead of CircleCI stopping the job without test failure information.
330+
no_output_timeout: 40m
307331
- fail_fast
308332

309333
snapshot_publish:
@@ -433,7 +457,11 @@ workflows:
433457
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
434458
# will catch any build errors before proceeding to the more lengthy and resource intensive
435459
# Bazel jobs.
436-
- test:
460+
- unit-test:
461+
name: test-node<< matrix.nodeversion >>
462+
matrix:
463+
parameters:
464+
nodeversion: *all_nodeversion_major
437465
requires:
438466
- build
439467

packages/angular/cli/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ ts_library(
156156
jasmine_node_test(
157157
name = "angular-cli_test_" + toolchain_name,
158158
srcs = [":angular-cli_test_lib"],
159+
tags = [toolchain_name],
159160
toolchain = toolchain,
160161
)
161162
for toolchain_name, toolchain in zip(

packages/angular/pwa/BUILD.bazel

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

packages/angular_devkit/architect/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ ts_library(
9595
jasmine_node_test(
9696
name = "architect_test_" + toolchain_name,
9797
srcs = [":architect_test_lib"],
98+
tags = [toolchain_name],
9899
toolchain = toolchain,
99100
)
100101
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

+11-3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ ts_library(
214214
jasmine_node_test(
215215
name = "build_angular_test_" + toolchain_name,
216216
srcs = [":build_angular_test_lib"],
217+
tags = [toolchain_name],
217218
toolchain = toolchain,
218219
)
219220
for toolchain_name, toolchain in zip(
@@ -295,8 +296,12 @@ LARGE_SPECS = {
295296
"@npm//puppeteer",
296297
"@npm//ts-node",
297298
],
298-
# NB: does not run on rbe because webdriver manager uses an absolute path to chromedriver
299-
"tags": ["no-remote-exec"],
299+
"tags": [
300+
# NB: does not run on rbe because webdriver manager uses an absolute path to chromedriver
301+
"no-remote-exec",
302+
# TODO: node crashes with an internal error on node16
303+
"node16-broken",
304+
],
300305
},
301306
"dev-server": {
302307
"shards": 10,
@@ -400,7 +405,10 @@ LARGE_SPECS = {
400405
# These tests are resource intensive and should not be over-parallized as they will
401406
# compete for the resources of other parallel tests slowing everything down.
402407
# Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
403-
tags = ["cpu:2"] + LARGE_SPECS[spec].get("tags", []),
408+
tags = [
409+
"cpu:2",
410+
toolchain_name,
411+
] + LARGE_SPECS[spec].get("tags", []),
404412
toolchain = toolchain,
405413
deps = [":build_angular_" + spec + "_test_lib"],
406414
)

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
@@ -72,6 +72,7 @@ ts_library(
7272
srcs = [":core_test_lib"],
7373
# TODO: Audit tests to determine if tests can be run in RBE environments
7474
local = True,
75+
tags = [toolchain_name],
7576
toolchain = toolchain,
7677
deps = [
7778
# @node_module: ajv

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
@@ -64,6 +64,7 @@ ts_library(
6464
jasmine_node_test(
6565
name = "schematics_test_" + toolchain_name,
6666
srcs = [":schematics_test_lib"],
67+
tags = [toolchain_name],
6768
toolchain = toolchain,
6869
deps = [
6970
"@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
@@ -79,6 +79,7 @@ ts_library(
7979
jasmine_node_test(
8080
name = "schematics_cli_test_" + toolchain_name,
8181
srcs = [":schematics_cli_test_lib"],
82+
tags = [toolchain_name],
8283
toolchain = toolchain,
8384
)
8485
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
@@ -87,6 +87,7 @@ ts_library(
8787
jasmine_node_test(
8888
name = "no_typescript_runtime_dep_test_" + toolchain_name,
8989
srcs = ["no_typescript_runtime_dep_spec.js"],
90+
tags = [toolchain_name],
9091
toolchain = toolchain,
9192
deps = [
9293
":angular",
@@ -130,6 +131,7 @@ ts_library(
130131
jasmine_node_test(
131132
name = "angular_test_" + toolchain_name,
132133
srcs = [":angular_test_lib"],
134+
tags = [toolchain_name],
133135
toolchain = toolchain,
134136
deps = [
135137
"//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)