Skip to content

build: fix bazel run invocations of js_binary/js_test #30119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ build --action_env=NG_FORCE_TTY=false
# Required by `rules_ts`.
common --@aspect_rules_ts//ts:skipLibCheck=always
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
# TODO: remove this flag once we get to bazel version >7.
common --incompatible_merge_fixed_and_default_shell_env

# Make TypeScript compilation fast, by keeping a few copies of the compiler
# running as daemons, and cache SourceFile AST's to reduce parse time.
Expand Down Expand Up @@ -156,12 +154,8 @@ build:remote-cache --google_default_credentials
# Additional flags added when running a "trusted build" with additional access
build:trusted-build --remote_upload_local_results=true

###############################
# NodeJS rules settings
# These settings are required for rules_nodejs
###############################

# Fixes use of npm paths with spaces such as some within the puppeteer module
# Fixes issues with browser archives and files with spaces. Could be
# removed in Bazel 8 when Bazel runfiles supports spaces.
build --experimental_inprocess_symlink_creation

####################################################
Expand All @@ -172,6 +166,11 @@ build --experimental_inprocess_symlink_creation
# Prevents the npm package extract from occuring or caching on RBE which overwhelms our quota
build --modify_execution_info=NpmPackageExtract=+no-remote

# Allow the Bazel server to check directory sources for changes. `rules_js` previously
# heavily relied on this, but still uses directory "inputs" in some cases.
# See: https://github.com/aspect-build/rules_js/issues/1408.
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1

####################################################
# User bazel configuration
# NOTE: This needs to be the *last* entry in the config.
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.0
7.4.0
2 changes: 1 addition & 1 deletion .github/shared-actions/windows-bazel-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ runs:
# Needed for resolution because Aspect/Bazel looks for repositories at `<workspace>/external`.
# TODO(devversion): consult with Aspect on why this is needed.
(cd $runfiles_dir/angular_cli && ${{steps.init_wsl.outputs.cmd_path}} /C "mklink /D external ..")
(cd $runfiles_dir/_main && ${{steps.init_wsl.outputs.cmd_path}} /C "mklink /D external ..")
- name: Run tests
# Note: This is Git Bash.
Expand Down
5 changes: 5 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TODO(devversion): Investigate bzlmod and use it where possible.

module(
name = "angular_cli",
)
1,630 changes: 1,630 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,10 @@ rules_angular_step3(
angular_compiler_cli = "//:node_modules/@angular/compiler-cli",
typescript = "//:node_modules/typescript",
)

http_archive(
name = "aspect_rules_rollup",
sha256 = "c4062681968f5dcd3ce01e09e4ba73670c064744a7046211763e17c98ab8396e",
strip_prefix = "rules_rollup-2.0.0",
url = "https://github.com/aspect-build/rules_rollup/releases/download/v2.0.0/rules_rollup-v2.0.0.tar.gz",
)
2 changes: 1 addition & 1 deletion docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ You can find more info about debugging [tests with Bazel in the docs.](https://g

- For a complete list of test targets use the following Bazel query: `pnpm bazel query "tests(//tests/...)"`
- Run a subset of the tests: `pnpm bazel test //tests/legacy-cli:e2e_node22 --config=e2e --test_filter="tests/i18n/ivy-localize-*"`
- Use `bazel run` to debug failing tests debugging: `JS_BINARY__PATCH_NODE_FS=0 pnpm bazel run //tests/legacy-cli:e2e_node22 --config=e2e --test_arg="--glob=tests/basic/aot.ts"`
- Use `bazel run` to debug failing tests debugging: `pnpm bazel run //tests/legacy-cli:e2e_node22 --config=e2e --test_arg="--glob=tests/basic/aot.ts"`
- Provide additional `e2e_runner` options using `--test_arg`: `--test_arg="--package-manager=yarn"`

When running the debug commands, Node will stop and wait for a debugger to attach.
Expand Down
2 changes: 1 addition & 1 deletion scripts/windows-testing/convert-symlinks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const skipDirectories = [
'_windows_amd64/bin/nodejs/node_modules',
];

const workspaceRootPaths = [/.*\.runfiles\/angular_cli\//, /^.*-fastbuild\/bin\//];
const workspaceRootPaths = [/.*\.runfiles\/_main\//, /^.*-fastbuild\/bin\//];

// Copying can be parallelized and doesn't cause any WSL flakiness (no exe is invoked).
const parallelCopyTasks = [];
Expand Down
2 changes: 1 addition & 1 deletion scripts/windows-testing/parallel-executor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function main() {
const maxShards = 4;

const testEntrypoint = path.resolve(runfilesDir, '../', targetName);
const testWorkingDir = path.resolve(runfilesDir, 'angular_cli');
const testWorkingDir = path.resolve(runfilesDir, '_main');
const tasks = [];
const progress = {};

Expand Down
6 changes: 6 additions & 0 deletions tests/legacy-cli/e2e_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createConsoleLogger } from '../../packages/angular_devkit/core/node';
import colors from 'ansi-colors';
import glob from 'fast-glob';
import * as path from 'node:path';
import * as fs from 'node:fs';
import { getGlobalVariable, setGlobalVariable } from './e2e/utils/env';
import { gitClean } from './e2e/utils/git';
import { createNpmRegistry } from './e2e/utils/registry';
Expand Down Expand Up @@ -79,6 +80,11 @@ const argv = {
Number(process.env.TEST_SHARD_INDEX ?? 0)),
};

// Indicate sharding support for Bazel.
if (process.env['TEST_SHARD_STATUS_FILE']) {
fs.writeFileSync(process.env['TEST_SHARD_STATUS_FILE'], '', 'utf8');
}

/**
* Set the error code of the process to 255. This is to ensure that if something forces node
* to exit without finishing properly, the error code will be 255. Right now that code is not used.
Expand Down
19 changes: 0 additions & 19 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("//tools:defaults.bzl", "js_binary")

package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -31,21 +30,3 @@ js_binary(
],
entry_point = "quicktype_runner.js",
)

# TODO(devversion): Improve this by potentially sharing this common block.
copy_file(
name = "copy_worker_js",
src = "@tsc_worker//file",
out = "ts_worker.mjs",
)

js_binary(
name = "vanilla_ts_worker",
data = [
":copy_worker_js",
"//:node_modules/@angular/compiler-cli",
"//:node_modules/typescript",
],
entry_point = ":copy_worker_js",
fixed_args = ["--vanilla-ts"],
)
7 changes: 1 addition & 6 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary")
load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project")
load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test")
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
load("@rules_angular//src/ts_project:index.bzl", _ts_project = "ts_project")
load("//tools:substitutions.bzl", "substitutions")
load("//tools/bazel:npm_package.bzl", _npm_package = "npm_package")

Expand All @@ -24,11 +24,6 @@ def ts_project(
declaration = True,
tsconfig = tsconfig,
visibility = visibility,
# Use the worker from our own Angular rules, as the default worker
# from `rules_ts` is incompatible with TS5+ and abandoned. We need
# worker for efficient, fast DX and avoiding Windows no-sandbox issues.
supports_workers = 1,
tsc_worker = "//tools:vanilla_ts_worker",
deps = deps,
**kwargs
)
Expand Down
Loading