diff --git a/.bazelignore b/.bazelignore index 64c85b64d2..bf1b2c45b2 100644 --- a/.bazelignore +++ b/.bazelignore @@ -4,7 +4,57 @@ dist aio/content aio/node_modules aio/tools/examples/shared/node_modules -integration/bazel +integration/bazel/bazel-bazel +integration/bazel/bazel-bin +integration/bazel/bazel-out +integration/bazel/bazel-testlogs +integration/bazel/node_modules +integration/bazel/.yarn_local_cache +integration/bazel-schematics/node_modules +integration/bazel-schematics/.yarn_local_cache integration/bazel-schematics/demo +integration/cli-hello-world/node_modules +integration/cli-hello-world-ivy-compat/node_modules +integration/cli-hello-world-ivy-i18n/node_modules +integration/cli-hello-world-ivy-minimal/node_modules +integration/cli-hello-world-lazy/node_modules +integration/cli-hello-world-lazy-rollup/node_modules +integration/dynamic-compiler/node_modules +integration/hello_world__closure/node_modules +integration/hello_world__systemjs_umd/node_modules +integration/i18n/node_modules +integration/injectable-def/node_modules +integration/ivy-i18n/node_modules +integration/language_service_plugin/node_modules +integration/ng_elements/node_modules +integration/ng_update/node_modules +integration/ng_update_migrations/node_modules +integration/ngcc/node_modules integration/platform-server/node_modules +integration/service-worker-schema/node_modules +integration/side-effects/node_modules +integration/terser/node_modules +integration/typings_test_ts36/node_modules +integration/cli-hello-world/.yarn_local_cache +integration/cli-hello-world-ivy-compat/.yarn_local_cache +integration/cli-hello-world-ivy-i18n/.yarn_local_cache +integration/cli-hello-world-ivy-minimal/.yarn_local_cache +integration/cli-hello-world-lazy/.yarn_local_cache +integration/cli-hello-world-lazy-rollup/.yarn_local_cache +integration/dynamic-compiler/.yarn_local_cache +integration/hello_world__closure/.yarn_local_cache +integration/hello_world__systemjs_umd/.yarn_local_cache +integration/i18n/.yarn_local_cache +integration/injectable-def/.yarn_local_cache +integration/ivy-i18n/.yarn_local_cache +integration/language_service_plugin/.yarn_local_cache +integration/ng_elements/.yarn_local_cache +integration/ng_update/.yarn_local_cache +integration/ng_update_migrations/.yarn_local_cache +integration/ngcc/.yarn_local_cache +integration/platform-server/.yarn_local_cache +integration/service-worker-schema/.yarn_local_cache +integration/side-effects/.yarn_local_cache +integration/terser/.yarn_local_cache +integration/typings_test_ts36/.yarn_local_cache packages/bazel/node_modules diff --git a/.bazelrc b/.bazelrc index c1321d4bf9..d725d60450 100644 --- a/.bazelrc +++ b/.bazelrc @@ -62,6 +62,23 @@ test --test_output=errors # Bazel flags for CircleCI are in /.circleci/bazel.linux.rc and /.circleci/bazel.windows.rc +################################## +# Settings for integration tests # +################################## + +# Trick bazel into treating BUILD files under integration/bazel as being regular files +# This lets us glob() up all the files inside this integration test to make them inputs to tests +# (Note, we cannot use common --deleted_packages because the bazel version command doesn't support it) +build --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/test/e2e +query --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/test/e2e + +# The following environment variables need to be available for certain +# integration tests such as //integration:cli_hello_world_test + +# integration/bazel-schematics uses $CI_CHROMEDRIVER_VERSION_ARG in its postinstall webdriver-manager update +run --action_env=CI_CHROMEDRIVER_VERSION_ARG +test --action_env=CI_CHROMEDRIVER_VERSION_ARG + ################################ # Temporary Settings for Ivy # ################################ @@ -100,7 +117,6 @@ build:remote --javabase=@rbe_ubuntu1604_angular//java:jdk build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 build:remote --crosstool_top=@rbe_ubuntu1604_angular//cc:toolchain -build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 build:remote --extra_toolchains=@rbe_ubuntu1604_angular//config:cc-toolchain build:remote --extra_execution_platforms=//tools:rbe_ubuntu1604-angular build:remote --host_platform=//tools:rbe_ubuntu1604-angular diff --git a/.circleci/config.yml b/.circleci/config.yml index 809ca9935b..e8a7f104bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -285,10 +285,26 @@ jobs: steps: - custom_attach_workspace - init_environment + - install_chrome_libs - run: command: yarn bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only no_output_timeout: 20m + test_integration_bazel: + executor: + # Needed because the //integration:bazel-schematics_test test expect Chrome to be installed + name: browsers-executor + resource_class: xlarge + steps: + - custom_attach_workspace + - init_environment + - run: + # Run "exclusive" and "manual" bazel-in-bazel integration tests in their own CI job + # as they take 8m+ to execute and with bazel running inside bazel they are too + # memory intensive to be run in parallel with other tests so are tagged as "exclusive" + command: yarn bazel test //integration:bazel_test //integration:bazel-schematics_test + no_output_timeout: 20m + # Temporary job to test what will happen when we flip the Ivy flag to true test_ivy_aot: executor: @@ -297,6 +313,7 @@ jobs: steps: - custom_attach_workspace - init_environment + - install_chrome_libs # We need to explicitly specify the --symlink_prefix option because otherwise we would # not be able to easily find the output bin directory when uploading artifacts for size # measurements. @@ -561,7 +578,7 @@ jobs: # of memory. Together with the system under test, this can exhaust the RAM # on a 4G worker so we use a larger machine here too. resource_class: xlarge - parallelism: 4 + parallelism: 3 steps: - custom_attach_workspace - init_environment @@ -807,6 +824,9 @@ workflows: - test: requires: - setup + - test_integration_bazel: + requires: + - setup - test_ivy_aot: requires: - setup diff --git a/.pullapprove.yml b/.pullapprove.yml index 3216d8d283..ead89ac1cc 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -953,6 +953,7 @@ groups: 'tools/ng_rollup_bundle/**', 'tools/ngcontainer/**', 'tools/npm/**', + 'tools/npm_integration_test/**', 'tools/public_api_guard/BUILD.bazel', 'tools/public_api_guard/public_api_guard.bzl', 'tools/pullapprove/**', diff --git a/WORKSPACE b/WORKSPACE index 398346ba1f..e3bc19d202 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -43,8 +43,11 @@ node_repositories( package_json = ["//:package.json"], ) +load("//integration:angular_integration_test.bzl", "npm_package_archives") + yarn_install( name = "npm", + manual_build_file_contents = npm_package_archives(), package_json = "//:package.json", yarn_lock = "//:yarn.lock", ) diff --git a/integration/BUILD.bazel b/integration/BUILD.bazel new file mode 100644 index 0000000000..6be5a1cf1a --- /dev/null +++ b/integration/BUILD.bazel @@ -0,0 +1,222 @@ +load(":angular_integration_test.bzl", "angular_integration_test") + +# Some integration ports must be managed manually to be unique and in other +# cases the tests are able to select a random free port. +# +# Where `ng e2e` is used we pass `ng e2e --port 0` which prompts the cli +# to select a random free port for the the e2e test. The protractor.conf is +# automaticaly updated to use this port. +# +# Karma automatically finds a free port so no effort is needed there. +# +# The manually configured ports are as follows: +# +# TEST PORT CONFIGURATION +# ==== ==== ============= +# dynamic-compiler 4201 /e2e/browser.config.json: "port": 4201 +# hello_world__closure 4202 /e2e/browser.config.json: "port": 4202 +# hello_world__systemjs_umd 4203 /bs-config.e2e.json: "port": 4203 +# i18n 4204 /e2e/browser.config.json: "port": 4204 +# ng_elements 4205 /e2e/browser.config.json: "port": 4205 +# platform-server 4206 /src/server.ts: app.listen(4206,... + +[ + angular_integration_test( + name = test_folder + "_test", + test_folder = test_folder, + ) + for test_folder in [ + "cli-hello-world", + "cli-hello-world-ivy-compat", + "cli-hello-world-ivy-minimal", + "cli-hello-world-lazy", + "cli-hello-world-lazy-rollup", + "language_service_plugin", + "ng_update", + "service-worker-schema", + "terser", + ] +] + +# The following tests should not be run with npm packages generated with `--config=ivy` +[ + angular_integration_test( + name = test_folder + "_test", + tags = ["no-ivy-aot"], + test_folder = test_folder, + ) + for test_folder in [ + # `injectable-def` has .ngfactory imports: + # ``` + # FAIL: Expected 'ngcc' to add build marker for 'esm2015' in '@angular/common'. + # ``` + # as it is not expecting the @angular bundles to be generated with `--define=compile=aot` + "injectable-def", + # `ngcc` fails with: + # ``` + # + ngc -p tsconfig-app.json + # src/main.ts(5,34): error TS2307: Cannot find module './app.ngfactory'. + # Error during template compile of 'AppModule' + # Function calls are not supported in decorators but 'BrowserModule' was called. + # ``` + "ngcc", + # `ng_update_migrations` has golden tests failures such as: + # ``` + # ✘ File "src/app/migration-tests/undecorated-derived-classes.ts" does not match the expected output. + # -------------------------------------------- + # --- src/app/migration-tests/undecorated-derived-classes.ts Expected content + # +++ src/app/migration-tests/undecorated-derived-classes.ts Actual content + # @@ -1,50 +1,19 @@ + # -import { Directive, NgModule, NgZone, Component } from '@angular/core'; + # -import { CheckboxControlValueAccessor, NG_VALUE_ACCESSOR, NG_ASYNC_VALIDATORS } from '@angular/forms'; + # -import { BaseComponentFromOtherFile, hostBindings } from './base-component'; + # +import {Directive, NgModule, NgZone} from '@angular/core'; + # +import {CheckboxControlValueAccessor} from '@angular/forms'; + # +import {BaseComponentFromOtherFile} from './base-component'; + # ``` + "ng_update_migrations", + # `i18n` has .ngfactory imports: + # ``` + # $ ngc && yarn run closure && concurrently "yarn run serve" "yarn run protractor" --kill-others --success first && npm run test-locale-folder + # src/main.ts(2,34): error TS2307: Cannot find module './app.ngfactory'. + # Unexpected value 'BrowserModule in /private/var/folders/0l/nj_q9kzj49gdz1w6f5v9tw3h0000gn/T/tmp-58883IJeiUMLGHRRQ/node_modules/@angular/platform-browser/src/browser.d.ts' imported by the module 'AppModule in /private/var/folders/0l/nj_q9kzj49gdz1w6f5v9tw3h0000gn/T/tmp-58883IJeiUMLGHRRQ/src/app.ts'. Please add a @NgModule annotation. + # ``` + "i18n", + # `ivy-i18n` fails with: + # ``` + # ERROR in Unexpected value 'BrowserModule in /private/var/folders/0l/nj_q9kzj49gdz1w6f5v9tw3h0000gn/T/tmp-59999cYHm5rQoUk0v/node_modules/@angular/platform-browser/src/browser.d.ts' imported by the module 'AppModule in /private/var/folders/0l/nj_q9kzj49gdz1w6f5v9tw3h0000gn/T/tmp-59999cYHm5rQoUk0v/src/app/app.module.ts'. Please add a @NgModule annotation. + # @angular/core/src/i18n/tokens.ts(31,22): Error during template compile of 'LOCALE_ID' + # Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler. + # Can't resolve all parameters for AppComponent in /private/var/folders/0l/nj_q9kzj49gdz1w6f5v9tw3h0000gn/T/tmp-59999cYHm5rQoUk0v/src/app/app.component.ts: (?). + # The pipe 'percent' could not be found (" + # + #

{{ locale }}

+ #

{{ [ERROR ->]1 | percent }} awesome

+ #

{{ jan | date : 'LLLL' }}

+ #

Here are some links to help") + # The pipe 'date' could not be found (" + #

{{ locale }}

+ #

{{ 1 | percent }} awesome

+ #

{{ [ERROR ->]jan | date : 'LLLL' }}

+ #

Here are some links to help you start:

+ #