build: Use Ivy compiler for bazel builds by default (#43862)

Setting the angular_ivy_enabled environment variable to True will default Bazel builds to use the Ivy
compiler rather than defaulting to ViewEngine.

PR Close #43862
This commit is contained in:
Joey Perrott
2021-10-15 13:22:30 -07:00
committed by Andrew Kushnir
parent 9f40d2a0ea
commit 00d801122c
16 changed files with 30 additions and 51 deletions
+2 -3
View File
@@ -84,9 +84,8 @@ query --deleted_packages=integration/bazel,integration/bazel/src,integration/baz
################################ ################################
# Temporary Settings for Ivy # # Temporary Settings for Ivy #
################################ ################################
# To determine if the compiler used should be Ivy instead of ViewEngine, one can use `--config=ivy` # Set the default compiler used for bazel builds to be Ivy.
# on any bazel target. This is a temporary flag until codebase is permanently switched to Ivy. build --define=angular_ivy_enabled=True
build --define=angular_ivy_enabled=False
build:view-engine --define=angular_ivy_enabled=False build:view-engine --define=angular_ivy_enabled=False
build:ivy --define=angular_ivy_enabled=True build:ivy --define=angular_ivy_enabled=True
+6 -6
View File
@@ -358,7 +358,7 @@ jobs:
command: | command: |
yarn bazel run //tools/saucelabs:sauce_service_setup yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)')
yarn bazel test --config=saucelabs ${TESTS} yarn bazel test --config=saucelabs --config=view-engine ${TESTS}
yarn bazel run //tools/saucelabs:sauce_service_stop yarn bazel run //tools/saucelabs:sauce_service_stop
no_output_timeout: 40m no_output_timeout: 40m
- notify_webhook_on_fail: - notify_webhook_on_fail:
@@ -382,7 +382,7 @@ jobs:
command: | command: |
yarn bazel run //tools/saucelabs:sauce_service_setup yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)')
yarn bazel test --config=saucelabs --config=ivy ${TESTS} yarn bazel test --config=saucelabs ${TESTS}
yarn bazel run //tools/saucelabs:sauce_service_stop yarn bazel run //tools/saucelabs:sauce_service_stop
no_output_timeout: 40m no_output_timeout: 40m
- notify_webhook_on_fail: - notify_webhook_on_fail:
@@ -776,11 +776,11 @@ jobs:
- setup_win - setup_win
- run: - run:
name: Build all windows CI targets name: Build all windows CI targets
command: bazel build --build_tag_filters=-ivy-only //packages/compiler-cli/... command: bazel build --config=view-engine --build_tag_filters=-ivy-only //packages/compiler-cli/...
no_output_timeout: 15m no_output_timeout: 15m
- run: - run:
name: Test all windows CI targets name: Test all windows CI targets
command: bazel test --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/... command: bazel test --config=view-engine --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/...
no_output_timeout: 15m no_output_timeout: 15m
test_ivy_aot_win: test_ivy_aot_win:
@@ -789,11 +789,11 @@ jobs:
- setup_win - setup_win
- run: - run:
name: Build all windows CI targets name: Build all windows CI targets
command: bazel build --config=ivy --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/... command: bazel build --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/...
no_output_timeout: 15m no_output_timeout: 15m
- run: - run:
name: Test all windows CI targets name: Test all windows CI targets
command: bazel test --config=ivy --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/... command: bazel test --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/...
no_output_timeout: 15m no_output_timeout: 15m
# Save dependencies to use on subsequent runs. # Save dependencies to use on subsequent runs.
- save_cache: - save_cache:
-3
View File
@@ -39,7 +39,6 @@
"program": "${workspaceFolder}/node_modules/.bin/bazelisk", "program": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test/acceptance", "packages/core/test/acceptance",
"--config=debug" "--config=debug"
], ],
@@ -57,7 +56,6 @@
"program": "${workspaceFolder}/node_modules/.bin/bazelisk", "program": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test/render3", "packages/core/test/render3",
"--config=debug" "--config=debug"
], ],
@@ -75,7 +73,6 @@
"program": "${workspaceFolder}/node_modules/.bin/bazelisk", "program": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test", "packages/core/test",
"--config=debug" "--config=debug"
], ],
-4
View File
@@ -9,7 +9,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk", "command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test", "packages/core/test",
"packages/core/test/acceptance", "packages/core/test/acceptance",
"packages/core/test/render3", "packages/core/test/render3",
@@ -42,7 +41,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk", "command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test/acceptance", "packages/core/test/acceptance",
], ],
"group": "test", "group": "test",
@@ -71,7 +69,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk", "command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test", "packages/core/test",
], ],
"group": "test", "group": "test",
@@ -100,7 +97,6 @@
"command": "${workspaceFolder}/node_modules/.bin/bazelisk", "command": "${workspaceFolder}/node_modules/.bin/bazelisk",
"args": [ "args": [
"test", "test",
"--config=ivy",
"packages/core/test/render3", "packages/core/test/render3",
], ],
"group": "test", "group": "test",
+2 -6
View File
@@ -63,12 +63,8 @@ See also: [`//.bazelrc`](https://github.com/angular/angular/blob/master/.bazelrc
- `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below) - `--config=debug`: build and launch in debug mode (see [debugging](#debugging) instructions below)
- `--test_arg=--node_options=--inspect=9228`: change the inspector port. - `--test_arg=--node_options=--inspect=9228`: change the inspector port.
- `--config=ivy` Enables ivy mode if present, otherwise ViewEngine is used. This switches which compiler is used (ngc or ngtsc) - `--config=view-engine` Enables ViewEngine mode if present, otherwise Ivy is used. This switches which compiler is used (ngc or ngtsc)
- `--config=view-engine` Enables ViewEngine mode if present, currently this the default mode. This switches which compiler is used (ngc or ngtsc)
- `--test_tag_filters=<tag>`: filter tests down to tags defined in the `tag` config of your rules in any given `BUILD.bazel`. - `--test_tag_filters=<tag>`: filter tests down to tags defined in the `tag` config of your rules in any given `BUILD.bazel`.
- `no-ivy-aot`: Useful for excluding build and test targets that are not meant to be executed in Ivy AOT mode (`--config=ivy`).
- `ivy-only`: Useful for excluding all Ivy build and tests targets with `--config=view-engine`.
- `fixme-ivy-aot`: Useful for including/excluding build and test targets that are currently broken in Ivy AOT mode (`--config=ivy`).
### Debugging a Node Test ### Debugging a Node Test
@@ -276,7 +272,7 @@ Require stack:
`bazel run` only works in Bazel Windows with non-test targets. Ensure that you are using `bazel test` instead. `bazel run` only works in Bazel Windows with non-test targets. Ensure that you are using `bazel test` instead.
e.g: `yarn bazel test packages/core/test/bundling/forms:symbol_test --config=ivy` e.g: `yarn bazel test packages/core/test/bundling/forms:symbol_test`
#### mkdir missing #### mkdir missing
If you see the following error:: If you see the following error::
+1 -1
View File
@@ -20,7 +20,7 @@ node ./scripts/ci/update-framework-deps-to-dist-packages.js {COMPONENTS_REPO}/pa
following command: following command:
```bash ```bash
yarn test --deleted_packages=//src/dev-app --config=ivy yarn test --deleted_packages=//src/dev-app
``` ```
### Running tests for individual entry-points ### Running tests for individual entry-points
@@ -19,8 +19,7 @@ import {getComponent, getContext, getDirectiveMetadata, getDirectives, getHostEl
* *
* To see this in action run the following command: * To see this in action run the following command:
* *
* bazel run --config=ivy * bazel run //packages/core/test/bundling/todo:devserver
* //packages/core/test/bundling/todo:devserver
* *
* Then load `localhost:5432` and start using the console tools. * Then load `localhost:5432` and start using the console tools.
*/ */
+6 -6
View File
@@ -6,12 +6,12 @@ This is asserted by keeping gold files of all symbols which are expected to be r
When doing renaming it is often necessary to update the gold files, to do so use these commands: When doing renaming it is often necessary to update the gold files, to do so use these commands:
``` ```
yarn bazel run --config=ivy //packages/core/test/bundling/injection:symbol_test.accept yarn bazel run //packages/core/test/bundling/injection:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/cyclic_import:symbol_test.accept yarn bazel run //packages/core/test/bundling/cyclic_import:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/forms:symbol_test.accept yarn bazel run //packages/core/test/bundling/forms:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/hello_world:symbol_test.accept yarn bazel run //packages/core/test/bundling/hello_world:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/router:symbol_test.accept yarn bazel run //packages/core/test/bundling/router:symbol_test.accept
yarn bazel run --config=ivy //packages/core/test/bundling/todo:symbol_test.accept yarn bazel run //packages/core/test/bundling/todo:symbol_test.accept
``` ```
## Running all symbol tests ## Running all symbol tests
@@ -28,9 +28,6 @@ ng_rollup_bundle(
js_size_tracking_test( js_size_tracking_test(
name = "size_test", name = "size_test",
src = "angular/packages/core/test/bundling/core_all/bundle.min.js", src = "angular/packages/core/test/bundling/core_all/bundle.min.js",
# Ensures that this target runs with "--config=ivy" (aka Ivy). This is necessary
# because we don't run this test on CI currently, but if we run it manually, we need to
# ensure that it runs with Ivy for proper size comparisons.
angular_ivy_enabled = "True", angular_ivy_enabled = "True",
data = [ data = [
"bundle.golden_size_map_ivy.json", "bundle.golden_size_map_ivy.json",
+4 -4
View File
@@ -1,7 +1,7 @@
### Build ### Build
``` ```
yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}_lib.min_debug.js --config=ivy yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}_lib.min_debug.js
``` ```
### Run ### Run
@@ -72,15 +72,15 @@ The resulting output should look something like this:
### Notes ### Notes
To run the benchmark use `bazel run <benchmark_target>`, example: To run the benchmark use `bazel run <benchmark_target>`, example:
- `yarn bazel run --config=ivy //packages/core/test/render3/perf:noop_change_detection` - `yarn bazel run //packages/core/test/render3/perf:noop_change_detection`
To profile, append `_profile` to the target name and attach a debugger via chrome://inspect, example: To profile, append `_profile` to the target name and attach a debugger via chrome://inspect, example:
- `yarn bazel run --config=ivy //packages/core/test/render3/perf:noop_change_detection_profile` - `yarn bazel run //packages/core/test/render3/perf:noop_change_detection_profile`
To interactively edit/rerun benchmarks use `ibazel` instead of `bazel`. To interactively edit/rerun benchmarks use `ibazel` instead of `bazel`.
To debug To debug
- Follow the directions in `profile_in_browser.html` - Follow the directions in `profile_in_browser.html`
OR OR
- `yarn bazel build --config=ivy //packages/core/test/render3/perf:noop_change_detection` - `yarn bazel build //packages/core/test/render3/perf:noop_change_detection`
- `node --inspect-brk bazel-out/darwin-fastbuild/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.js` - `node --inspect-brk bazel-out/darwin-fastbuild/bin/packages/core/test/render3/perf/noop_change_detection.min_debug.js`
@@ -29,7 +29,7 @@ const profileTests =
// build tests // build tests
shell.exec( shell.exec(
`yarn bazel build --config=ivy ` + `yarn bazel build ` +
profileTests.map((name) => `//packages/core/test/render3/perf:${name}_lib.min_debug.js`) profileTests.map((name) => `//packages/core/test/render3/perf:${name}_lib.min_debug.js`)
.join(' ')); .join(' '));
@@ -9,8 +9,7 @@
<body> <body>
<ol> <ol>
<li>Build the benchmark using <tt>yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.js <li>Build the benchmark using <tt>yarn bazel build //packages/core/test/render3/perf:${BENCHMARK}.min_debug.js</tt></li>
--config=ivy</tt></li>
<li>Open this file using the <tt>file://</tt> protocol and add <tt>?benchmark=BENCHMARK</tt> to the URL.</li> <li>Open this file using the <tt>file://</tt> protocol and add <tt>?benchmark=BENCHMARK</tt> to the URL.</li>
<li> <li>
Note: You should likely run this in an incognito browser with the "no-turbo-inlining" flag.<br /> Note: You should likely run this in an incognito browser with the "no-turbo-inlining" flag.<br />
+1 -1
View File
@@ -34,7 +34,7 @@ function buildAngularInMemoryWebApiPackage(destDir) {
console.info(`${scriptPath}:`); console.info(`${scriptPath}:`);
console.info(' Building angular-in-memory-web-api npm package'); console.info(' Building angular-in-memory-web-api npm package');
console.info('##############################'); console.info('##############################');
exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package --config=ivy`); exec(`${bazelCmd} build //packages/misc/angular-in-memory-web-api:npm_package`);
// Create the output directory. // Create the output directory.
const absDestDir = resolve(baseDir, destDir); const absDestDir = resolve(baseDir, destDir);
+1 -2
View File
@@ -92,8 +92,7 @@ function buildTargetPackages(destDir, description, isRelease = false) {
// Use either `--config=snapshot` or `--config=release` so that builds are created with the // Use either `--config=snapshot` or `--config=release` so that builds are created with the
// correct embedded version info. // correct embedded version info.
exec(`${bazelCmd} build --config=${isRelease ? 'release' : 'snapshot'} --config=ivy ${ exec(`${bazelCmd} build --config=${isRelease ? 'release' : 'snapshot'} ${targets.join(' ')}`);
targets.join(' ')}`);
// Create the output directory. // Create the output directory.
const absDestDir = resolve(baseDir, destDir); const absDestDir = resolve(baseDir, destDir);
+3 -5
View File
@@ -29,11 +29,9 @@ yarn bazel run //tools/saucelabs:sauce_service_setup
For example, `packages/core/test:test_web` becomes `packages/core/test:saucelabs_test_web`. For example, `packages/core/test:test_web` becomes `packages/core/test:saucelabs_test_web`.
``` ```
yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs --config=ivy yarn bazel test //packages/core/test:saucelabs_test_web --config=saucelabs
``` ```
Remove the `--config=ivy` if you want to run through View Engine instead.
5. Sauce service log may be tailed or dumped with the following targets: 5. Sauce service log may be tailed or dumped with the following targets:
``` bash ``` bash
@@ -54,7 +52,7 @@ Running all ViewEngine karma tests in Saucelabs:
``` bash ``` bash
yarn bazel run //tools/saucelabs:sauce_service_setup yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)') TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "ivy-only", ...) except attr("tags", "fixme-saucelabs-ve", ...)')
yarn bazel test --config=saucelabs ${TESTS} yarn bazel test --config=saucelabs --config=view-engine ${TESTS}
``` ```
Running all Ivy karma tests in Saucelabs: Running all Ivy karma tests in Saucelabs:
@@ -62,7 +60,7 @@ Running all Ivy karma tests in Saucelabs:
``` bash ``` bash
yarn bazel run //tools/saucelabs:sauce_service_setup yarn bazel run //tools/saucelabs:sauce_service_setup
TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)') TESTS=$(./node_modules/.bin/bazelisk query --output label '(kind(karma_web_test, ...) intersect attr("tags", "saucelabs", ...)) except attr("tags", "no-ivy-aot", ...) except attr("tags", "fixme-saucelabs-ivy", ...)')
yarn bazel test --config=saucelabs --config=ivy ${TESTS} yarn bazel test --config=saucelabs ${TESTS}
``` ```
## Under the hood ## Under the hood
@@ -39,8 +39,7 @@ const ALL_ACCEPT_TARGETS = ALL_TEST_TARGETS.map(test => `${test}.accept`);
function runBazelCommandOnTargets(command, targets, present) { function runBazelCommandOnTargets(command, targets, present) {
for (const target of targets) { for (const target of targets) {
process.stdout.write(`${present}: ${target}`); process.stdout.write(`${present}: ${target}`);
const commandResult = const commandResult = spawnSync('yarn', ['-s', 'bazel', command, target], {encoding: 'utf8'});
spawnSync('yarn', ['-s', 'bazel', command, '--config=ivy', target], {encoding: 'utf8'});
process.stdout.clearLine(); process.stdout.clearLine();
process.stdout.cursorTo(0); process.stdout.cursorTo(0);
if (commandResult.status) { if (commandResult.status) {