Skip to content

Commit

Permalink
test: run tests on multiple node versions
Browse files Browse the repository at this point in the history
(cherry picked from commit db5c1fc)
  • Loading branch information
jbedard authored and dgp1130 committed Aug 3, 2022
1 parent 88267e6 commit 60acbb6
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 117 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ test --incompatible_strict_action_env
# Enable remote caching of build/action tree
build --experimental_remote_merkle_tree_cache

# Ensure sandboxing is enabled even for exclusive tests
test --incompatible_exclusive_test_sandboxed

###############################
# Saucelabs support #
# Turn on these settings with #
Expand Down
10 changes: 10 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,13 @@ load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies",
aspect_bazel_lib_dependencies()

register_jq_toolchains(version = "1.6")

nodejs_register_toolchains(
name = "node14",
node_version = "14.17.1",
)

nodejs_register_toolchains(
name = "node16",
node_version = "16.13.1",
)
16 changes: 12 additions & 4 deletions packages/angular/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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

# @external_begin
load("//tools:ts_json_schema.bzl", "ts_json_schema")
Expand Down Expand Up @@ -151,10 +152,17 @@ ts_library(
],
)

jasmine_node_test(
name = "angular-cli_test",
srcs = [":angular-cli_test_lib"],
)
[
jasmine_node_test(
name = "angular-cli_test_" + toolchain_name,
srcs = [":angular-cli_test_lib"],
toolchain = toolchain,
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

# @external_begin
genrule(
Expand Down
16 changes: 12 additions & 4 deletions packages/angular/pwa/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")

licenses(["notice"]) # MIT

Expand Down Expand Up @@ -62,10 +63,17 @@ ts_library(
],
)

jasmine_node_test(
name = "pwa_test",
srcs = [":pwa_test_lib"],
)
[
jasmine_node_test(
name = "pwa_test_" + toolchain_name,
srcs = [":pwa_test_lib"],
toolchain = toolchain,
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

genrule(
name = "license",
Expand Down
16 changes: 12 additions & 4 deletions packages/angular_devkit/architect/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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

# @external_begin
load("//tools:ts_json_schema.bzl", "ts_json_schema")
Expand Down Expand Up @@ -90,10 +91,17 @@ ts_library(
],
)

jasmine_node_test(
name = "architect_test",
srcs = [":architect_test_lib"],
)
[
jasmine_node_test(
name = "architect_test_" + toolchain_name,
srcs = [":architect_test_lib"],
toolchain = toolchain,
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

# @external_begin
genrule(
Expand Down
32 changes: 20 additions & 12 deletions packages/angular_devkit/benchmark/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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

licenses(["notice"]) # MIT

Expand Down Expand Up @@ -55,18 +56,25 @@ ts_library(
# @external_end
)

jasmine_node_test(
name = "benchmark_test",
srcs = [":benchmark_test_lib"],
deps = [
"@npm//jasmine",
"@npm//pidtree",
"@npm//pidusage",
"@npm//source-map",
"@npm//tree-kill",
"@npm//yargs-parser",
],
)
[
jasmine_node_test(
name = "benchmark_test_" + toolchain_name,
srcs = [":benchmark_test_lib"],
toolchain = toolchain,
deps = [
"@npm//jasmine",
"@npm//pidtree",
"@npm//pidusage",
"@npm//source-map",
"@npm//tree-kill",
"@npm//yargs-parser",
],
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

genrule(
name = "license",
Expand Down
45 changes: 30 additions & 15 deletions packages/angular_devkit/build_angular/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")

licenses(["notice"]) # MIT
Expand Down Expand Up @@ -209,10 +210,17 @@ ts_library(
],
)

jasmine_node_test(
name = "build_angular_test",
srcs = [":build_angular_test_lib"],
)
[
jasmine_node_test(
name = "build_angular_test_" + toolchain_name,
srcs = [":build_angular_test_lib"],
toolchain = toolchain,
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

genrule(
name = "license",
Expand Down Expand Up @@ -384,16 +392,23 @@ LARGE_SPECS = {
]

[
jasmine_node_test(
name = "build_angular_" + spec + "_test",
size = LARGE_SPECS[spec].get("size", "medium"),
flaky = LARGE_SPECS[spec].get("flaky", False),
shard_count = LARGE_SPECS[spec].get("shards", 2),
# These tests are resource intensive and should not be over-parallized as they will
# compete for the resources of other parallel tests slowing everything down.
# Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
tags = ["cpu:2"] + LARGE_SPECS[spec].get("tags", []),
deps = [":build_angular_" + spec + "_test_lib"],
[
jasmine_node_test(
name = "build_angular_" + spec + "_test_" + toolchain_name,
size = LARGE_SPECS[spec].get("size", "medium"),
flaky = LARGE_SPECS[spec].get("flaky", False),
shard_count = LARGE_SPECS[spec].get("shards", 2),
# These tests are resource intensive and should not be over-parallized as they will
# compete for the resources of other parallel tests slowing everything down.
# Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
tags = ["cpu:2"] + LARGE_SPECS[spec].get("tags", []),
toolchain = toolchain,
deps = [":build_angular_" + spec + "_test_lib"],
)
for spec in LARGE_SPECS
]
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
for spec in LARGE_SPECS
]
30 changes: 19 additions & 11 deletions packages/angular_devkit/build_webpack/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")

licenses(["notice"]) # MIT
Expand Down Expand Up @@ -87,17 +88,24 @@ ts_library(
],
)

jasmine_node_test(
name = "build_webpack_test",
srcs = [":build_webpack_test_lib"],
# Turns off nodejs require patches and turns on the linker, which sets up up node_modules
# so that standard node module resolution work.
templated_args = ["--nobazel_patch_module_resolver"],
deps = [
"@npm//jasmine",
"@npm//source-map",
],
)
[
jasmine_node_test(
name = "build_webpack_test_" + toolchain_name,
srcs = [":build_webpack_test_lib"],
# Turns off nodejs require patches and turns on the linker, which sets up up node_modules
# so that standard node module resolution work.
templated_args = ["--nobazel_patch_module_resolver"],
toolchain = toolchain,
deps = [
"@npm//jasmine",
"@npm//source-map",
],
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

genrule(
name = "license",
Expand Down
30 changes: 19 additions & 11 deletions packages/angular_devkit/core/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")

# @external_begin
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
Expand Down Expand Up @@ -65,17 +66,24 @@ ts_library(
],
)

jasmine_node_test(
name = "core_test",
srcs = [":core_test_lib"],
# TODO: Audit tests to determine if tests can be run in RBE environments
local = True,
deps = [
# @node_module: ajv
# @node_module: fast_json_stable_stringify
# @node_module: source_map
],
)
[
jasmine_node_test(
name = "core_test_" + toolchain_name,
srcs = [":core_test_lib"],
# TODO: Audit tests to determine if tests can be run in RBE environments
local = True,
toolchain = toolchain,
deps = [
# @node_module: ajv
# @node_module: fast_json_stable_stringify
# @node_module: source_map
],
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

# @external_begin
genrule(
Expand Down
28 changes: 18 additions & 10 deletions packages/angular_devkit/core/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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

licenses(["notice"]) # MIT License

Expand Down Expand Up @@ -52,13 +53,20 @@ ts_library(
],
)

jasmine_node_test(
name = "node_test",
srcs = [":node_test_lib"],
deps = [
"@npm//chokidar",
# @node_module: ajv
# @node_module: fast_json_stable_stringify
# @node_module: magic_string
],
)
[
jasmine_node_test(
name = "node_test_" + toolchain_name,
srcs = [":node_test_lib"],
toolchain = toolchain,
deps = [
"@npm//chokidar",
# @node_module: ajv
# @node_module: fast_json_stable_stringify
# @node_module: magic_string
],
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]
24 changes: 16 additions & 8 deletions packages/angular_devkit/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:toolchain_info.bzl", "TOOLCHAINS_NAMES", "TOOLCHAINS_VERSIONS")

# @external_begin
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
Expand Down Expand Up @@ -59,14 +60,21 @@ ts_library(
],
)

jasmine_node_test(
name = "schematics_test",
srcs = [":schematics_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
],
)
[
jasmine_node_test(
name = "schematics_test_" + toolchain_name,
srcs = [":schematics_test_lib"],
toolchain = toolchain,
deps = [
"@npm//jasmine",
"@npm//source-map",
],
)
for toolchain_name, toolchain in zip(
TOOLCHAINS_NAMES,
TOOLCHAINS_VERSIONS,
)
]

# @external_begin
genrule(
Expand Down
Loading

0 comments on commit 60acbb6

Please sign in to comment.