refactor: setup bazel integration test with new integration rule (#44238)

Sets up the Bazel integration test with the new integration rule. This
commit is separate from the other changes because it required some
additional work. i.e.

The test has moved from `integration/bazel` to `integration/<..>/bazel`
where `<..>` is a new Bazel package defining the integration test.

This is necessary because we could not declare the integration test
within the `BUILD.bazel` file actually being part of the nested bazel
workspace. In those cases we can just define it at a higher-level and
use integration test `working_dir` attribute.

PR Close #44238
This commit is contained in:
Paul Gschwendtner 2021-11-20 17:17:23 +01:00 committed by Alex Rickabaugh
parent 64fd824f67
commit 5837fbd357
38 changed files with 42 additions and 56 deletions

View file

@ -9,14 +9,9 @@ aio/content
aio/node_modules
aio/tools/examples/shared/node_modules
packages/bazel/node_modules
integration/bazel/bazel-bazel
integration/bazel/bazel-bin
integration/bazel/bazel-out
integration/bazel/bazel-testlogs
integration/bazel-schematics/demo
# All integration test node_modules folders
integration/bazel/node_modules
integration/bazel-schematics/node_modules
integration/bazel_workspace_tests/bazel_ngtsc_plugin/node_modules
integration/cli-elements-universal/node_modules
integration/cli-hello-world/node_modules
integration/cli-hello-world-ivy-compat/node_modules
@ -29,6 +24,9 @@ integration/hello_world__systemjs_umd/node_modules
integration/i18n/node_modules
integration/injectable-def/node_modules
integration/ivy-i18n/node_modules
integration/ng-add-localize/node_modules
integration/trusted-types/node_modules
integration/forms/node_modules
integration/ng_elements/node_modules
integration/ng_elements_schematics/node_modules
integration/ng_update/node_modules
@ -40,9 +38,9 @@ integration/side-effects/node_modules
integration/terser/node_modules
integration/typings_test_ts36/node_modules
integration/typings_test_ts37/node_modules
# All integration test .yarn_local_cache folders
integration/bazel/.yarn_local_cache
integration/bazel-schematics/.yarn_local_cache
integration/bazel_workspace_tests/bazel_ngtsc_plugin/.yarn_local_cache
integration/cli-elements-universal/.yarn_local_cache
integration/cli-hello-world/.yarn_local_cache
integration/cli-hello-world-ivy-compat/.yarn_local_cache
@ -55,6 +53,9 @@ 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/ng-add-localize/.yarn_local_cache
integration/trusted-types/.yarn_local_cache
integration/forms/.yarn_local_cache
integration/ng_elements/.yarn_local_cache
integration/ng_elements_schematics/.yarn_local_cache
integration/ng_update/.yarn_local_cache
@ -66,29 +67,3 @@ integration/side-effects/.yarn_local_cache
integration/terser/.yarn_local_cache
integration/typings_test_ts36/.yarn_local_cache
integration/typings_test_ts37/.yarn_local_cache
# All integration test NPM_PACKAGE_MANIFEST.json folders
integration/bazel/NPM_PACKAGE_MANIFEST.json
integration/bazel-schematics/NPM_PACKAGE_MANIFEST.json
integration/cli-elements-universal/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-ivy-compat/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-ivy-i18n/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-ivy-minimal/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-lazy/NPM_PACKAGE_MANIFEST.json
integration/dynamic-compiler/NPM_PACKAGE_MANIFEST.json
integration/hello_world__closure/NPM_PACKAGE_MANIFEST.json
integration/hello_world__systemjs_umd/NPM_PACKAGE_MANIFEST.json
integration/i18n/NPM_PACKAGE_MANIFEST.json
integration/injectable-def/NPM_PACKAGE_MANIFEST.json
integration/ivy-i18n/NPM_PACKAGE_MANIFEST.json
integration/ng_elements/NPM_PACKAGE_MANIFEST.json
integration/ng_elements_schematics/NPM_PACKAGE_MANIFEST.json
integration/ng_update/NPM_PACKAGE_MANIFEST.json
integration/ng_update_migrations/NPM_PACKAGE_MANIFEST.json
integration/ngcc/NPM_PACKAGE_MANIFEST.json
integration/platform-server/NPM_PACKAGE_MANIFEST.json
integration/service-worker-schema/NPM_PACKAGE_MANIFEST.json
integration/side-effects/NPM_PACKAGE_MANIFEST.json
integration/terser/NPM_PACKAGE_MANIFEST.json
integration/typings_test_ts36/NPM_PACKAGE_MANIFEST.json
integration/typings_test_ts37/NPM_PACKAGE_MANIFEST.json

View file

@ -71,16 +71,6 @@ 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/tools,integration/bazel/test/e2e
query --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/tools,integration/bazel/test/e2e
##################################
# Remote Build Execution support #
# Turn on these settings with #
@ -140,8 +130,8 @@ build --flag_alias=ng_perf=//packages/compiler-cli:ng_perf
# The nested Bazel integration test workspace should not be analysed as part of
# Skyframe, but should also not be ignored in order to be able to glob for its files.
# TODO: Simplify this once https://github.com/bazelbuild/bazel/issues/12034 is fixed
build --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/test/e2e,integration/bazel/tools,integration/bazel/tools/angular
query --deleted_packages=integration/bazel,integration/bazel/src,integration/bazel/src/hello-world,integration/bazel/test,integration/bazel/test/e2e,integration/bazel/tools,integration/bazel/tools/angular
build --deleted_packages=integration/bazel_workspace_tests/bazel_ngtsc_plugin,integration/bazel_workspace_tests/bazel_ngtsc_plugin/src,integration/bazel_workspace_tests/bazel_ngtsc_plugin/src/hello-world,integration/bazel_workspace_tests/bazel_ngtsc_plugin/test,integration/bazel_workspace_tests/bazel_ngtsc_plugin/test/e2e,integration/bazel_workspace_tests/bazel_ngtsc_plugin/tools,integration/bazel_workspace_tests/bazel_ngtsc_plugin/tools/angular
query --deleted_packages=integration/bazel_workspace_tests/bazel_ngtsc_plugin,integration/bazel_workspace_tests/bazel_ngtsc_plugin/src,integration/bazel_workspace_tests/bazel_ngtsc_plugin/src/hello-world,integration/bazel_workspace_tests/bazel_ngtsc_plugin/test,integration/bazel_workspace_tests/bazel_ngtsc_plugin/test/e2e,integration/bazel_workspace_tests/bazel_ngtsc_plugin/tools,integration/bazel_workspace_tests/bazel_ngtsc_plugin/tools/angular
####################################################
# User bazel configuration

View file

@ -104,7 +104,7 @@ When adding a new integration test, follow the steps below to add a bazel test t
1. `integration/new_test/node_modules`
2. `integration/new_test/.yarn_local_cache`
4. Add any other untracked folders to `.bazelignore` that may contain `BUILD` files
5. If there are BUILD files in the integration test folder (except for the top-level one defining the test), add those folders to the `--deleted_packages` in the `.bazelrc`. An example is the `bazel` integration test.
5. If there are BUILD files in the integration test folder (except for the top-level one defining the test), add those folders to the `--deleted_packages` in the `.bazelrc`. An example is the `bazel_ngtsc_plugin` test within `//integration/bazel_workspace_tests`.
## Manually configured ports

View file

@ -0,0 +1,23 @@
load("//integration:index.bzl", "ng_integration_test")
package(default_visibility = ["//visibility:public"])
ng_integration_test(
name = "bazel_ngtsc_plugin_test",
srcs = glob(["bazel_ngtsc_plugin/**"]),
environment = {
# Setup a HOME directory so that Bazelisk can work, both Linux/macOS and Windows variants
# are configured to provide a fake home directory so that Bazelisk can download Bazel.
"HOME": "<TMP>",
"LOCALAPPDATA": "<TMP>",
},
tags = [
# Bazel-in-bazel tests are resource intensive and should not be over-parallelized
# as they will compete for the resources of other parallel tests slowing
# everything down. Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
"cpu:3",
],
# Nested bazel workspace tests need to be declared at a higher-level because the test
# cannot be wired up within the `BUILD.bazel` file as part of the actual test workspace.
working_dir = "bazel_ngtsc_plugin/",
)

View file

@ -1,4 +1,4 @@
workspace(name = "bazel_integration_test")
workspace(name = "bazel_ngtsc_plugin")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

View file

@ -49,10 +49,6 @@
"terser": "file:../../node_modules/terser",
"typescript": "file:../../node_modules/typescript"
},
"//resolutions-comment": "Ensure a single version of webdriver-manager which comes from root node_modules that has already run webdriver-manager update",
"resolutions": {
"**/webdriver-manager": "file:../../node_modules/webdriver-manager"
},
"scripts": {
"test": "bazelisk build ... --noshow_progress && bazelisk test ..."
}

View file

@ -2418,7 +2418,7 @@ rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.0:
source-map-resolve "^0.6.0"
"rollup@file:../../node_modules/rollup":
version "2.58.3"
version "2.59.0"
optionalDependencies:
fsevents "~2.3.2"
@ -2811,7 +2811,7 @@ type-is@~1.6.17:
mime-types "~2.1.24"
"typescript@file:../../node_modules/typescript":
version "4.4.3"
version "4.4.4"
typescript@~4.4.2:
version "4.4.4"
@ -2902,8 +2902,10 @@ webdriver-js-extender@2.1.0:
"@types/selenium-webdriver" "^3.0.0"
selenium-webdriver "^3.0.1"
webdriver-manager@^12.1.7, "webdriver-manager@file:../../node_modules/webdriver-manager":
webdriver-manager@^12.1.7:
version "12.1.8"
resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.8.tgz#5e70e73eaaf53a0767d5745270addafbc5905fd4"
integrity sha512-qJR36SXG2VwKugPcdwhaqcLQOD7r8P2Xiv9sfNbfZrKBnX243iAkOueX1yAmeNgIKhJ3YAT/F2gq6IiEZzahsg==
dependencies:
adm-zip "^0.4.9"
chalk "^1.1.1"