Skip to content

Commit 2c8fd2b

Browse files
kormidethePunderWoman
authored andcommitted
build(bazel): enable runfiles (angular#46313)
Patches are required for tsec and rules_webtesting. The fix for rules_webtesting was merged to that repo (bazelbuild/rules_webtesting@581b155) but it's unclear when a release will be cut. PR Close angular#46313
1 parent 714183d commit 2c8fd2b

12 files changed

+400
-488
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ test --incompatible_strict_action_env
3838
# and https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df
3939
build --nobuild_runfile_links
4040

41+
build --enable_runfiles
42+
4143
###############################
4244
# Release support #
4345
# Turn on these settings with #

.pullapprove.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ groups:
11241124
'packages/examples/*',
11251125
'scripts/**',
11261126
'third_party/**',
1127+
'tools/bazel-repo-patches/**',
11271128
'tools/build/**',
11281129
'tools/circular_dependency_test/**',
11291130
'tools/contributing-stats/**',

WORKSPACE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ workspace(
88

99
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1010

11+
# Add a patch fix for rules_webtesting v0.3.5 required for enabling runfiles on Windows.
12+
# TODO: Remove the http_archive for this transitive dependency when a release is cut
13+
# for https://github.com/bazelbuild/rules_webtesting/commit/581b1557e382f93419da6a03b91a45c2ac9a9ec8
14+
# and the version is updated in rules_nodejs.
15+
http_archive(
16+
name = "io_bazel_rules_webtesting",
17+
patch_args = ["-p1"],
18+
patches = [
19+
"//:tools/bazel-repo-patches/rules_webtesting__windows_runfiles_fix.patch",
20+
],
21+
sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
22+
urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz"],
23+
)
24+
1125
http_archive(
1226
name = "build_bazel_rules_nodejs",
1327
sha256 = "0fad45a9bda7dc1990c47b002fd64f55041ea751fafc00cd34efb96107675778",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
},
179179
"// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.",
180180
"devDependencies": {
181-
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#e45a962f80dbcd36bcdfe82497d8b6ce3990506c",
181+
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#fb0ce9d4c7f9a15e0351dc30f771993d757dc870",
182182
"@bazel/bazelisk": "^1.7.5",
183183
"@bazel/buildifier": "^5.0.0",
184184
"@bazel/ibazel": "^0.16.0",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/web/internal/windows_utils.bzl b/web/internal/windows_utils.bzl
2+
index 4bec20e..cada638 100644
3+
--- a/web/internal/windows_utils.bzl
4+
+++ b/web/internal/windows_utils.bzl
5+
@@ -35,6 +35,9 @@ if "%RUNFILES_MANIFEST_ONLY%" neq "1" (
6+
set %~2=%~1
7+
exit /b 0
8+
)
9+
+if exist "%RUNFILES_DIR%" (
10+
+ set RUNFILES_MANIFEST_FILE=%RUNFILES_DIR%_manifest
11+
+)
12+
if "%RUNFILES_MANIFEST_FILE%" equ "" (
13+
set RUNFILES_MANIFEST_FILE=%~f0.runfiles\MANIFEST
14+
)

tools/legacy-saucelabs/test-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
// Increase the timeout for specs as Saucelabs devices can be slow.
1010
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
1111

12-
import '../testing/init_browser_spec';
12+
import '../testing/init_browser_tests';

tools/postinstall-patches.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
6161
}
6262
});
6363

64+
// patch tsec 0.2.2 to enable runfiles on windows
65+
// Note that we need to use tsec 0.2.2 as future versions don't publish this bzl file
66+
log('\n# patch: tsec to enable using runfiles on windows');
67+
sed('-i', '@platforms//os:windows": False', '@platforms//os:windows": True',
68+
'node_modules/tsec/index.bzl');
69+
6470
log('\n# patch: use local version of @angular/* and zone.js in Starlark files from @angular/dev-infra-private');
6571

6672
const ngDevPatches = new Map();

tools/testing/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"])
55
ts_library(
66
name = "browser",
77
testonly = 1,
8-
srcs = ["init_browser_spec.ts"],
8+
srcs = ["init_browser_tests.ts"],
99
deps = [
1010
"//packages/compiler",
1111
"//packages/core/testing",
@@ -17,7 +17,7 @@ ts_library(
1717
ts_library(
1818
name = "node",
1919
testonly = 1,
20-
srcs = ["init_node_spec.ts"],
20+
srcs = ["init_node_tests.ts"],
2121
deps = [
2222
"//packages/compiler",
2323
"//packages/core/testing",
@@ -31,7 +31,7 @@ ts_library(
3131
ts_library(
3232
name = "node_no_angular",
3333
testonly = 1,
34-
srcs = ["init_node_no_angular_spec.ts"],
34+
srcs = ["init_node_no_angular_tests.ts"],
3535
deps = [
3636
"//packages:types",
3737
],

tools/testing/init_browser_spec.ts renamed to tools/testing/init_browser_tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import '@angular/compiler'; // For JIT mode. Must be in front of any other @angular/* imports.
10+
1011
import {TestBed} from '@angular/core/testing';
1112
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
1213
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
File renamed without changes.

0 commit comments

Comments
 (0)