Skip to content

Commit db5c1fc

Browse files
jbedarddgp1130
authored andcommittedAug 3, 2022
test: run tests on multiple node versions
1 parent 425082b commit db5c1fc

File tree

16 files changed

+273
-117
lines changed

16 files changed

+273
-117
lines changed
 

‎.bazelrc

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ test --incompatible_strict_action_env
5050
# Enable remote caching of build/action tree
5151
build --experimental_remote_merkle_tree_cache
5252

53+
# Ensure sandboxing is enabled even for exclusive tests
54+
test --incompatible_exclusive_test_sandboxed
55+
5356
###############################
5457
# Saucelabs support #
5558
# Turn on these settings with #

‎WORKSPACE

+10
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,13 @@ load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies",
8888
aspect_bazel_lib_dependencies()
8989

9090
register_jq_toolchains(version = "1.6")
91+
92+
nodejs_register_toolchains(
93+
name = "node14",
94+
node_version = "14.17.1",
95+
)
96+
97+
nodejs_register_toolchains(
98+
name = "node16",
99+
node_version = "16.13.1",
100+
)

‎packages/angular/cli/BUILD.bazel

+12-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
8+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
89

910
# @external_begin
1011
load("//tools:ts_json_schema.bzl", "ts_json_schema")
@@ -151,10 +152,17 @@ ts_library(
151152
],
152153
)
153154

154-
jasmine_node_test(
155-
name = "angular-cli_test",
156-
srcs = [":angular-cli_test_lib"],
157-
)
155+
[
156+
jasmine_node_test(
157+
name = "angular-cli_test_" + toolchain_name,
158+
srcs = [":angular-cli_test_lib"],
159+
toolchain = toolchain,
160+
)
161+
for toolchain_name, toolchain in zip(
162+
TOOLCHAINS_NAMES,
163+
TOOLCHAINS_VERSIONS,
164+
)
165+
]
158166

159167
# @external_begin
160168
genrule(

‎packages/angular/pwa/BUILD.bazel

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
88
load("//tools:ts_json_schema.bzl", "ts_json_schema")
9+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
910

1011
licenses(["notice"]) # MIT
1112

@@ -62,10 +63,17 @@ ts_library(
6263
],
6364
)
6465

65-
jasmine_node_test(
66-
name = "pwa_test",
67-
srcs = [":pwa_test_lib"],
68-
)
66+
[
67+
jasmine_node_test(
68+
name = "pwa_test_" + toolchain_name,
69+
srcs = [":pwa_test_lib"],
70+
toolchain = toolchain,
71+
)
72+
for toolchain_name, toolchain in zip(
73+
TOOLCHAINS_NAMES,
74+
TOOLCHAINS_VERSIONS,
75+
)
76+
]
6977

7078
genrule(
7179
name = "license",

‎packages/angular_devkit/architect/BUILD.bazel

+12-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
8+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
89

910
# @external_begin
1011
load("//tools:ts_json_schema.bzl", "ts_json_schema")
@@ -90,10 +91,17 @@ ts_library(
9091
],
9192
)
9293

93-
jasmine_node_test(
94-
name = "architect_test",
95-
srcs = [":architect_test_lib"],
96-
)
94+
[
95+
jasmine_node_test(
96+
name = "architect_test_" + toolchain_name,
97+
srcs = [":architect_test_lib"],
98+
toolchain = toolchain,
99+
)
100+
for toolchain_name, toolchain in zip(
101+
TOOLCHAINS_NAMES,
102+
TOOLCHAINS_VERSIONS,
103+
)
104+
]
97105

98106
# @external_begin
99107
genrule(

‎packages/angular_devkit/benchmark/BUILD.bazel

+20-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
8+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
89

910
licenses(["notice"]) # MIT
1011

@@ -55,18 +56,25 @@ ts_library(
5556
# @external_end
5657
)
5758

58-
jasmine_node_test(
59-
name = "benchmark_test",
60-
srcs = [":benchmark_test_lib"],
61-
deps = [
62-
"@npm//jasmine",
63-
"@npm//pidtree",
64-
"@npm//pidusage",
65-
"@npm//source-map",
66-
"@npm//tree-kill",
67-
"@npm//yargs-parser",
68-
],
69-
)
59+
[
60+
jasmine_node_test(
61+
name = "benchmark_test_" + toolchain_name,
62+
srcs = [":benchmark_test_lib"],
63+
toolchain = toolchain,
64+
deps = [
65+
"@npm//jasmine",
66+
"@npm//pidtree",
67+
"@npm//pidusage",
68+
"@npm//source-map",
69+
"@npm//tree-kill",
70+
"@npm//yargs-parser",
71+
],
72+
)
73+
for toolchain_name, toolchain in zip(
74+
TOOLCHAINS_NAMES,
75+
TOOLCHAINS_VERSIONS,
76+
)
77+
]
7078

7179
genrule(
7280
name = "license",

‎packages/angular_devkit/build_angular/BUILD.bazel

+30-15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
88
load("//tools:ts_json_schema.bzl", "ts_json_schema")
9+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
910
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
1011

1112
licenses(["notice"]) # MIT
@@ -209,10 +210,17 @@ ts_library(
209210
],
210211
)
211212

212-
jasmine_node_test(
213-
name = "build_angular_test",
214-
srcs = [":build_angular_test_lib"],
215-
)
213+
[
214+
jasmine_node_test(
215+
name = "build_angular_test_" + toolchain_name,
216+
srcs = [":build_angular_test_lib"],
217+
toolchain = toolchain,
218+
)
219+
for toolchain_name, toolchain in zip(
220+
TOOLCHAINS_NAMES,
221+
TOOLCHAINS_VERSIONS,
222+
)
223+
]
216224

217225
genrule(
218226
name = "license",
@@ -383,16 +391,23 @@ LARGE_SPECS = {
383391
]
384392

385393
[
386-
jasmine_node_test(
387-
name = "build_angular_" + spec + "_test",
388-
size = LARGE_SPECS[spec].get("size", "medium"),
389-
flaky = LARGE_SPECS[spec].get("flaky", False),
390-
shard_count = LARGE_SPECS[spec].get("shards", 2),
391-
# These tests are resource intensive and should not be over-parallized as they will
392-
# compete for the resources of other parallel tests slowing everything down.
393-
# Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
394-
tags = ["cpu:2"] + LARGE_SPECS[spec].get("tags", []),
395-
deps = [":build_angular_" + spec + "_test_lib"],
394+
[
395+
jasmine_node_test(
396+
name = "build_angular_" + spec + "_test_" + toolchain_name,
397+
size = LARGE_SPECS[spec].get("size", "medium"),
398+
flaky = LARGE_SPECS[spec].get("flaky", False),
399+
shard_count = LARGE_SPECS[spec].get("shards", 2),
400+
# These tests are resource intensive and should not be over-parallized as they will
401+
# compete for the resources of other parallel tests slowing everything down.
402+
# Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
403+
tags = ["cpu:2"] + LARGE_SPECS[spec].get("tags", []),
404+
toolchain = toolchain,
405+
deps = [":build_angular_" + spec + "_test_lib"],
406+
)
407+
for spec in LARGE_SPECS
408+
]
409+
for toolchain_name, toolchain in zip(
410+
TOOLCHAINS_NAMES,
411+
TOOLCHAINS_VERSIONS,
396412
)
397-
for spec in LARGE_SPECS
398413
]

‎packages/angular_devkit/build_webpack/BUILD.bazel

+19-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
88
load("//tools:ts_json_schema.bzl", "ts_json_schema")
9+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
910
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
1011

1112
licenses(["notice"]) # MIT
@@ -87,17 +88,24 @@ ts_library(
8788
],
8889
)
8990

90-
jasmine_node_test(
91-
name = "build_webpack_test",
92-
srcs = [":build_webpack_test_lib"],
93-
# Turns off nodejs require patches and turns on the linker, which sets up up node_modules
94-
# so that standard node module resolution work.
95-
templated_args = ["--nobazel_patch_module_resolver"],
96-
deps = [
97-
"@npm//jasmine",
98-
"@npm//source-map",
99-
],
100-
)
91+
[
92+
jasmine_node_test(
93+
name = "build_webpack_test_" + toolchain_name,
94+
srcs = [":build_webpack_test_lib"],
95+
# Turns off nodejs require patches and turns on the linker, which sets up up node_modules
96+
# so that standard node module resolution work.
97+
templated_args = ["--nobazel_patch_module_resolver"],
98+
toolchain = toolchain,
99+
deps = [
100+
"@npm//jasmine",
101+
"@npm//source-map",
102+
],
103+
)
104+
for toolchain_name, toolchain in zip(
105+
TOOLCHAINS_NAMES,
106+
TOOLCHAINS_VERSIONS,
107+
)
108+
]
101109

102110
genrule(
103111
name = "license",

‎packages/angular_devkit/core/BUILD.bazel

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
22
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
3+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
34

45
# @external_begin
56
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
@@ -65,17 +66,24 @@ ts_library(
6566
],
6667
)
6768

68-
jasmine_node_test(
69-
name = "core_test",
70-
srcs = [":core_test_lib"],
71-
# TODO: Audit tests to determine if tests can be run in RBE environments
72-
local = True,
73-
deps = [
74-
# @node_module: ajv
75-
# @node_module: fast_json_stable_stringify
76-
# @node_module: source_map
77-
],
78-
)
69+
[
70+
jasmine_node_test(
71+
name = "core_test_" + toolchain_name,
72+
srcs = [":core_test_lib"],
73+
# TODO: Audit tests to determine if tests can be run in RBE environments
74+
local = True,
75+
toolchain = toolchain,
76+
deps = [
77+
# @node_module: ajv
78+
# @node_module: fast_json_stable_stringify
79+
# @node_module: source_map
80+
],
81+
)
82+
for toolchain_name, toolchain in zip(
83+
TOOLCHAINS_NAMES,
84+
TOOLCHAINS_VERSIONS,
85+
)
86+
]
7987

8088
# @external_begin
8189
genrule(

‎packages/angular_devkit/core/node/BUILD.bazel

+18-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
77
load("//tools:defaults.bzl", "ts_library")
8+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
89

910
licenses(["notice"]) # MIT License
1011

@@ -52,13 +53,20 @@ ts_library(
5253
],
5354
)
5455

55-
jasmine_node_test(
56-
name = "node_test",
57-
srcs = [":node_test_lib"],
58-
deps = [
59-
"@npm//chokidar",
60-
# @node_module: ajv
61-
# @node_module: fast_json_stable_stringify
62-
# @node_module: magic_string
63-
],
64-
)
56+
[
57+
jasmine_node_test(
58+
name = "node_test_" + toolchain_name,
59+
srcs = [":node_test_lib"],
60+
toolchain = toolchain,
61+
deps = [
62+
"@npm//chokidar",
63+
# @node_module: ajv
64+
# @node_module: fast_json_stable_stringify
65+
# @node_module: magic_string
66+
],
67+
)
68+
for toolchain_name, toolchain in zip(
69+
TOOLCHAINS_NAMES,
70+
TOOLCHAINS_VERSIONS,
71+
)
72+
]

‎packages/angular_devkit/schematics/BUILD.bazel

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
22
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
3+
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
34

45
# @external_begin
56
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
@@ -59,14 +60,21 @@ ts_library(
5960
],
6061
)
6162

62-
jasmine_node_test(
63-
name = "schematics_test",
64-
srcs = [":schematics_test_lib"],
65-
deps = [
66-
"@npm//jasmine",
67-
"@npm//source-map",
68-
],
69-
)
63+
[
64+
jasmine_node_test(
65+
name = "schematics_test_" + toolchain_name,
66+
srcs = [":schematics_test_lib"],
67+
toolchain = toolchain,
68+
deps = [
69+
"@npm//jasmine",
70+
"@npm//source-map",
71+
],
72+
)
73+
for toolchain_name, toolchain in zip(
74+
TOOLCHAINS_NAMES,
75+
TOOLCHAINS_VERSIONS,
76+
)
77+
]
7078

7179
# @external_begin
7280
genrule(

0 commit comments

Comments
 (0)