build: remove legacy integration test runner (#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 #35985
This commit is contained in:
parent
99ea5d7044
commit
2b6028b643
|
@ -556,22 +556,6 @@ jobs:
|
|||
- ng/dist/packages-dist-ivy-aot
|
||||
- ng/dist/zone.js-dist-ivy-aot
|
||||
|
||||
# We run a subset of the integration tests outside of Bazel that track
|
||||
# payload size.
|
||||
# See comments inside the integration/run_tests.sh script.
|
||||
# TODO(gregmagolan): move payload size tracking to Bazel and remove this job.
|
||||
integration_test:
|
||||
executor: default-executor
|
||||
parallelism: 3
|
||||
steps:
|
||||
- custom_attach_workspace
|
||||
- init_environment
|
||||
- install_chrome_libs
|
||||
- install_java
|
||||
# Runs the integration tests in parallel across multiple CircleCI container instances. The
|
||||
# amount of container nodes for this job is controlled by the "parallelism" option.
|
||||
- run: ./integration/run_tests.sh ${CIRCLE_NODE_INDEX} ${CIRCLE_NODE_TOTAL}
|
||||
|
||||
# This job creates compressed tarballs (`.tgz` files) for all Angular packages and stores them as
|
||||
# build artifacts. This makes it easy to try out changes from a PR build for testing purposes.
|
||||
# More info CircleCI build artifacts: https://circleci.com/docs/2.0/artifacts
|
||||
|
@ -855,9 +839,6 @@ workflows:
|
|||
- test_aio_preview:
|
||||
requires:
|
||||
- aio_preview
|
||||
- integration_test:
|
||||
requires:
|
||||
- build-npm-packages
|
||||
- publish_packages_as_artifacts:
|
||||
requires:
|
||||
- build-npm-packages
|
||||
|
@ -870,7 +851,6 @@ workflows:
|
|||
# Only publish if tests and integration tests pass
|
||||
- test
|
||||
- test_ivy_aot
|
||||
- integration_test
|
||||
# Only publish if `aio`/`docs` tests using the locally built Angular packages pass
|
||||
- test_aio_local
|
||||
- test_aio_local_viewengine
|
||||
|
|
|
@ -82,6 +82,22 @@ openssl aes-256-cbc -d -in "${projectDir}/.circleci/gcp_token" \
|
|||
####################################################################################################
|
||||
cp "${projectDir}/.circleci/bazel.linux.rc" "$HOME/.bazelrc";
|
||||
|
||||
####################################################################################################
|
||||
# Create shell script in /tmp for Bazel actions to access CI envs without
|
||||
# busting the cache. Used by payload-size.sh script in integration tests.
|
||||
####################################################################################################
|
||||
readonly bazelVarEnv="/tmp/bazel-ci-env.sh"
|
||||
echo "# Setup by /.circle/env.sh" > $bazelVarEnv
|
||||
echo "export PROJECT_ROOT=\"${PROJECT_ROOT}\";" >> $bazelVarEnv
|
||||
echo "export CI_BRANCH=\"${CI_BRANCH}\";" >> $bazelVarEnv
|
||||
echo "export CI_BUILD_URL=\"${CI_BUILD_URL}\";" >> $bazelVarEnv
|
||||
echo "export CI_COMMIT=\"${CI_COMMIT}\";" >> $bazelVarEnv
|
||||
echo "export CI_COMMIT_RANGE=\"${CI_COMMIT_RANGE}\";" >> $bazelVarEnv
|
||||
echo "export CI_PULL_REQUEST=\"${CI_PULL_REQUEST}\";" >> $bazelVarEnv
|
||||
echo "export CI_REPO_NAME=\"${CI_REPO_NAME}\";" >> $bazelVarEnv
|
||||
echo "export CI_REPO_OWNER=\"${CI_REPO_OWNER}\";" >> $bazelVarEnv
|
||||
echo "export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=\"${CI_SECRET_PAYLOAD_FIREBASE_TOKEN}\";" >> $bazelVarEnv
|
||||
|
||||
####################################################################################################
|
||||
####################################################################################################
|
||||
## Source `$BASH_ENV` to make the variables available immediately. ##
|
||||
|
|
|
@ -5,6 +5,9 @@ exports_files([
|
|||
"protractor-perf.conf.js",
|
||||
"karma-js.conf.js",
|
||||
"browser-providers.conf.js",
|
||||
"scripts/ci/track-payload-size.sh",
|
||||
"scripts/ci/payload-size.sh",
|
||||
"scripts/ci/payload-size.js",
|
||||
])
|
||||
|
||||
alias(
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
load(":angular_integration_test.bzl", "angular_integration_test")
|
||||
|
||||
exports_files([
|
||||
"_payload-limits.json",
|
||||
])
|
||||
|
||||
# Some integration ports must be managed manually to be unique and in other
|
||||
# cases the tests are able to select a random free port.
|
||||
#
|
||||
|
@ -24,76 +28,82 @@ load(":angular_integration_test.bzl", "angular_integration_test")
|
|||
# A subset of these tests fail or are not meant to be run with ivy bundles. These are tagged
|
||||
# "no-ivy-aot".
|
||||
INTEGRATION_TESTS = {
|
||||
"bazel": [
|
||||
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
|
||||
# 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",
|
||||
"no-ivy-aot",
|
||||
],
|
||||
"bazel-schematics": [
|
||||
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
|
||||
# as they will complete 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",
|
||||
"no-ivy-aot",
|
||||
],
|
||||
"cli-hello-world": [],
|
||||
"cli-hello-world-ivy-compat": [],
|
||||
"cli-hello-world-ivy-i18n": ["no-ivy-aot"],
|
||||
"cli-hello-world-ivy-minimal": [],
|
||||
"cli-hello-world-lazy": [],
|
||||
"cli-hello-world-lazy-rollup": [],
|
||||
"dynamic-compiler": ["no-ivy-aot"],
|
||||
"hello_world__closure": ["no-ivy-aot"],
|
||||
"i18n": ["no-ivy-aot"],
|
||||
"injectable-def": ["no-ivy-aot"],
|
||||
"ivy-i18n": ["no-ivy-aot"],
|
||||
"language_service_plugin": [],
|
||||
"ng_elements": ["no-ivy-aot"],
|
||||
"ng_elements_schematics": ["no-ivy-aot"],
|
||||
"ng_update": [],
|
||||
"ng_update_migrations": ["no-ivy-aot"],
|
||||
"ngcc": ["no-ivy-aot"],
|
||||
"platform-server": ["no-ivy-aot"],
|
||||
"service-worker-schema": [],
|
||||
"side-effects": ["no-ivy-aot"],
|
||||
"terser": [],
|
||||
"bazel": {
|
||||
"tags": [
|
||||
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
|
||||
# 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",
|
||||
"no-ivy-aot",
|
||||
],
|
||||
},
|
||||
"bazel-schematics": {
|
||||
"tags": [
|
||||
# Bazel-in-bazel tests are resource intensive and should not be over-parallized
|
||||
# as they will complete 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",
|
||||
"no-ivy-aot",
|
||||
],
|
||||
},
|
||||
"cli-hello-world": {"commands": "payload_size_tracking"},
|
||||
"cli-hello-world-ivy-compat": {"commands": "payload_size_tracking"},
|
||||
"cli-hello-world-ivy-i18n": {
|
||||
"commands": "payload_size_tracking",
|
||||
"tags": ["no-ivy-aot"],
|
||||
},
|
||||
"cli-hello-world-ivy-minimal": {"commands": "payload_size_tracking"},
|
||||
"cli-hello-world-lazy": {
|
||||
"commands": "payload_size_tracking",
|
||||
# TODO: cli-hello-world-lazy fails on a bundle size check with Ivy bundles
|
||||
"tags": ["no-ivy-aot"],
|
||||
},
|
||||
"cli-hello-world-lazy-rollup": {"commands": "payload_size_tracking"},
|
||||
"dynamic-compiler": {"tags": ["no-ivy-aot"]},
|
||||
"hello_world__closure": {
|
||||
"commands": "payload_size_tracking",
|
||||
"tags": ["no-ivy-aot"],
|
||||
},
|
||||
"hello_world__systemjs_umd": {
|
||||
# Special case for `hello_world__systemjs_umd` test as we want to pin
|
||||
# `systems` at version 0.20.2 and not link to the the root @npm//systemjs
|
||||
# which is stuck at 0.18.10 and can't be updated to 0.20.2 without
|
||||
# breaking the legacy saucelabs job.
|
||||
"pinned_npm_packages": ["systemjs"],
|
||||
},
|
||||
"i18n": {"tags": ["no-ivy-aot"]},
|
||||
"injectable-def": {"tags": ["no-ivy-aot"]},
|
||||
"ivy-i18n": {"tags": ["no-ivy-aot"]},
|
||||
"language_service_plugin": {},
|
||||
"ng_elements": {"tags": ["no-ivy-aot"]},
|
||||
"ng_elements_schematics": {"tags": ["no-ivy-aot"]},
|
||||
"ng_update": {},
|
||||
"ng_update_migrations": {"tags": ["no-ivy-aot"]},
|
||||
"ngcc": {"tags": ["no-ivy-aot"]},
|
||||
"platform-server": {"tags": ["no-ivy-aot"]},
|
||||
"service-worker-schema": {},
|
||||
"side-effects": {"tags": ["no-ivy-aot"]},
|
||||
"terser": {},
|
||||
"typings_test_ts36": {
|
||||
# Special case for `typings_test_ts36` test as we want to pin
|
||||
# `typescript` at version 3.6.x for that test and not link to the
|
||||
# root @npm//typescript package.
|
||||
"pinned_npm_packages": ["typescript"],
|
||||
},
|
||||
"typings_test_ts37": {
|
||||
# Special case for `typings_test_ts37` test as we want to pin
|
||||
# `typescript` at version 3.7.x for that test and not link to the
|
||||
# root @npm//typescript package.
|
||||
"pinned_npm_packages": ["typescript"],
|
||||
},
|
||||
}
|
||||
|
||||
[
|
||||
angular_integration_test(
|
||||
name = test_folder + "_test",
|
||||
tags = INTEGRATION_TESTS[test_folder],
|
||||
test_folder = test_folder,
|
||||
name = test_folder,
|
||||
commands = INTEGRATION_TESTS[test_folder].get("commands", "default"),
|
||||
pinned_npm_packages = INTEGRATION_TESTS[test_folder].get("pinned_npm_packages", []),
|
||||
tags = INTEGRATION_TESTS[test_folder].get("tags", []),
|
||||
)
|
||||
for test_folder in INTEGRATION_TESTS
|
||||
]
|
||||
|
||||
# Special case for `typings_test_ts36` test as we want to pin
|
||||
# `typescript` at version 3.6.x for that test and not link to the
|
||||
# root @npm//typescript package.
|
||||
angular_integration_test(
|
||||
name = "typings_test_ts36_test",
|
||||
pinned_npm_packages = ["typescript"],
|
||||
test_folder = "typings_test_ts36",
|
||||
)
|
||||
|
||||
# Special case for `typings_test_ts37` test as we want to pin
|
||||
# `typescript` at version 3.7.x for that test and not link to the
|
||||
# root @npm//typescript package.
|
||||
angular_integration_test(
|
||||
name = "typings_test_ts37_test",
|
||||
pinned_npm_packages = ["typescript"],
|
||||
test_folder = "typings_test_ts37",
|
||||
)
|
||||
|
||||
# Special case for `hello_world__systemjs_umd` test as we want to pin
|
||||
# `systems` at version 0.20.2 and not link to the the root @npm//systemjs
|
||||
# which is stuck at 0.18.10 and can't be updated to 0.20.2 without
|
||||
# breaking the legacy saucelabs job.
|
||||
angular_integration_test(
|
||||
name = "hello_world__systemjs_umd_test",
|
||||
pinned_npm_packages = ["systemjs"],
|
||||
test_folder = "hello_world__systemjs_umd",
|
||||
)
|
||||
|
|
|
@ -98,7 +98,7 @@ yarn bazel test //integration:bazel-schematics_test
|
|||
|
||||
When adding a new integration test, follow the steps below to add a bazel test target for the new test.
|
||||
|
||||
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.*
|
||||
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).
|
||||
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
|
||||
3. Add at least the following two entries `.bazelignore` (as they may contain BUILD files)
|
||||
1. `integration/new_test/node_modules`
|
||||
|
|
|
@ -80,35 +80,56 @@ def npm_package_archives():
|
|||
def _npm_package_archive_label(package_name):
|
||||
return package_name.replace("/", "_").replace("@", "") + "_archive"
|
||||
|
||||
def _angular_integration_test(pinned_npm_packages = [], **kwargs):
|
||||
def _angular_integration_test(name, **kwargs):
|
||||
"Set defaults for the npm_integration_test common to the angular repo"
|
||||
commands = kwargs.pop("commands", None)
|
||||
if not commands:
|
||||
# By default run `yarn install` followed by `yarn test` using
|
||||
# the bazel managed hermetic version of yarn inside
|
||||
commands = [
|
||||
# Workaround https://github.com/yarnpkg/yarn/issues/2165
|
||||
# Yarn will cache file://dist URIs and not update Angular code
|
||||
"rm -rf ./.yarn_local_cache",
|
||||
"mkdir .yarn_local_cache",
|
||||
"patch-package-json",
|
||||
"$(rootpath @nodejs//:yarn_bin) install --cache-folder ./.yarn_local_cache",
|
||||
"$(rootpath @nodejs//:yarn_bin) test",
|
||||
"rm -rf ./.yarn_local_cache",
|
||||
payload_size_tracking = kwargs.pop("payload_size_tracking", [])
|
||||
pinned_npm_packages = kwargs.pop("pinned_npm_packages", [])
|
||||
data = [
|
||||
# We need the yarn_bin & yarn_files available at runtime
|
||||
"@nodejs//:yarn_bin",
|
||||
"@nodejs//:yarn_files",
|
||||
]
|
||||
|
||||
# By default run `yarn install` followed by `yarn test` using
|
||||
# the bazel managed hermetic version of yarn inside
|
||||
DEFAULT_COMMANDS = [
|
||||
"patch-package-json",
|
||||
# Workaround https://github.com/yarnpkg/yarn/issues/2165
|
||||
# Yarn will cache file://dist URIs and not update Angular code
|
||||
"rm -rf ./.yarn_local_cache",
|
||||
"mkdir .yarn_local_cache",
|
||||
"$(rootpath @nodejs//:yarn_bin) install --cache-folder ./.yarn_local_cache",
|
||||
"$(rootpath @nodejs//:yarn_bin) test",
|
||||
]
|
||||
|
||||
commands = kwargs.pop("commands", [])
|
||||
if commands == "default":
|
||||
commands = DEFAULT_COMMANDS
|
||||
elif commands == "payload_size_tracking":
|
||||
commands = DEFAULT_COMMANDS + [
|
||||
"$(rootpath @nodejs//:yarn_bin) build",
|
||||
"$(rootpath //:scripts/ci/track-payload-size.sh) %s dist/*.js true ${RUNFILES}/angular/$(rootpath //integration:_payload-limits.json)" % name,
|
||||
]
|
||||
data = data + [
|
||||
"//integration:_payload-limits.json",
|
||||
"//:scripts/ci/track-payload-size.sh",
|
||||
"//:scripts/ci/payload-size.sh",
|
||||
"//:scripts/ci/payload-size.js",
|
||||
]
|
||||
|
||||
# Complete list of npm packages to override in the test's package.json file mapped to
|
||||
# tgz archive to use for the replacement. This is the full list for all integration
|
||||
# tests. Any given integration does not need to use all of these packages.
|
||||
npm_packages = {}
|
||||
for name in NPM_PACKAGE_ARCHIVES:
|
||||
if name not in pinned_npm_packages:
|
||||
npm_packages["@npm//:" + _npm_package_archive_label(name)] = name
|
||||
for name in GENERATED_NPM_PACKAGES:
|
||||
last_segment_name = name if name.find("/") == -1 else name.split("/")[-1]
|
||||
npm_packages["//packages/%s:npm_package_archive" % last_segment_name] = name
|
||||
for pkg in NPM_PACKAGE_ARCHIVES:
|
||||
if pkg not in pinned_npm_packages:
|
||||
npm_packages["@npm//:" + _npm_package_archive_label(pkg)] = pkg
|
||||
for pkg in GENERATED_NPM_PACKAGES:
|
||||
last_segment_name = pkg if pkg.find("/") == -1 else pkg.split("/")[-1]
|
||||
npm_packages["//packages/%s:npm_package_archive" % last_segment_name] = pkg
|
||||
|
||||
npm_integration_test(
|
||||
name = name + "_test",
|
||||
check_npm_packages = GENERATED_NPM_PACKAGES,
|
||||
commands = commands,
|
||||
npm_packages = npm_packages,
|
||||
|
@ -122,11 +143,7 @@ def _angular_integration_test(pinned_npm_packages = [], **kwargs):
|
|||
# Remote doesn't work as it needs network access right now
|
||||
"no-remote-exec",
|
||||
],
|
||||
data = kwargs.pop("data", []) + [
|
||||
# We need the yarn_bin & yarn_files available at runtime
|
||||
"@nodejs//:yarn_bin",
|
||||
"@nodejs//:yarn_files",
|
||||
],
|
||||
data = kwargs.pop("data", []) + data,
|
||||
# 15-minute timeout
|
||||
timeout = "long",
|
||||
# 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):
|
|||
**kwargs
|
||||
)
|
||||
|
||||
def angular_integration_test(name, test_folder, pinned_npm_packages = [], **kwargs):
|
||||
def angular_integration_test(name, **kwargs):
|
||||
"Sets up the integration test target based on the test folder name"
|
||||
native.filegroup(
|
||||
name = "_%s_sources" % name,
|
||||
srcs = native.glob(
|
||||
include = ["%s/**" % test_folder],
|
||||
include = ["%s/**" % name],
|
||||
exclude = [
|
||||
"%s/node_modules/**" % test_folder,
|
||||
"%s/.yarn_local_cache/**" % test_folder,
|
||||
"%s/node_modules/**" % name,
|
||||
"%s/.yarn_local_cache/**" % name,
|
||||
],
|
||||
),
|
||||
)
|
||||
_angular_integration_test(
|
||||
name = name,
|
||||
test_files = kwargs.pop("test_files", "_%s_sources" % name),
|
||||
pinned_npm_packages = pinned_npm_packages,
|
||||
**kwargs
|
||||
)
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/*
|
||||
* Script that determines the sharded tests for the current CircleCI container. CircleCI starts
|
||||
* multiple containers if the "parallelism" option has been specified and this script splits up
|
||||
* the integration tests into shards based on the amount of parallelism.
|
||||
*
|
||||
* It's also possible to manually specify tests which should run on a container because some
|
||||
* integration tests are more complex and take up more time. In order to properly balance the
|
||||
* duration of each container, we allow manual test shards to be specified.
|
||||
*
|
||||
* The output of this script can then be used to only run the tests which are assigned to the
|
||||
* current CircleCI container.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const minimist = require('minimist');
|
||||
|
||||
// Parsed command line arguments.
|
||||
const {_, shardIndex, maxShards} = minimist(process.argv.slice(2));
|
||||
|
||||
// Ensure that all CLI options are set properly.
|
||||
if (shardIndex == null) {
|
||||
throw new Error('The "--shardIndex" option has not been specified.')
|
||||
} else if (maxShards == null) {
|
||||
throw new Error('The "--maxShards" option has not been specified.');
|
||||
}
|
||||
if (shardIndex >= maxShards) {
|
||||
throw new Error('shardIndex out of bounds');
|
||||
}
|
||||
|
||||
printTestNames(getTestsForShardIndex(_, shardIndex, maxShards));
|
||||
|
||||
/**
|
||||
* Splits the specified tests into a limited amount of shards and returns the tests that should
|
||||
* run on the given shard. The shards of tests are being created deterministically and therefore
|
||||
* we get reproducible tests when executing the same script multiple times.
|
||||
*/
|
||||
function getTestsForShardIndex(tests, shardIndex, maxShards) {
|
||||
return tests.filter((n, index) => index % maxShards === shardIndex);
|
||||
}
|
||||
|
||||
/** Prints the specified test names to the stdout. */
|
||||
function printTestNames(testNames) {
|
||||
// Print the test names joined with spaces because this allows Bash to easily convert the output
|
||||
// of this script into an array.
|
||||
process.stdout.write(testNames.join(' '));
|
||||
}
|
|
@ -30,6 +30,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf",
|
||||
"build": "cd .",
|
||||
"test": "ngc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first",
|
||||
"serve": "lite-server -c e2e/browser.config.json",
|
||||
"preprotractor": "tsc -p e2e",
|
||||
|
|
|
@ -7,41 +7,20 @@ CI=${CI:-false}
|
|||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# basedir is the workspace root
|
||||
readonly basedir=$(pwd)/..
|
||||
|
||||
# Skip all integration tests that are now handled by angular_integration_test except
|
||||
# the tests that are tracked for payload size; these are:
|
||||
# - cli-hello-world*
|
||||
# - hello_world__closure
|
||||
readonly TEST_DIRS=$(find $(ls) -maxdepth 0 -type d \( -name "cli-hello-world*" -or -name "hello_world__closure" \))
|
||||
|
||||
# When running on the CI, we track the payload size of various integration output files. Also
|
||||
# we shard tests across multiple CI job instances. The script needs to be run with a shard index
|
||||
# and the maximum amount of shards available for the integration tests on the CI.
|
||||
# For example: "./run_tests.sh {SHARD_INDEX} {MAX_SHARDS}".
|
||||
if $CI; then
|
||||
source ${basedir}/scripts/ci/payload-size.sh
|
||||
|
||||
readonly SHARD_INDEX=${1:?"No shard index has been specified."}
|
||||
readonly MAX_SHARDS=${2:?"The maximum amount of shards has not been specified."}
|
||||
|
||||
# Determines the tests that need to be run for this shard index.
|
||||
readonly RUN_TESTS=$(node ./get-sharded-tests.js --shardIndex ${SHARD_INDEX} --maxShards ${MAX_SHARDS} ${TEST_DIRS})
|
||||
|
||||
# NB: we don't run build-packages-dist.js because we expect that it was done
|
||||
# by an earlier job in the CircleCI workflow.
|
||||
# If we aren't running on CircleCI, we do not shard tests because this would be the job of
|
||||
# Bazel eventually. For now, we just run all tests sequentially when running locally.
|
||||
if [ -n "${1:-}" ]; then
|
||||
readonly RUN_TESTS=$@
|
||||
else
|
||||
# Not on CircleCI so let's build the packages-dist directory.
|
||||
# This should be fast on incremental re-build.
|
||||
node ${basedir}/scripts/build/build-packages-dist.js
|
||||
|
||||
# If we aren't running on CircleCI, we do not shard tests because this would be the job of
|
||||
# Bazel eventually. For now, we just run all tests sequentially when running locally.
|
||||
readonly RUN_TESTS=${TEST_DIRS}
|
||||
readonly RUN_TESTS=$(find $(ls) -maxdepth 0 -type d)
|
||||
fi
|
||||
|
||||
echo "Running integration tests: ${RUN_TESTS}"
|
||||
echo "Running integration tests:"
|
||||
echo ${RUN_TESTS}
|
||||
|
||||
# Build the packages-dist directory.
|
||||
# This should be fast on incremental re-build.
|
||||
node ../scripts/build/build-packages-dist.js
|
||||
|
||||
# Workaround https://github.com/yarnpkg/yarn/issues/2165
|
||||
# Yarn will cache file://dist URIs and not update Angular code
|
||||
|
@ -73,20 +52,7 @@ for testDir in ${RUN_TESTS}; do
|
|||
yarn install --cache-folder ../$cache
|
||||
yarn test || exit 1
|
||||
|
||||
# Track payload size for cli-hello-world* tests, plus hello_world__closure
|
||||
if $CI && ([[ $testDir =~ cli-hello-world ]] || [[ $testDir == hello_world__closure ]]); then
|
||||
if ([[ $testDir =~ cli-hello-world ]]); then
|
||||
yarn build
|
||||
fi
|
||||
|
||||
trackPayloadSize "$testDir" "dist/*.js" true "${basedir}/integration/_payload-limits.json"
|
||||
fi
|
||||
|
||||
# remove the temporary node modules directory to keep the source folder clean.
|
||||
rm -rf node_modules
|
||||
)
|
||||
done
|
||||
|
||||
if $CI && [[ "$SHARD_INDEX" == "0" ]]; then
|
||||
trackPayloadSize "umd" "../dist/packages-dist/*/bundles/*.umd.min.js" false
|
||||
fi
|
||||
|
|
|
@ -2,6 +2,26 @@
|
|||
|
||||
set -eu -o pipefail
|
||||
|
||||
# statc makes `stat -c` work on both Linux & OSX
|
||||
function statc () {
|
||||
case $(uname) in
|
||||
Darwin*) format='-f%z' ;;
|
||||
*) format='-c%s' ;;
|
||||
esac
|
||||
|
||||
stat ${format} $@
|
||||
}
|
||||
|
||||
# sedr makes `sed -r` work on both Linux & OSX
|
||||
function sedr () {
|
||||
case $(uname) in
|
||||
Darwin*) flag='-E' ;;
|
||||
*) flag='-r' ;;
|
||||
esac
|
||||
|
||||
sed ${flag} "$@"
|
||||
}
|
||||
|
||||
readonly PROJECT_NAME="angular-payload-size"
|
||||
NODE_MODULES_BIN=$PROJECT_ROOT/node_modules/.bin/
|
||||
|
||||
|
@ -15,7 +35,7 @@ getGzipSize() {
|
|||
local size=-1
|
||||
|
||||
gzip -c -$compLevel "$filePath" >> "$compPath"
|
||||
size=$(stat -c%s "$compPath")
|
||||
size=$(statc "$compPath")
|
||||
rm "$compPath"
|
||||
|
||||
echo $size
|
||||
|
@ -26,7 +46,7 @@ getGzipSize() {
|
|||
calculateSize() {
|
||||
label=$(echo "$filename" | sed "s/.*\///" | sed "s/\..*//")
|
||||
|
||||
rawSize=$(stat -c%s "$filename")
|
||||
rawSize=$(statc $filename)
|
||||
gzip7Size=$(getGzipSize "$filename" 7)
|
||||
gzip9Size=$(getGzipSize "$filename" 9)
|
||||
|
||||
|
@ -48,7 +68,7 @@ checkSize() {
|
|||
|
||||
# In non-PR builds, `CI_BRANCH` is the branch being built (e.g. `pull/12345`), not the targeted branch.
|
||||
# Thus, PRs will fall back to using the size limits for `master`.
|
||||
node ${PROJECT_ROOT}/scripts/ci/payload-size.js $limitFile $name $CI_BRANCH $CI_COMMIT
|
||||
node ${PROJECT_ROOT}/scripts/ci/payload-size.js $limitFile $name ${CI_BRANCH:-} ${CI_COMMIT:-}
|
||||
}
|
||||
|
||||
# Write timestamp to global variable `$payloadData`.
|
||||
|
@ -75,7 +95,7 @@ addMessage() {
|
|||
# Grab the set of SHAs for the message. This can fail when you force push or do initial build
|
||||
# because $CI_COMMIT_RANGE may contain the previous SHA which will not be in the
|
||||
# force push or commit, hence we default to last commit.
|
||||
message=$(git log --oneline $commitRange -- || git log --oneline -n1)
|
||||
message=$(git --git-dir ${PROJECT_ROOT}/.git log --oneline $commitRange -- || git --git-dir ${PROJECT_ROOT}/.git log --oneline -n1)
|
||||
message=$(echo $message | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
|
||||
payloadData="$payloadData\"message\": \"$message\", "
|
||||
}
|
||||
|
@ -83,7 +103,7 @@ addMessage() {
|
|||
# Convert the current `payloadData` value to a JSON string.
|
||||
# (Basically remove trailing `,` and wrap in `{...}`.)
|
||||
payloadToJson() {
|
||||
echo "{$(sed -r 's|, *$||' <<< $payloadData)}"
|
||||
echo "{$(sedr 's|, *$||' <<< $payloadData)}"
|
||||
}
|
||||
|
||||
# Upload data to firebase database if it's commit, print out data for pull requests.
|
||||
|
@ -123,7 +143,7 @@ trackPayloadSize() {
|
|||
echo "$(payloadToJson)" > /tmp/current.log
|
||||
|
||||
# If this is a non-PR build, upload the data to firebase.
|
||||
if [[ "$CI_PULL_REQUEST" == "false" ]]; then
|
||||
if [[ "${CI_PULL_REQUEST:-}" == "false" ]]; then
|
||||
echo "Uploading data for '$name'..."
|
||||
addTimestamp
|
||||
addBuildUrl $CI_BUILD_URL
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
# Source optional CI environment variables which are sandboxed out
|
||||
# of the environment when running integration tests under Bazel
|
||||
readonly bazelVarEnv="/tmp/bazel-ci-env.sh"
|
||||
if [[ -f "$bazelVarEnv" ]]; then
|
||||
source $bazelVarEnv
|
||||
fi
|
||||
|
||||
# If running locally, at a minimum set PROJECT_ROOT
|
||||
if [[ -z "${PROJECT_ROOT:-}" ]]; then
|
||||
PROJECT_ROOT=$(cd $(dirname $0)/../..; pwd)
|
||||
fi
|
||||
|
||||
source ${PROJECT_ROOT}/scripts/ci/payload-size.sh
|
||||
trackPayloadSize "$@"
|
|
@ -131,6 +131,22 @@ function copyToTmp(files) {
|
|||
tmp.dirSync({keep: KEEP_TMP, unsafeCleanup: !KEEP_TMP}).name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands environment variables in a string of the form ${FOO_BAR}.
|
||||
*/
|
||||
function expandEnv(s) {
|
||||
if (!s) return s;
|
||||
const reg = /\$\{(\w+)\}/g;
|
||||
return s.replace(reg, (matched) => {
|
||||
const varName = matched.substring(2, matched.length - 1);
|
||||
if (process.env.hasOwnProperty(varName)) {
|
||||
return process.env[varName];
|
||||
} else {
|
||||
throw `Failed to expand unbound environment variable '${varName}' in '${s}'`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* TestRunner handles setting up the integration test and executing
|
||||
* the test commands based on the config.
|
||||
|
@ -153,7 +169,7 @@ class TestRunner {
|
|||
// and quoted arguments that contain spaces
|
||||
const split = command.split(' ');
|
||||
let binary = split[0];
|
||||
const args = split.slice(1);
|
||||
const args = split.slice(1).map(a => expandEnv(a));
|
||||
switch (binary) {
|
||||
case 'patch-package-json': {
|
||||
let packageJsonFile = 'package.json';
|
||||
|
|
Loading…
Reference in New Issue