Skip to content

Commit cd775a7

Browse files
devversionalan-agius4
authored andcommitted
build: migrate @angular/pwa tests to rules_js
This commit changes the execution of `@angular/pwa` tests to `rules_js` native `jasmine_test`. This requires setting it up in the pnpm workspace for first-party linked dependencies. Notably it turns out the peer dependency placeholder was incorrect, so we are fixing it here and nicely avoid a problem where pnpm would otherwise not find a local, or external suitable version. As we originally tried to work without the fix for the peer dependency range, there was supported added for extra substitutions. We are keeping that logic as it will likely be useful in the future.
1 parent aa6f0d0 commit cd775a7

File tree

7 files changed

+120
-20
lines changed

7 files changed

+120
-20
lines changed

Diff for: .aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
.npmrc=-2023857461
55
package.json=34697733
66
packages/angular/cli/package.json=349838588
7+
packages/angular/pwa/package.json=-1352285148
78
packages/angular_devkit/architect/package.json=-1496633956
89
packages/angular_devkit/architect_cli/package.json=1551210941
910
packages/angular_devkit/core/package.json=339935828
1011
packages/angular_devkit/schematics/package.json=673943597
1112
packages/schematics/angular/package.json=251715148
12-
pnpm-lock.yaml=656786919
13-
pnpm-workspace.yaml=-1051214858
13+
pnpm-lock.yaml=1949888233
14+
pnpm-workspace.yaml=-818108966
1415
yarn.lock=1185228888

Diff for: WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ npm_translate_lock(
187187
"//:package.json",
188188
"//:pnpm-workspace.yaml",
189189
"//packages/angular/cli:package.json",
190+
"//packages/angular/pwa:package.json",
190191
"//packages/angular_devkit/architect:package.json",
191192
"//packages/angular_devkit/architect_cli:package.json",
192193
"//packages/angular_devkit/core:package.json",

Diff for: packages/angular/pwa/BUILD.bazel

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.dev/license
55

6-
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
7-
load("//tools:defaults2.bzl", "npm_package", "ts_project")
6+
load("@npm2//:defs.bzl", "npm_link_all_packages")
7+
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")
88
load("//tools:ts_json_schema.bzl", "ts_json_schema")
99

1010
licenses(["notice"])
1111

1212
package(default_visibility = ["//visibility:public"])
1313

14+
npm_link_all_packages()
15+
1416
RUNTIME_ASSETS = glob(
1517
include = [
1618
"pwa/*.js",
@@ -32,10 +34,10 @@ ts_project(
3234
data = RUNTIME_ASSETS,
3335
module_name = "@angular/pwa",
3436
deps = [
37+
":node_modules/@angular-devkit/schematics",
38+
":node_modules/@schematics/angular",
3539
"//:node_modules/@types/node",
3640
"//:node_modules/parse5-html-rewriting-stream",
37-
"//packages/angular_devkit/schematics:schematics_rjs",
38-
"//packages/schematics/angular:angular_rjs",
3941
],
4042
)
4143

@@ -55,9 +57,9 @@ ts_project(
5557
],
5658
)
5759

58-
jasmine_node_test(
60+
jasmine_test(
5961
name = "pwa_test",
60-
srcs = [":pwa_test_lib"],
62+
data = [":pwa_test_lib_rjs"],
6163
)
6264

6365
genrule(

Diff for: packages/angular/pwa/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"save": false
1313
},
1414
"dependencies": {
15-
"@angular-devkit/schematics": "0.0.0-PLACEHOLDER",
16-
"@schematics/angular": "0.0.0-PLACEHOLDER",
15+
"@angular-devkit/schematics": "workspace:0.0.0-PLACEHOLDER",
16+
"@schematics/angular": "workspace:0.0.0-PLACEHOLDER",
1717
"parse5-html-rewriting-stream": "7.0.0"
1818
},
1919
"peerDependencies": {

Diff for: pnpm-lock.yaml

+97-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pnpm-workspace.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ packages:
55
- packages/angular_devkit/core
66
- packages/angular_devkit/schematics
77
- packages/angular/cli
8+
- packages/angular/pwa
89
- packages/schematics/angular

Diff for: tools/bazel/npm_package.bzl

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def npm_package(
1515
pkg_deps = [],
1616
stamp_files = [],
1717
pkg_json = "package.json",
18+
extra_substitutions = {},
1819
**kwargs):
1920
if name != "pkg":
2021
fail("Expected npm_package to be named `pkg`. " +
@@ -61,6 +62,9 @@ def npm_package(
6162
out = "substituted_with_snapshot_repos/package.json",
6263
)
6364

65+
nostamp_subs = dict(substitutions["rjs"]["nostamp"], **extra_substitutions)
66+
stamp_subs = dict(substitutions["rjs"]["stamp"], **extra_substitutions)
67+
6468
expand_template(
6569
name = "final_package_json",
6670
template = select({
@@ -71,8 +75,8 @@ def npm_package(
7175
"//conditions:default": "substituted/package.json",
7276
}),
7377
out = "substituted_final/package.json",
74-
substitutions = substitutions["rjs"]["nostamp"],
75-
stamp_substitutions = substitutions["rjs"]["stamp"],
78+
substitutions = nostamp_subs,
79+
stamp_substitutions = stamp_subs,
7680
)
7781

7882
stamp_targets = []
@@ -81,8 +85,8 @@ def npm_package(
8185
name = "stamp_file_%s" % f,
8286
template = f,
8387
out = "substituted/%s" % f,
84-
substitutions = substitutions["rjs"]["nostamp"],
85-
stamp_substitutions = substitutions["rjs"]["stamp"],
88+
substitutions = nostamp_subs,
89+
stamp_substitutions = stamp_subs,
8690
)
8791

8892
stamp_targets.append("stamp_file_%s" % f)

0 commit comments

Comments
 (0)