Skip to content

Commit 2b6028b

Browse files
gregmagolanAndrewKushnir
authored andcommitted
build: remove legacy integration test runner (angular#35985)
* integration tests target definitions in integration/BUILD.bazel updated to use a single dict * payload tracking for integration tests updated to work under Bazel * legacy integration_test CI job removed * integration/run_tests.sh script no longer used in CI so it has been updated for running integration tests locally in the legacy way PR Close angular#35985
1 parent 99ea5d7 commit 2b6028b

File tree

12 files changed

+215
-224
lines changed

12 files changed

+215
-224
lines changed

Diff for: .circleci/config.yml

-20
Original file line numberDiff line numberDiff line change
@@ -556,22 +556,6 @@ jobs:
556556
- ng/dist/packages-dist-ivy-aot
557557
- ng/dist/zone.js-dist-ivy-aot
558558

559-
# We run a subset of the integration tests outside of Bazel that track
560-
# payload size.
561-
# See comments inside the integration/run_tests.sh script.
562-
# TODO(gregmagolan): move payload size tracking to Bazel and remove this job.
563-
integration_test:
564-
executor: default-executor
565-
parallelism: 3
566-
steps:
567-
- custom_attach_workspace
568-
- init_environment
569-
- install_chrome_libs
570-
- install_java
571-
# Runs the integration tests in parallel across multiple CircleCI container instances. The
572-
# amount of container nodes for this job is controlled by the "parallelism" option.
573-
- run: ./integration/run_tests.sh ${CIRCLE_NODE_INDEX} ${CIRCLE_NODE_TOTAL}
574-
575559
# This job creates compressed tarballs (`.tgz` files) for all Angular packages and stores them as
576560
# build artifacts. This makes it easy to try out changes from a PR build for testing purposes.
577561
# More info CircleCI build artifacts: https://circleci.com/docs/2.0/artifacts
@@ -855,9 +839,6 @@ workflows:
855839
- test_aio_preview:
856840
requires:
857841
- aio_preview
858-
- integration_test:
859-
requires:
860-
- build-npm-packages
861842
- publish_packages_as_artifacts:
862843
requires:
863844
- build-npm-packages
@@ -870,7 +851,6 @@ workflows:
870851
# Only publish if tests and integration tests pass
871852
- test
872853
- test_ivy_aot
873-
- integration_test
874854
# Only publish if `aio`/`docs` tests using the locally built Angular packages pass
875855
- test_aio_local
876856
- test_aio_local_viewengine

Diff for: .circleci/env.sh

+16
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ openssl aes-256-cbc -d -in "${projectDir}/.circleci/gcp_token" \
8282
####################################################################################################
8383
cp "${projectDir}/.circleci/bazel.linux.rc" "$HOME/.bazelrc";
8484

85+
####################################################################################################
86+
# Create shell script in /tmp for Bazel actions to access CI envs without
87+
# busting the cache. Used by payload-size.sh script in integration tests.
88+
####################################################################################################
89+
readonly bazelVarEnv="/tmp/bazel-ci-env.sh"
90+
echo "# Setup by /.circle/env.sh" > $bazelVarEnv
91+
echo "export PROJECT_ROOT=\"${PROJECT_ROOT}\";" >> $bazelVarEnv
92+
echo "export CI_BRANCH=\"${CI_BRANCH}\";" >> $bazelVarEnv
93+
echo "export CI_BUILD_URL=\"${CI_BUILD_URL}\";" >> $bazelVarEnv
94+
echo "export CI_COMMIT=\"${CI_COMMIT}\";" >> $bazelVarEnv
95+
echo "export CI_COMMIT_RANGE=\"${CI_COMMIT_RANGE}\";" >> $bazelVarEnv
96+
echo "export CI_PULL_REQUEST=\"${CI_PULL_REQUEST}\";" >> $bazelVarEnv
97+
echo "export CI_REPO_NAME=\"${CI_REPO_NAME}\";" >> $bazelVarEnv
98+
echo "export CI_REPO_OWNER=\"${CI_REPO_OWNER}\";" >> $bazelVarEnv
99+
echo "export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=\"${CI_SECRET_PAYLOAD_FIREBASE_TOKEN}\";" >> $bazelVarEnv
100+
85101
####################################################################################################
86102
####################################################################################################
87103
## Source `$BASH_ENV` to make the variables available immediately. ##

Diff for: BUILD.bazel

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ exports_files([
55
"protractor-perf.conf.js",
66
"karma-js.conf.js",
77
"browser-providers.conf.js",
8+
"scripts/ci/track-payload-size.sh",
9+
"scripts/ci/payload-size.sh",
10+
"scripts/ci/payload-size.js",
811
])
912

1013
alias(

Diff for: integration/BUILD.bazel

+76-66
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
load(":angular_integration_test.bzl", "angular_integration_test")
22

3+
exports_files([
4+
"_payload-limits.json",
5+
])
6+
37
# Some integration ports must be managed manually to be unique and in other
48
# cases the tests are able to select a random free port.
59
#
@@ -24,76 +28,82 @@ load(":angular_integration_test.bzl", "angular_integration_test")
2428
# A subset of these tests fail or are not meant to be run with ivy bundles. These are tagged
2529
# "no-ivy-aot".
2630
INTEGRATION_TESTS = {
27-
"bazel": [
28-
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
29-
# as they will compete for the resources of other parallel tests slowing
30-
# everything down. Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
31-
"cpu:3",
32-
"no-ivy-aot",
33-
],
34-
"bazel-schematics": [
35-
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
36-
# as they will complete for the resources of other parallel tests slowing
37-
# everything down. Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
38-
"cpu:3",
39-
"no-ivy-aot",
40-
],
41-
"cli-hello-world": [],
42-
"cli-hello-world-ivy-compat": [],
43-
"cli-hello-world-ivy-i18n": ["no-ivy-aot"],
44-
"cli-hello-world-ivy-minimal": [],
45-
"cli-hello-world-lazy": [],
46-
"cli-hello-world-lazy-rollup": [],
47-
"dynamic-compiler": ["no-ivy-aot"],
48-
"hello_world__closure": ["no-ivy-aot"],
49-
"i18n": ["no-ivy-aot"],
50-
"injectable-def": ["no-ivy-aot"],
51-
"ivy-i18n": ["no-ivy-aot"],
52-
"language_service_plugin": [],
53-
"ng_elements": ["no-ivy-aot"],
54-
"ng_elements_schematics": ["no-ivy-aot"],
55-
"ng_update": [],
56-
"ng_update_migrations": ["no-ivy-aot"],
57-
"ngcc": ["no-ivy-aot"],
58-
"platform-server": ["no-ivy-aot"],
59-
"service-worker-schema": [],
60-
"side-effects": ["no-ivy-aot"],
61-
"terser": [],
31+
"bazel": {
32+
"tags": [
33+
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
34+
# as they will compete for the resources of other parallel tests slowing
35+
# everything down. Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
36+
"cpu:3",
37+
"no-ivy-aot",
38+
],
39+
},
40+
"bazel-schematics": {
41+
"tags": [
42+
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
43+
# as they will complete for the resources of other parallel tests slowing
44+
# everything down. Ask Bazel to allocate multiple CPUs for these tests with "cpu:n" tag.
45+
"cpu:3",
46+
"no-ivy-aot",
47+
],
48+
},
49+
"cli-hello-world": {"commands": "payload_size_tracking"},
50+
"cli-hello-world-ivy-compat": {"commands": "payload_size_tracking"},
51+
"cli-hello-world-ivy-i18n": {
52+
"commands": "payload_size_tracking",
53+
"tags": ["no-ivy-aot"],
54+
},
55+
"cli-hello-world-ivy-minimal": {"commands": "payload_size_tracking"},
56+
"cli-hello-world-lazy": {
57+
"commands": "payload_size_tracking",
58+
# TODO: cli-hello-world-lazy fails on a bundle size check with Ivy bundles
59+
"tags": ["no-ivy-aot"],
60+
},
61+
"cli-hello-world-lazy-rollup": {"commands": "payload_size_tracking"},
62+
"dynamic-compiler": {"tags": ["no-ivy-aot"]},
63+
"hello_world__closure": {
64+
"commands": "payload_size_tracking",
65+
"tags": ["no-ivy-aot"],
66+
},
67+
"hello_world__systemjs_umd": {
68+
# Special case for `hello_world__systemjs_umd` test as we want to pin
69+
# `systems` at version 0.20.2 and not link to the the root @npm//systemjs
70+
# which is stuck at 0.18.10 and can't be updated to 0.20.2 without
71+
# breaking the legacy saucelabs job.
72+
"pinned_npm_packages": ["systemjs"],
73+
},
74+
"i18n": {"tags": ["no-ivy-aot"]},
75+
"injectable-def": {"tags": ["no-ivy-aot"]},
76+
"ivy-i18n": {"tags": ["no-ivy-aot"]},
77+
"language_service_plugin": {},
78+
"ng_elements": {"tags": ["no-ivy-aot"]},
79+
"ng_elements_schematics": {"tags": ["no-ivy-aot"]},
80+
"ng_update": {},
81+
"ng_update_migrations": {"tags": ["no-ivy-aot"]},
82+
"ngcc": {"tags": ["no-ivy-aot"]},
83+
"platform-server": {"tags": ["no-ivy-aot"]},
84+
"service-worker-schema": {},
85+
"side-effects": {"tags": ["no-ivy-aot"]},
86+
"terser": {},
87+
"typings_test_ts36": {
88+
# Special case for `typings_test_ts36` test as we want to pin
89+
# `typescript` at version 3.6.x for that test and not link to the
90+
# root @npm//typescript package.
91+
"pinned_npm_packages": ["typescript"],
92+
},
93+
"typings_test_ts37": {
94+
# Special case for `typings_test_ts37` test as we want to pin
95+
# `typescript` at version 3.7.x for that test and not link to the
96+
# root @npm//typescript package.
97+
"pinned_npm_packages": ["typescript"],
98+
},
6299
}
63100

64101
[
65102
angular_integration_test(
66-
name = test_folder + "_test",
67-
tags = INTEGRATION_TESTS[test_folder],
68-
test_folder = test_folder,
103+
name = test_folder,
104+
commands = INTEGRATION_TESTS[test_folder].get("commands", "default"),
105+
pinned_npm_packages = INTEGRATION_TESTS[test_folder].get("pinned_npm_packages", []),
106+
tags = INTEGRATION_TESTS[test_folder].get("tags", []),
69107
)
70108
for test_folder in INTEGRATION_TESTS
71109
]
72-
73-
# Special case for `typings_test_ts36` test as we want to pin
74-
# `typescript` at version 3.6.x for that test and not link to the
75-
# root @npm//typescript package.
76-
angular_integration_test(
77-
name = "typings_test_ts36_test",
78-
pinned_npm_packages = ["typescript"],
79-
test_folder = "typings_test_ts36",
80-
)
81-
82-
# Special case for `typings_test_ts37` test as we want to pin
83-
# `typescript` at version 3.7.x for that test and not link to the
84-
# root @npm//typescript package.
85-
angular_integration_test(
86-
name = "typings_test_ts37_test",
87-
pinned_npm_packages = ["typescript"],
88-
test_folder = "typings_test_ts37",
89-
)
90-
91-
# Special case for `hello_world__systemjs_umd` test as we want to pin
92-
# `systems` at version 0.20.2 and not link to the the root @npm//systemjs
93-
# which is stuck at 0.18.10 and can't be updated to 0.20.2 without
94-
# breaking the legacy saucelabs job.
95-
angular_integration_test(
96-
name = "hello_world__systemjs_umd_test",
97-
pinned_npm_packages = ["systemjs"],
98-
test_folder = "hello_world__systemjs_umd",
99-
)

Diff for: integration/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ yarn bazel test //integration:bazel-schematics_test
9898

9999
When adding a new integration test, follow the steps below to add a bazel test target for the new test.
100100

101-
1. Add new test to `INTEGRATION_TESTS` object in `/integration/BUILD.bazel` (and tag as `"no-ivy-aot"` if not meant to be run against ivy bundles). *NB: if the test requires any special attribute then make a new angular_integration_test target instead.*
101+
1. Add new test to `INTEGRATION_TESTS` object in `/integration/BUILD.bazel` (and tag as `"no-ivy-aot"` if not meant to be run against ivy bundles).
102102
2. If test requires ports and does not support ethereal ports then make sure the port is unique and add it to the "manually configured ports" comment to document which port it is using
103103
3. Add at least the following two entries `.bazelignore` (as they may contain BUILD files)
104104
1. `integration/new_test/node_modules`

Diff for: integration/angular_integration_test.bzl

+46-30
Original file line numberDiff line numberDiff line change
@@ -80,35 +80,56 @@ def npm_package_archives():
8080
def _npm_package_archive_label(package_name):
8181
return package_name.replace("/", "_").replace("@", "") + "_archive"
8282

83-
def _angular_integration_test(pinned_npm_packages = [], **kwargs):
83+
def _angular_integration_test(name, **kwargs):
8484
"Set defaults for the npm_integration_test common to the angular repo"
85-
commands = kwargs.pop("commands", None)
86-
if not commands:
87-
# By default run `yarn install` followed by `yarn test` using
88-
# the bazel managed hermetic version of yarn inside
89-
commands = [
90-
# Workaround https://github.com/yarnpkg/yarn/issues/2165
91-
# Yarn will cache file://dist URIs and not update Angular code
92-
"rm -rf ./.yarn_local_cache",
93-
"mkdir .yarn_local_cache",
94-
"patch-package-json",
95-
"$(rootpath @nodejs//:yarn_bin) install --cache-folder ./.yarn_local_cache",
96-
"$(rootpath @nodejs//:yarn_bin) test",
97-
"rm -rf ./.yarn_local_cache",
85+
payload_size_tracking = kwargs.pop("payload_size_tracking", [])
86+
pinned_npm_packages = kwargs.pop("pinned_npm_packages", [])
87+
data = [
88+
# We need the yarn_bin & yarn_files available at runtime
89+
"@nodejs//:yarn_bin",
90+
"@nodejs//:yarn_files",
91+
]
92+
93+
# By default run `yarn install` followed by `yarn test` using
94+
# the bazel managed hermetic version of yarn inside
95+
DEFAULT_COMMANDS = [
96+
"patch-package-json",
97+
# Workaround https://github.com/yarnpkg/yarn/issues/2165
98+
# Yarn will cache file://dist URIs and not update Angular code
99+
"rm -rf ./.yarn_local_cache",
100+
"mkdir .yarn_local_cache",
101+
"$(rootpath @nodejs//:yarn_bin) install --cache-folder ./.yarn_local_cache",
102+
"$(rootpath @nodejs//:yarn_bin) test",
103+
]
104+
105+
commands = kwargs.pop("commands", [])
106+
if commands == "default":
107+
commands = DEFAULT_COMMANDS
108+
elif commands == "payload_size_tracking":
109+
commands = DEFAULT_COMMANDS + [
110+
"$(rootpath @nodejs//:yarn_bin) build",
111+
"$(rootpath //:scripts/ci/track-payload-size.sh) %s dist/*.js true ${RUNFILES}/angular/$(rootpath //integration:_payload-limits.json)" % name,
112+
]
113+
data = data + [
114+
"//integration:_payload-limits.json",
115+
"//:scripts/ci/track-payload-size.sh",
116+
"//:scripts/ci/payload-size.sh",
117+
"//:scripts/ci/payload-size.js",
98118
]
99119

100120
# Complete list of npm packages to override in the test's package.json file mapped to
101121
# tgz archive to use for the replacement. This is the full list for all integration
102122
# tests. Any given integration does not need to use all of these packages.
103123
npm_packages = {}
104-
for name in NPM_PACKAGE_ARCHIVES:
105-
if name not in pinned_npm_packages:
106-
npm_packages["@npm//:" + _npm_package_archive_label(name)] = name
107-
for name in GENERATED_NPM_PACKAGES:
108-
last_segment_name = name if name.find("/") == -1 else name.split("/")[-1]
109-
npm_packages["//packages/%s:npm_package_archive" % last_segment_name] = name
124+
for pkg in NPM_PACKAGE_ARCHIVES:
125+
if pkg not in pinned_npm_packages:
126+
npm_packages["@npm//:" + _npm_package_archive_label(pkg)] = pkg
127+
for pkg in GENERATED_NPM_PACKAGES:
128+
last_segment_name = pkg if pkg.find("/") == -1 else pkg.split("/")[-1]
129+
npm_packages["//packages/%s:npm_package_archive" % last_segment_name] = pkg
110130

111131
npm_integration_test(
132+
name = name + "_test",
112133
check_npm_packages = GENERATED_NPM_PACKAGES,
113134
commands = commands,
114135
npm_packages = npm_packages,
@@ -122,11 +143,7 @@ def _angular_integration_test(pinned_npm_packages = [], **kwargs):
122143
# Remote doesn't work as it needs network access right now
123144
"no-remote-exec",
124145
],
125-
data = kwargs.pop("data", []) + [
126-
# We need the yarn_bin & yarn_files available at runtime
127-
"@nodejs//:yarn_bin",
128-
"@nodejs//:yarn_files",
129-
],
146+
data = kwargs.pop("data", []) + data,
130147
# 15-minute timeout
131148
timeout = "long",
132149
# Tells bazel that this test should be allocated a large amount of memory.
@@ -135,21 +152,20 @@ def _angular_integration_test(pinned_npm_packages = [], **kwargs):
135152
**kwargs
136153
)
137154

138-
def angular_integration_test(name, test_folder, pinned_npm_packages = [], **kwargs):
155+
def angular_integration_test(name, **kwargs):
139156
"Sets up the integration test target based on the test folder name"
140157
native.filegroup(
141158
name = "_%s_sources" % name,
142159
srcs = native.glob(
143-
include = ["%s/**" % test_folder],
160+
include = ["%s/**" % name],
144161
exclude = [
145-
"%s/node_modules/**" % test_folder,
146-
"%s/.yarn_local_cache/**" % test_folder,
162+
"%s/node_modules/**" % name,
163+
"%s/.yarn_local_cache/**" % name,
147164
],
148165
),
149166
)
150167
_angular_integration_test(
151168
name = name,
152169
test_files = kwargs.pop("test_files", "_%s_sources" % name),
153-
pinned_npm_packages = pinned_npm_packages,
154170
**kwargs
155171
)

0 commit comments

Comments
 (0)