Skip to content

Commit

Permalink
build(bazel): enable runfiles (#46313)
Browse files Browse the repository at this point in the history
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 #46313
  • Loading branch information
kormide authored and jessicajaniuk committed Jun 14, 2022
1 parent 714183d commit 2c8fd2b
Show file tree
Hide file tree
Showing 12 changed files with 400 additions and 488 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Expand Up @@ -38,6 +38,8 @@ test --incompatible_strict_action_env
# and https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df
build --nobuild_runfile_links

build --enable_runfiles

###############################
# Release support #
# Turn on these settings with #
Expand Down
1 change: 1 addition & 0 deletions .pullapprove.yml
Expand Up @@ -1124,6 +1124,7 @@ groups:
'packages/examples/*',
'scripts/**',
'third_party/**',
'tools/bazel-repo-patches/**',
'tools/build/**',
'tools/circular_dependency_test/**',
'tools/contributing-stats/**',
Expand Down
14 changes: 14 additions & 0 deletions WORKSPACE
Expand Up @@ -8,6 +8,20 @@ workspace(

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

# Add a patch fix for rules_webtesting v0.3.5 required for enabling runfiles on Windows.
# TODO: Remove the http_archive for this transitive dependency when a release is cut
# for https://github.com/bazelbuild/rules_webtesting/commit/581b1557e382f93419da6a03b91a45c2ac9a9ec8
# and the version is updated in rules_nodejs.
http_archive(
name = "io_bazel_rules_webtesting",
patch_args = ["-p1"],
patches = [
"//:tools/bazel-repo-patches/rules_webtesting__windows_runfiles_fix.patch",
],
sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
urls = ["https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz"],
)

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "0fad45a9bda7dc1990c47b002fd64f55041ea751fafc00cd34efb96107675778",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -178,7 +178,7 @@
},
"// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.",
"devDependencies": {
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#e45a962f80dbcd36bcdfe82497d8b6ce3990506c",
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#fb0ce9d4c7f9a15e0351dc30f771993d757dc870",
"@bazel/bazelisk": "^1.7.5",
"@bazel/buildifier": "^5.0.0",
"@bazel/ibazel": "^0.16.0",
Expand Down
@@ -0,0 +1,14 @@
diff --git a/web/internal/windows_utils.bzl b/web/internal/windows_utils.bzl
index 4bec20e..cada638 100644
--- a/web/internal/windows_utils.bzl
+++ b/web/internal/windows_utils.bzl
@@ -35,6 +35,9 @@ if "%RUNFILES_MANIFEST_ONLY%" neq "1" (
set %~2=%~1
exit /b 0
)
+if exist "%RUNFILES_DIR%" (
+ set RUNFILES_MANIFEST_FILE=%RUNFILES_DIR%_manifest
+)
if "%RUNFILES_MANIFEST_FILE%" equ "" (
set RUNFILES_MANIFEST_FILE=%~f0.runfiles\MANIFEST
)
2 changes: 1 addition & 1 deletion tools/legacy-saucelabs/test-init.ts
Expand Up @@ -9,4 +9,4 @@
// Increase the timeout for specs as Saucelabs devices can be slow.
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;

import '../testing/init_browser_spec';
import '../testing/init_browser_tests';
6 changes: 6 additions & 0 deletions tools/postinstall-patches.js
Expand Up @@ -61,6 +61,12 @@ ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
}
});

// patch tsec 0.2.2 to enable runfiles on windows
// Note that we need to use tsec 0.2.2 as future versions don't publish this bzl file
log('\n# patch: tsec to enable using runfiles on windows');
sed('-i', '@platforms//os:windows": False', '@platforms//os:windows": True',
'node_modules/tsec/index.bzl');

log('\n# patch: use local version of @angular/* and zone.js in Starlark files from @angular/dev-infra-private');

const ngDevPatches = new Map();
Expand Down
6 changes: 3 additions & 3 deletions tools/testing/BUILD.bazel
Expand Up @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"])
ts_library(
name = "browser",
testonly = 1,
srcs = ["init_browser_spec.ts"],
srcs = ["init_browser_tests.ts"],
deps = [
"//packages/compiler",
"//packages/core/testing",
Expand All @@ -17,7 +17,7 @@ ts_library(
ts_library(
name = "node",
testonly = 1,
srcs = ["init_node_spec.ts"],
srcs = ["init_node_tests.ts"],
deps = [
"//packages/compiler",
"//packages/core/testing",
Expand All @@ -31,7 +31,7 @@ ts_library(
ts_library(
name = "node_no_angular",
testonly = 1,
srcs = ["init_node_no_angular_spec.ts"],
srcs = ["init_node_no_angular_tests.ts"],
deps = [
"//packages:types",
],
Expand Down
Expand Up @@ -7,6 +7,7 @@
*/

import '@angular/compiler'; // For JIT mode. Must be in front of any other @angular/* imports.

import {TestBed} from '@angular/core/testing';
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
Expand Down
File renamed without changes.

0 comments on commit 2c8fd2b

Please sign in to comment.