2017-07-13 15:16:02 -04:00
# Configuration file for https://circleci.com/gh/angular/angular
# Note: YAML anchors allow an object to be re-used, reducing duplication.
# The ampersand declares an alias for an object, then later the `<<: *name`
# syntax dereferences it.
2020-11-16 16:37:09 -05:00
# See https://blog.daemonl.com/2016/02/yaml.html
2017-07-13 15:16:02 -04:00
# To validate changes, use an online parser, eg.
2020-11-16 16:37:09 -05:00
# https://yaml-online-parser.appspot.com/
2017-07-13 15:16:02 -04:00
2019-09-18 10:23:29 -04:00
# CircleCI configuration version
# Version 2.1 allows for extra config reuse features
# https://circleci.com/docs/2.0/reusing-config/#getting-started-with-config-reuse
version : 2.1
2019-01-31 17:57:26 -05:00
# We don't want to include the current branch name in the cache key because that would prevent
# PRs from being able to restore the cache since the branch names are always different for PRs.
# The cache key should only consist of dynamic values that change whenever something in the
2019-02-04 11:11:26 -05:00
# cache changes. For example:
# 1) yarn lock file changes --> cached "node_modules" are different.
# 2) bazel repository definitions change --> cached bazel repositories are different.
2019-09-18 10:25:23 -04:00
# Windows needs its own cache key because binaries in node_modules are different.
2021-04-26 08:57:48 -04:00
# **NOTE 1 **: In order to avoid the cache from growing indefinitely and causing slow-downs, we invalidate the cache monthly.
# (See https://support.circleci.com/hc/en-us/articles/360012618473-Creating-a-daily-cache.)
# **NOTE 2 **: If you change the cache key prefix, also sync the cache_key_fallback to match.
# **NOTE 3 **: Keep the static part of the cache key as prefix to enable correct fallbacks.
2019-02-05 13:30:26 -05:00
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
2021-07-06 09:39:58 -04:00
var_3 : &cache_key v4-angular-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "aio/yarn.lock" }}
2020-03-17 06:56:22 -04:00
# We invalidate the cache if the Bazel version changes because otherwise the `bazelisk` cache
# folder will contain all previously used versions and ultimately cause the cache restoring to
# be slower due to its growing size.
2021-04-26 08:57:48 -04:00
var_4 : &cache_key_fallback v4-angular-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
2017-12-12 04:23:09 -05:00
2021-04-06 07:11:07 -04:00
# Windows needs its own cache key because binaries in node_modules are different.
2021-07-06 09:39:58 -04:00
var_3_win : &cache_key_win v4-angular-win-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "aio/yarn.lock" }}
2021-04-26 08:57:48 -04:00
var_4_win : &cache_key_win_fallback v4-angular-win-node-14-{{ checksum "month.txt" }}-{{ checksum ".bazelversion" }}
2021-04-06 07:11:07 -04:00
2020-01-22 15:54:16 -05:00
# Cache key for the `components-repo-unit-tests` job. **Note** when updating the SHA in the
# cache keys also update the SHA for the "COMPONENTS_REPO_COMMIT" environment variable.
2021-07-16 13:23:09 -04:00
var_5 : &components_repo_unit_tests_cache_key v1-angular-components-{{ checksum "month.txt" }}-d090617912da8e70aa336aa5b4d804b1b535402e
2021-04-26 08:57:48 -04:00
var_6 : &components_repo_unit_tests_cache_key_fallback v1-angular-components-{{ checksum "month.txt" }}
2019-07-25 10:47:02 -04:00
2019-09-18 11:22:50 -04:00
# Workspace initially persisted by the `setup` job, and then enhanced by `build-npm-packages` and
# `build-ivy-npm-packages`.
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
# https://circleci.com/blog/deep-diving-into-circleci-workspaces/
var_7 : &workspace_location ~/
2018-08-02 00:02:36 -04:00
2019-10-22 07:30:09 -04:00
# Filter to run a job on builds for pull requests only.
var_8 : &only_on_pull_requests
filters :
branches :
only :
- /pull\/\d+/
# Filter to skip a job on builds for pull requests.
var_9 : &skip_on_pull_requests
2019-09-18 11:22:50 -04:00
filters :
branches :
ignore :
2019-10-22 07:30:09 -04:00
- /pull\/\d+/
# Filter to run a job on builds for the master branch only.
var_10 : &only_on_master
filters :
branches :
only :
- master
2019-09-18 11:22:50 -04:00
2021-04-29 06:42:13 -04:00
# Filter to run a job on all releasable branches.
var_11 : &only_release_branches
filters :
branches :
only :
- master
- /\d+\.\d+\.x/
2019-09-18 10:23:29 -04:00
# Executor Definitions
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
# **NOTE 1**: Pin to exact images using an ID (SHA). See https://circleci.com/docs/2.0/circleci-images/#using-a-docker-image-id-to-pin-an-image-to-a-fixed-version.
# (Using the tag in not necessary when pinning by ID, but include it anyway for documentation purposes.)
# **NOTE 2**: If you change the version of the docker images, also change the `cache_key` suffix.
2021-04-01 15:15:44 -04:00
# **NOTE 3**: If you change the version of Node.js provided by the docker images, also update `.devcontainer/recommended-Dockerfile` to match the new version.
2019-09-18 10:23:29 -04:00
executors :
2019-09-26 07:40:28 -04:00
default-executor :
2019-09-18 10:23:29 -04:00
parameters :
resource_class :
type : string
default : medium
docker :
2021-04-12 15:01:58 -04:00
- image : circleci/node:14.16.1@sha256:951e12268fe692615bfd155c327bd910e10c99db98404badd03879f984c32b31
2019-09-18 10:23:29 -04:00
resource_class : << parameters.resource_class >>
working_directory : ~/ng
windows-executor :
working_directory : ~/ng
2020-10-05 18:46:36 -04:00
resource_class : windows.2xlarge
2019-09-18 10:23:29 -04:00
# CircleCI windows VMs do have the GitBash shell available:
# https://github.com/CircleCI-Public/windows-preview-docs#shells
# But in this specific case we really should not use it because Bazel must not be ran from
# GitBash. These issues discuss why:
# https://github.com/bazelbuild/bazel/issues/5751
# https://github.com/bazelbuild/bazel/issues/5724#issuecomment-410194038
# https://github.com/bazelbuild/bazel/issues/6339#issuecomment-441600879
shell : powershell.exe -ExecutionPolicy Bypass
machine :
# Windows preview image that includes the following:
# - Visual Studio 2019 build tools
2021-04-12 15:01:58 -04:00
# - Node 14
2019-09-18 10:23:29 -04:00
# - yarn 1.17
# - Python 3 3.7.4
image : windows-server-2019-vs2019:201908-02
2019-09-18 11:22:50 -04:00
# Command Definitions
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
commands :
custom_attach_workspace :
description : Attach workspace at a predefined location
steps :
- attach_workspace :
at : *workspace_location
2020-01-31 18:50:44 -05:00
# Install shared libs used by Chrome that is either provisioned by
2020-02-07 06:38:58 -05:00
# rules_webtesting or by puppeteer.
2020-01-31 18:50:44 -05:00
install_chrome_libs :
description : Install shared Chrome libs
steps :
- run :
name : Install shared Chrome libs
command : |
sudo apt-get update
# Install GTK+ graphical user interface (libgtk-3-0), advanced linux sound architecture (libasound2)
# and network security service libraries (libnss3) & X11 Screen Saver extension library (libssx1)
2020-06-04 17:38:53 -04:00
# which are dependencies of chrome & needed for karma & protractor headless chrome tests.
2020-01-31 18:50:44 -05:00
# This is a very small install which takes around 7s in comparing to using the full
# circleci/node:x.x.x-browsers image.
sudo apt-get -y install libgtk-3-0 libasound2 libnss3 libxss1
2020-02-11 00:41:28 -05:00
# Install java runtime which is required by some integration tests such as
# //integration:hello_world__closure_test, //integration:i18n_test and
# //integration:ng_elements_test to run the closure compiler
install_java :
description : Install java
steps :
- run :
name : Install java
command : |
sudo apt-get update
# Install java runtime
sudo apt-get install default-jre
2019-12-17 12:05:22 -05:00
# Initializes the CI environment by setting up common environment variables.
init_environment :
2020-01-31 14:26:21 -05:00
description : Initializing environment (setting up variables)
2019-12-17 12:05:22 -05:00
steps :
2020-02-11 17:56:25 -05:00
- run :
name : Set up environment
environment :
2021-04-10 12:30:33 -04:00
CIRCLE_GIT_BASE_REVISION : << pipeline.git.base_revision >>
CIRCLE_GIT_REVISION : << pipeline.git.revision >>
2020-02-11 17:56:25 -05:00
command : ./.circleci/env.sh
2019-10-04 09:02:04 -04:00
- run :
# Configure git as the CircleCI `checkout` command does.
# This is needed because we only checkout on the setup job.
# Add GitHub to known hosts
name : Configure git
command : |
mkdir -p ~/.ssh
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
git config --global gc.auto 0 || true
2019-09-18 11:22:50 -04:00
2020-02-06 08:17:03 -05:00
init_saucelabs_environment :
description : Sets up a domain that resolves to the local host.
steps :
- run :
2020-06-04 17:38:53 -04:00
name : Preparing environment for running tests on Sauce Labs.
2020-02-06 08:17:03 -05:00
command : |
# For SauceLabs jobs, we set up a domain which resolves to the machine which launched
# the tunnel. We do this because devices are sometimes not able to properly resolve
# `localhost` or `127.0.0.1` through the SauceLabs tunnel. Using a domain that does not
# resolve to anything on SauceLabs VMs ensures that such requests are always resolved
# through the tunnel, and resolve to the actual tunnel host machine (i.e. the CircleCI VM).
# More context can be found in: https://github.com/angular/angular/pull/35171.
setPublicVar SAUCE_LOCALHOST_ALIAS_DOMAIN "angular-ci.local"
setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
- run :
# Sets up a local domain in the machine's host file that resolves to the local
2020-06-04 17:38:53 -04:00
# host. This domain is helpful in Sauce Labs tests where devices are not able to
2020-02-06 08:17:03 -05:00
# properly resolve `localhost` or `127.0.0.1` through the sauce-connect tunnel.
name : Setting up alias domain for local host.
command : echo "127.0.0.1 $SAUCE_LOCALHOST_ALIAS_DOMAIN" | sudo tee -a /etc/hosts
2021-04-26 08:57:48 -04:00
save_month_to_file :
description : Store the current year and month in a file, so that it can be used for computing the cache key.
steps :
- run :
name : Save month to file
command : date +%Y-%m > month.txt
2019-09-18 11:41:56 -04:00
# Normally this would be an individual job instead of a command.
2020-06-04 17:38:53 -04:00
# But startup and setup time for each individual windows job are high enough to discourage
2019-09-18 11:41:56 -04:00
# many small jobs, so instead we use a command for setup unless the gain becomes significant.
setup_win :
2019-09-18 11:22:50 -04:00
description : Setup windows node environment
steps :
2020-10-07 16:25:08 -04:00
- checkout
2021-04-26 08:57:48 -04:00
- save_month_to_file
2019-09-18 11:22:50 -04:00
# Install Bazel pre-requisites that aren't in the preconfigured CircleCI Windows VM.
- run : ./.circleci/windows-env.ps1
- run : node --version
- run : yarn --version
2021-04-06 07:11:07 -04:00
- restore_cache :
keys :
- *cache_key_win
- *cache_key_win_fallback
# On Windows `~/` is not resolved when using as a CLI value. `../` results in the same path.
- run : yarn install --frozen-lockfile --non-interactive --cache-folder ../.cache/yarn
2019-09-18 11:22:50 -04:00
2019-09-26 07:40:28 -04:00
notify_webhook_on_fail :
description : Notify a webhook about failure
parameters :
# `webhook_url_env_var` are secret env vars defined in CircleCI project settings.
# The URLs come from https://angular-team.slack.com/apps/A0F7VRE7N-circleci.
webhook_url_env_var :
type : env_var_name
2019-09-18 11:22:50 -04:00
steps :
- run :
when : on_fail
command : |
notificationJson="{\"text\":\":x: \`$CIRCLE_JOB\` job for $CIRCLE_BRANCH branch failed on build $CIRCLE_BUILD_NUM: $CIRCLE_BUILD_URL :scream:\"}"
2019-09-26 07:40:28 -04:00
curl --request POST --header "Content-Type: application/json" --data "$notificationJson" ${<< parameters.webhook_url_env_var >>}
2019-09-18 11:22:50 -04:00
# Job definitions
2019-09-18 12:23:18 -04:00
# Jobs can include parameters that are passed in the workflow job invocation.
# https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs
2017-06-02 20:03:15 -04:00
jobs :
2019-02-22 16:33:53 -05:00
setup :
2019-09-26 07:40:28 -04:00
executor : default-executor
2017-06-02 20:03:15 -04:00
steps :
2019-01-31 09:14:59 -05:00
- checkout
2021-04-26 08:57:48 -04:00
- save_month_to_file
2020-03-23 14:22:57 -04:00
- init_environment
2019-09-18 11:22:50 -04:00
- run :
name : Rebase PR on target branch
# After checkout, rebase on top of target branch.
command : >
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
# User is required for rebase.
git config user.name "angular-ci"
git config user.email "angular-ci"
# Rebase PR on top of target branch.
2020-11-06 15:30:03 -05:00
node .circleci/rebase-pr.js
2019-09-18 11:22:50 -04:00
else
echo "This build is not over a PR, nothing to do."
fi
2019-02-22 12:30:19 -05:00
# This cache is saved in the build-npm-packages so that Bazel cache is also included.
2019-09-18 11:22:50 -04:00
- restore_cache :
keys :
- *cache_key
- *cache_key_fallback
- run :
name : Running Yarn install
2021-04-06 09:15:57 -04:00
command : yarn install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2019-09-18 11:22:50 -04:00
# Yarn's requests sometimes take more than 10mins to complete.
no_output_timeout : 45m
2021-04-06 09:15:57 -04:00
- run : yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2019-02-25 04:19:07 -05:00
# Make the bazel directories and add a file to them if they don't exist already so that
# persist_to_workspace does not fail.
- run : |
if [ ! -d ~/bazel_repository_cache ]; then
mkdir ~/bazel_repository_cache
touch ~/bazel_repository_cache/MARKER
fi
2019-02-22 12:30:19 -05:00
# Persist any changes at this point to be reused by further jobs.
2019-09-18 11:22:50 -04:00
# **NOTE**: To add new content to the workspace, always persist on the same root.
2019-02-22 12:30:19 -05:00
- persist_to_workspace :
2019-09-18 11:22:50 -04:00
root : *workspace_location
2019-02-22 12:30:19 -05:00
paths :
2019-02-25 04:19:07 -05:00
- ./ng
- ./bazel_repository_cache
2019-02-22 12:30:19 -05:00
lint :
2019-09-26 07:40:28 -04:00
executor : default-executor
2019-02-22 12:30:19 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2018-01-25 12:55:27 -05:00
2020-04-20 16:04:08 -04:00
- run : yarn -s tslint
- run : yarn -s ng-dev format changed $CI_GIT_BASE_REVISION --check
2020-03-20 15:24:12 -04:00
- run : yarn -s ts-circular-deps:check
2020-03-30 13:33:37 -04:00
- run : yarn -s ng-dev pullapprove verify
2020-09-30 17:32:19 -04:00
- run : yarn -s ng-dev ngbot verify
2021-03-25 16:30:49 -04:00
- run : yarn -s ng-dev commit-message validate-range $CI_GIT_BASE_REVISION $CI_GIT_REVISION
2017-06-21 00:08:20 -04:00
2018-04-23 14:46:02 -04:00
test :
2019-09-18 10:23:29 -04:00
executor :
2019-09-26 07:40:28 -04:00
name : default-executor
2020-02-07 19:24:19 -05:00
# Now that large integration tests are running locally in parallel (they can't run on RBE yet
# as they require network access for yarn install), this test is running out of memory
# consistently with the xlarge machine.
# TODO: switch back to xlarge once integration tests are running on remote-exec
2020-02-14 20:23:49 -05:00
resource_class : 2xlarge+
2017-06-14 19:38:27 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-04 14:45:40 -05:00
- install_chrome_libs
2020-02-11 00:41:28 -05:00
- install_java
2019-07-25 10:40:05 -04:00
- run :
command : yarn bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only
no_output_timeout : 20m
2017-12-13 12:18:16 -05:00
2018-06-05 14:38:46 -04:00
# Temporary job to test what will happen when we flip the Ivy flag to true
test_ivy_aot :
2019-09-18 10:23:29 -04:00
executor :
2019-09-26 07:40:28 -04:00
name : default-executor
2019-09-18 10:23:29 -04:00
resource_class : xlarge
2018-06-05 14:38:46 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-04 14:45:40 -05:00
- install_chrome_libs
2020-01-17 11:03:07 -05:00
# 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.
2019-07-25 10:40:05 -04:00
- run :
command : yarn test-ivy-aot //... --symlink_prefix=dist/
no_output_timeout : 20m
2018-11-10 05:27:08 -05:00
# Publish bundle artifacts which will be used to calculate the size change. **Note**: Make
# sure that the size plugin from the Angular robot fetches the artifacts from this CircleCI
# job (see .github/angular-robot.yml). Additionally any artifacts need to be stored with the
# following path format: "{projectName}/{context}/{fileName}". This format is necessary
# because otherwise the bot is not able to pick up the artifacts from CircleCI. See:
# https://github.com/angular/github-robot/blob/master/functions/src/plugins/size.ts#L392-L394
- store_artifacts :
path : dist/bin/packages/core/test/bundling/hello_world/bundle.min.js
destination : core/hello_world/bundle
- store_artifacts :
path : dist/bin/packages/core/test/bundling/todo/bundle.min.js
destination : core/todo/bundle
- store_artifacts :
path : dist/bin/packages/core/test/bundling/hello_world/bundle.min.js.br
destination : core/hello_world/bundle.br
- store_artifacts :
path : dist/bin/packages/core/test/bundling/todo/bundle.min.js.br
destination : core/todo/bundle.br
2017-06-14 19:38:27 -04:00
2020-02-24 12:17:32 -05:00
# NOTE: This is currently limited to master builds only. See the `monitoring` configuration.
2019-12-06 10:17:09 -05:00
saucelabs_view_engine :
2019-09-18 10:23:29 -04:00
executor :
2019-09-26 07:40:28 -04:00
name : default-executor
2019-09-18 10:23:29 -04:00
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
# container for this job. This is necessary because we launch a lot of browsers concurrently
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
resource_class : xlarge
2018-12-18 01:09:39 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-06 08:17:03 -05:00
- init_saucelabs_environment
2020-01-13 17:40:21 -05:00
- run :
2020-02-23 20:35:46 -05:00
name : Run Bazel tests on Saucelabs with ViewEngine
2020-01-13 17:40:21 -05:00
# See /tools/saucelabs/README.md for more info
command : |
yarn bazel run //tools/saucelabs:sauce_service_setup
2020-03-17 13:00:16 -04:00
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", ...)')
2020-02-23 20:35:46 -05:00
yarn bazel test --config=saucelabs ${TESTS}
2020-01-13 17:40:21 -05:00
yarn bazel run //tools/saucelabs:sauce_service_stop
2020-02-23 20:35:46 -05:00
no_output_timeout : 40m
2019-09-26 07:40:28 -04:00
- notify_webhook_on_fail :
webhook_url_env_var : SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
2018-12-18 01:09:39 -05:00
2020-02-24 12:17:32 -05:00
# NOTE: This is currently limited to master builds only. See the `monitoring` configuration.
2019-12-06 10:17:09 -05:00
saucelabs_ivy :
executor :
name : default-executor
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
# container for this job. This is necessary because we launch a lot of browsers concurrently
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
resource_class : xlarge
steps :
- custom_attach_workspace
- init_environment
2020-02-06 08:17:03 -05:00
- init_saucelabs_environment
2019-12-06 10:17:09 -05:00
- run :
2020-02-23 20:35:46 -05:00
name : Run Bazel tests on Saucelabs with Ivy
2020-01-13 17:40:21 -05:00
# See /tools/saucelabs/README.md for more info
command : |
yarn bazel run //tools/saucelabs:sauce_service_setup
2020-03-17 13:00:16 -04:00
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", ...)')
2020-02-23 20:35:46 -05:00
yarn bazel test --config=saucelabs --config=ivy ${TESTS}
2020-01-13 17:40:21 -05:00
yarn bazel run //tools/saucelabs:sauce_service_stop
2020-02-23 20:35:46 -05:00
no_output_timeout : 40m
- notify_webhook_on_fail :
webhook_url_env_var : SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
2019-12-06 10:17:09 -05:00
2018-10-25 07:01:24 -04:00
test_aio :
2020-02-07 06:38:58 -05:00
executor : default-executor
2018-10-10 16:55:45 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-07 06:38:58 -05:00
- install_chrome_libs
2018-10-10 16:55:45 -04:00
# Build aio
- run : yarn --cwd aio build --progress=false
# Lint the code
- run : yarn --cwd aio lint
# Run unit tests
2019-02-01 17:13:51 -05:00
- run : yarn --cwd aio test --progress=false --watch=false
2018-10-10 16:55:45 -04:00
# Run e2e tests
2019-02-01 17:13:51 -05:00
- run : yarn --cwd aio e2e --configuration=ci
2019-06-13 17:25:35 -04:00
# Run PWA-score tests
- run : yarn --cwd aio test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE
2019-07-03 19:34:32 -04:00
# Run accessibility tests
- run : yarn --cwd aio test-a11y-score-localhost
2019-06-13 17:25:35 -04:00
# Check the bundle sizes.
- run : yarn --cwd aio payload-size
2018-10-10 16:55:45 -04:00
# Run unit tests for Firebase redirects
- run : yarn --cwd aio redirects-test
2018-10-25 07:01:24 -04:00
deploy_aio :
2020-02-07 06:38:58 -05:00
executor : default-executor
2018-10-25 07:01:24 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-07 06:38:58 -05:00
- install_chrome_libs
2018-10-18 07:49:30 -04:00
# Deploy angular.io to production (if necessary)
2019-04-25 06:59:16 -04:00
- run : setPublicVar_CI_STABLE_BRANCH
2018-10-22 06:06:20 -04:00
- run : yarn --cwd aio deploy-production
2018-10-10 16:55:45 -04:00
test_aio_local :
2020-02-07 06:38:58 -05:00
executor : default-executor
2018-10-10 16:55:45 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-07 06:38:58 -05:00
- install_chrome_libs
2018-10-10 16:55:45 -04:00
# Build aio (with local Angular packages)
2021-04-15 05:03:31 -04:00
- run : yarn --cwd aio build-local-ci
2018-10-10 16:55:45 -04:00
# Run unit tests
2019-02-01 17:13:51 -05:00
- run : yarn --cwd aio test --progress=false --watch=false
2018-10-10 16:55:45 -04:00
# Run e2e tests
2019-02-01 17:13:51 -05:00
- run : yarn --cwd aio e2e --configuration=ci
2019-06-13 17:25:35 -04:00
# Run PWA-score tests
- run : yarn --cwd aio test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE
2019-06-14 06:01:37 -04:00
# Check the bundle sizes.
2021-04-15 05:03:31 -04:00
- run : yarn --cwd aio payload-size aio-local
2021-06-29 11:59:35 -04:00
# Run tests with RxJS v7.
- run : yarn --cwd aio add rxjs@7.1.0
- run : yarn --cwd aio test --progress=false --watch=false
2018-11-05 12:21:27 -05:00
2018-10-10 16:55:45 -04:00
test_aio_tools :
2019-09-26 07:40:28 -04:00
executor : default-executor
2018-10-10 16:55:45 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2018-10-10 16:55:45 -04:00
# Install
2021-04-06 09:15:57 -04:00
- run : yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2018-10-10 16:55:45 -04:00
- run : yarn --cwd aio extract-cli-command-docs
# Run tools tests
- run : yarn --cwd aio tools-test
- run : ./aio/aio-builds-setup/scripts/test.sh
2019-01-06 09:37:55 -05:00
test_docs_examples :
2019-09-18 10:23:29 -04:00
executor :
2020-02-13 09:58:04 -05:00
name : default-executor
2019-09-18 10:23:29 -04:00
resource_class : xlarge
2019-02-26 14:24:04 -05:00
parallelism : 5
2019-02-05 16:20:05 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-13 09:58:04 -05:00
- install_chrome_libs
2019-02-05 16:20:05 -05:00
# Install aio
2021-04-06 09:15:57 -04:00
- run : yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2019-09-18 12:23:18 -04:00
# Run examples tests. The "CIRCLE_NODE_INDEX" will be set if "parallelism" is enabled.
# Since the parallelism is set to "5", there will be five parallel CircleCI containers.
# with either "0", "1", etc as node index. This can be passed to the "--shard" argument.
2021-04-15 05:03:31 -04:00
- run : yarn --cwd aio example-e2e --setup --local --cliSpecsConcurrency=5 --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL}
2021-06-29 11:59:35 -04:00
# Run tests with RxJS v7.
# (Exclude some examples that are not yet compatible with v7.)
- run : yarn --cwd aio/tools/examples/shared add rxjs@7.1.0 && yarn --cwd aio boilerplate:add
- run : yarn --cwd aio example-e2e --cliSpecsConcurrency=5 --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL} --exclude=practical-observable-usage --exclude=upgrade-module --exclude=upgrade-phonecat
2019-02-05 16:20:05 -05:00
2018-10-17 12:19:15 -04:00
# This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`.
2018-05-09 13:54:13 -04:00
aio_preview :
2019-09-26 07:40:28 -04:00
executor : default-executor
2018-05-09 13:54:13 -04:00
environment :
2021-05-14 13:54:35 -04:00
AIO_SNAPSHOT_ARTIFACT_PATH : &aio_preview_artifact_path 'aio/tmp/snapshot.tgz'
2018-05-09 13:54:13 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2018-10-17 12:19:15 -04:00
- run : ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CI_PULL_REQUEST $CI_COMMIT
2018-05-09 13:54:13 -04:00
- store_artifacts :
path : *aio_preview_artifact_path
# The `destination` needs to be kept in synch with the value of
# `AIO_ARTIFACT_PATH` in `aio/aio-builds-setup/Dockerfile`
destination : aio/dist/aio-snapshot.tgz
2018-12-04 08:50:17 -05:00
- run : node ./aio/scripts/create-preview $CIRCLE_BUILD_NUM
2018-05-09 13:54:13 -04:00
2018-10-17 12:19:15 -04:00
# This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`.
2018-08-25 17:40:58 -04:00
test_aio_preview :
2020-02-07 06:38:58 -05:00
executor : default-executor
2018-08-25 17:40:58 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-07 06:38:58 -05:00
- install_chrome_libs
2021-04-06 09:15:57 -04:00
- run : yarn --cwd aio install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2018-08-25 17:40:58 -04:00
- run :
name : Wait for preview and run tests
2018-10-22 06:06:20 -04:00
command : node aio/scripts/test-preview.js $CI_PULL_REQUEST $CI_COMMIT $CI_AIO_MIN_PWA_SCORE
2018-08-25 17:40:58 -04:00
2019-01-14 20:47:39 -05:00
# The `build-npm-packages` tasks exist for backwards-compatibility with old scripts and
# tests that rely on the pre-Bazel `dist/packages-dist` output structure (build.sh).
# Having multiple jobs that independently build in this manner duplicates some work; we build
# the bazel packages more than once. Even though we have a remote cache, these jobs will
# typically run in parallel so up-to-date outputs will not be available at the time the build
2018-04-23 14:46:02 -04:00
# starts.
2019-01-14 20:47:39 -05:00
# Build the view engine npm packages. No new jobs should depend on this.
build-npm-packages :
2019-09-18 10:23:29 -04:00
executor :
2019-09-26 07:40:28 -04:00
name : default-executor
2019-09-18 10:23:29 -04:00
resource_class : xlarge
2018-04-23 14:46:02 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-29 15:25:49 -05:00
- run : node scripts/build/build-packages-dist.js
2018-04-23 14:46:02 -04:00
# Save the npm packages from //packages/... for other workflow jobs to read
- persist_to_workspace :
2019-09-18 11:22:50 -04:00
root : *workspace_location
2018-04-23 14:46:02 -04:00
paths :
2019-02-25 04:19:07 -05:00
- ng/dist/packages-dist
2021-04-05 12:05:54 -04:00
- ng/dist/angular-in-memory-web-api-dist
2019-11-11 10:11:34 -05:00
- ng/dist/zone.js-dist
2019-01-14 20:47:39 -05:00
2019-02-25 04:19:07 -05:00
# Save dependencies and bazel repository cache to use on subsequent runs.
2019-02-06 03:26:36 -05:00
- save_cache :
key : *cache_key
paths :
2021-04-06 09:15:57 -04:00
- ~/.cache/yarn
- ~/bazel_repository_cache
- ~/.cache/bazelisk
2019-02-06 03:26:36 -05:00
2019-01-14 20:47:39 -05:00
# Build the ivy npm packages.
build-ivy-npm-packages :
2019-09-18 10:23:29 -04:00
executor :
2019-09-26 07:40:28 -04:00
name : default-executor
2019-09-18 10:23:29 -04:00
resource_class : xlarge
2019-01-14 20:47:39 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-29 15:25:49 -05:00
- run : node scripts/build/build-ivy-npm-packages.js
2019-01-14 20:47:39 -05:00
# Save the npm packages from //packages/... for other workflow jobs to read
- persist_to_workspace :
2019-09-18 11:22:50 -04:00
root : *workspace_location
2019-01-14 20:47:39 -05:00
paths :
2019-02-25 04:19:07 -05:00
- ng/dist/packages-dist-ivy-aot
2021-04-05 12:05:54 -04:00
- ng/dist/angular-in-memory-web-api-dist-ivy-aot
2020-02-29 14:05:23 -05:00
- ng/dist/zone.js-dist-ivy-aot
2018-04-23 14:46:02 -04:00
2019-10-22 09:57:13 -04:00
# 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
#
# NOTE: Currently, this job only runs for PR builds. See `publish_snapshot` for non-PR builds.
publish_packages_as_artifacts :
executor : default-executor
environment :
2021-05-14 13:54:35 -04:00
AIMWA_PACKAGES_DIR : &aimwa_packages_dir 'dist/angular-in-memory-web-api-dist'
AIMWA_PACKAGES_ARCHIVES_DIR : &aimwa_packages_archives_dir 'dist/angular-in-memory-web-api-dist-archives'
NG_PACKAGES_DIR : &ng_packages_dir 'dist/packages-dist'
NG_PACKAGES_ARCHIVES_DIR : &ng_packages_archives_dir 'dist/packages-dist-archives'
ZONEJS_PACKAGES_DIR : &zonejs_packages_dir 'dist/zone.js-dist'
ZONEJS_PACKAGES_ARCHIVES_DIR : &zonejs_packages_archives_dir 'dist/zone.js-dist-archives'
2019-10-22 09:57:13 -04:00
steps :
- custom_attach_workspace
- init_environment
2019-11-11 09:55:16 -05:00
# Publish `@angular/*` packages.
2019-10-22 09:57:13 -04:00
- run :
2019-11-11 09:55:16 -05:00
name : Create artifacts for @angular/* packages
2019-11-21 07:04:45 -05:00
command : ./scripts/ci/create-package-archives.sh $CI_BRANCH $CI_COMMIT $NG_PACKAGES_DIR $NG_PACKAGES_ARCHIVES_DIR
2019-10-22 09:57:13 -04:00
- store_artifacts :
path : *ng_packages_archives_dir
destination : angular
2021-04-05 12:05:54 -04:00
# Publish the `angular-in-memory-web-api` package.
2019-11-11 09:55:16 -05:00
- run :
2021-04-05 12:05:54 -04:00
name : Create artifacts for the `angular-in-memory-web-api` package
# Need to remove the zone.js.tgz before archive
command : ./scripts/ci/create-package-archives.sh $CI_BRANCH $CI_COMMIT $AIMWA_PACKAGES_DIR $AIMWA_PACKAGES_ARCHIVES_DIR
- store_artifacts :
path : *aimwa_packages_archives_dir
destination : angular-in-memory-web-api
# Publish the `zone.js` package.
- run :
name : Create artifacts for the `zone.js` package
2020-08-31 00:48:41 -04:00
# Need to remove the zone.js.tgz before archive
command : rm -rf $ZONEJS_PACKAGES_DIR/archive && ./scripts/ci/create-package-archives.sh $CI_BRANCH $CI_COMMIT $ZONEJS_PACKAGES_DIR $ZONEJS_PACKAGES_ARCHIVES_DIR
2019-11-11 09:55:16 -05:00
- store_artifacts :
path : *zonejs_packages_archives_dir
destination : zone.js
2019-10-22 09:57:13 -04:00
2018-04-23 14:46:02 -04:00
# This job updates the content of repos like github.com/angular/core-builds
# for every green build on angular/angular.
publish_snapshot :
2019-09-26 07:40:28 -04:00
executor : default-executor
2018-04-23 14:46:02 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2018-04-23 14:46:02 -04:00
# CircleCI has a config setting to force SSH for all github connections
# This is not compatible with our mechanism of using a Personal Access Token
# Clear the global setting
- run : git config --global --unset "url.ssh://git@github.com.insteadof"
2018-04-27 19:21:38 -04:00
- run :
name : Decrypt github credentials
2019-06-17 16:37:27 -04:00
# We need ensure that the same default digest is used for encoding and decoding with
2020-06-04 17:38:53 -04:00
# OpenSSL. OpenSSL versions might have different default digests which can cause
# decryption failures based on the installed OpenSSL version. https://stackoverflow.com/a/39641378/4317734
2019-06-17 16:37:27 -04:00
command : 'openssl aes-256-cbc -d -in .circleci/github_token -md md5 -k "${KEY}" -out ~/.git_credentials'
2018-04-23 14:46:02 -04:00
- run : ./scripts/ci/publish-build-artifacts.sh
2021-05-21 18:28:04 -04:00
aio_misc :
executor : default-executor
steps :
- custom_attach_workspace
- run :
name : Check website provided in contributors.json file
command : yarn node aio/scripts/test-external-urls.js
2019-04-25 06:54:10 -04:00
aio_monitoring_stable :
2020-02-13 09:46:38 -05:00
executor : default-executor
2018-02-27 18:24:07 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-13 09:46:38 -05:00
- install_chrome_libs
2019-04-25 06:59:16 -04:00
- run : setPublicVar_CI_STABLE_BRANCH
- run :
2020-01-24 13:05:04 -05:00
name : Check out `aio/` and yarn from the stable branch
2019-04-25 06:59:16 -04:00
command : |
git fetch origin $CI_STABLE_BRANCH
2020-01-24 13:05:04 -05:00
git checkout --force origin/$CI_STABLE_BRANCH -- aio/ .yarn/ .yarnrc
2020-01-31 14:26:21 -05:00
# Ignore yarn's engines check, because we checked out `aio/package.json` from the stable
# branch and there could be a node version skew, which is acceptable in this monitoring job.
2020-01-29 06:59:52 -05:00
- run : yarn config set ignore-engines true
2018-09-27 09:35:05 -04:00
- run :
2019-04-25 06:54:10 -04:00
name : Run tests against https://angular.io/
command : ./aio/scripts/test-production.sh https://angular.io/ $CI_AIO_MIN_PWA_SCORE
2019-09-26 07:40:28 -04:00
- notify_webhook_on_fail :
webhook_url_env_var : SLACK_CARETAKER_WEBHOOK_URL
- notify_webhook_on_fail :
webhook_url_env_var : SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
2019-04-25 06:54:10 -04:00
aio_monitoring_next :
2020-02-07 06:38:58 -05:00
executor : default-executor
2019-04-25 06:54:10 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-07 06:38:58 -05:00
- install_chrome_libs
2019-04-25 06:54:10 -04:00
- run :
name : Run tests against https://next.angular.io/
command : ./aio/scripts/test-production.sh https://next.angular.io/ $CI_AIO_MIN_PWA_SCORE
2019-09-26 07:40:28 -04:00
- notify_webhook_on_fail :
webhook_url_env_var : SLACK_CARETAKER_WEBHOOK_URL
- notify_webhook_on_fail :
webhook_url_env_var : SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL
2018-02-27 18:24:07 -05:00
2019-01-04 14:58:33 -05:00
legacy-unit-tests-saucelabs :
2019-09-18 10:23:29 -04:00
executor :
2019-09-26 07:40:28 -04:00
name : default-executor
2019-09-18 10:23:29 -04:00
# In order to avoid the bottleneck of having a slow host machine, we acquire a better
# container for this job. This is necessary because we launch a lot of browsers concurrently
# and therefore the tunnel and Karma need to process a lot of file requests and tests.
resource_class : xlarge
2019-01-04 14:58:33 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-02-06 08:17:03 -05:00
- init_saucelabs_environment
2019-01-04 14:58:33 -05:00
- run :
2020-01-13 17:40:21 -05:00
name : Starting Saucelabs tunnel service
command : ./tools/saucelabs/sauce-service.sh run
2019-01-04 14:58:33 -05:00
background : true
fix(core): detect DI parameters in JIT mode for downleveled ES2015 classes (#38463)
In the Angular Package Format, we always shipped UMD bundles and previously even ES5 module output.
With V10, we removed the ES5 module output but kept the UMD ES5 output.
For this, we were able to remove our second TypeScript transpilation. Instead we started only
building ES2015 output and then downleveled it to ES5 UMD for the NPM packages. This worked
as expected but unveiled an issue in the `@angular/core` reflection capabilities.
In JIT mode, Angular determines constructor parameters (for DI) using the `ReflectionCapabilities`. The
reflection capabilities basically read runtime metadata of classes to determine the DI parameters. Such
metadata can be either stored in static class properties like `ctorParameters` or within TypeScript's `design:params`.
If Angular comes across a class that does not have any parameter metadata, it tries to detect if the
given class is actually delegating to an inherited class. It does this naively in JIT by checking if the
stringified class (function in ES5) matches a certain pattern. e.g.
```js
function MatTable() {
var _this = _super.apply(this, arguments) || this;
```
These patterns are reluctant to changes of the class output. If a class is not recognized properly, the
DI parameters will be assumed empty and the class is **incorrectly** constructed without arguments.
This actually happened as part of v10 now. Since we downlevel ES2015 to ES5 (instead of previously
compiling sources directly to ES5), the class output changed slightly so that Angular no longer detects
it. e.g.
```js
var _this = _super.apply(this, __spread(arguments)) || this;
```
This happens because the ES2015 output will receive an auto-generated constructor if the class
defines class properties. This constructor is then already containing an explicit `super` call.
```js
export class MatTable extends CdkTable {
constructor() {
super(...arguments);
this.disabled = true;
}
}
```
If we then downlevel this file to ES5 with `--downlevelIteration`, TypeScript adjusts the `super` call so that
the spread operator is no longer used (not supported in ES5). The resulting super call is different to the
super call that would have been emitted if we would directly transpile to ES5. Ultimately, Angular no
longer detects such classes as having an delegate constructor -> and DI breaks.
We fix this by expanding the rather naive RegExp patterns used for the reflection capabilities
so that downleveled pass-through/delegate constructors are properly detected. There is a risk
of a false-positive as we cannot detect whether `__spread` is actually the TypeScript spread
helper, but given the reflection patterns already make lots of assumptions (e.g. that `super` is
actually the superclass, we should be fine making this assumption too. The false-positive would
not result in a broken app, but rather in unnecessary providers being injected (as a noop).
Fixes #38453
PR Close #38463
2020-08-14 04:23:53 -04:00
# Build test fixtures for a test that rely on Bazel-generated fixtures. Note that disabling
# specific tests which are reliant on such generated fixtures is not an option as SystemJS
# in the Saucelabs legacy job always fetches referenced files, even if the imports would be
# guarded by an check to skip in the Saucelabs legacy job. We should be good running such
# test in all supported browsers on Saucelabs anyway until this job can be removed.
- run :
name : Preparing Bazel-generated fixtures required in legacy tests
command : |
2021-05-22 13:18:31 -04:00
yarn bazel build \
//packages/core/test:downleveled_es5_fixture \
//packages/common/locales
fix(core): detect DI parameters in JIT mode for downleveled ES2015 classes (#38463)
In the Angular Package Format, we always shipped UMD bundles and previously even ES5 module output.
With V10, we removed the ES5 module output but kept the UMD ES5 output.
For this, we were able to remove our second TypeScript transpilation. Instead we started only
building ES2015 output and then downleveled it to ES5 UMD for the NPM packages. This worked
as expected but unveiled an issue in the `@angular/core` reflection capabilities.
In JIT mode, Angular determines constructor parameters (for DI) using the `ReflectionCapabilities`. The
reflection capabilities basically read runtime metadata of classes to determine the DI parameters. Such
metadata can be either stored in static class properties like `ctorParameters` or within TypeScript's `design:params`.
If Angular comes across a class that does not have any parameter metadata, it tries to detect if the
given class is actually delegating to an inherited class. It does this naively in JIT by checking if the
stringified class (function in ES5) matches a certain pattern. e.g.
```js
function MatTable() {
var _this = _super.apply(this, arguments) || this;
```
These patterns are reluctant to changes of the class output. If a class is not recognized properly, the
DI parameters will be assumed empty and the class is **incorrectly** constructed without arguments.
This actually happened as part of v10 now. Since we downlevel ES2015 to ES5 (instead of previously
compiling sources directly to ES5), the class output changed slightly so that Angular no longer detects
it. e.g.
```js
var _this = _super.apply(this, __spread(arguments)) || this;
```
This happens because the ES2015 output will receive an auto-generated constructor if the class
defines class properties. This constructor is then already containing an explicit `super` call.
```js
export class MatTable extends CdkTable {
constructor() {
super(...arguments);
this.disabled = true;
}
}
```
If we then downlevel this file to ES5 with `--downlevelIteration`, TypeScript adjusts the `super` call so that
the spread operator is no longer used (not supported in ES5). The resulting super call is different to the
super call that would have been emitted if we would directly transpile to ES5. Ultimately, Angular no
longer detects such classes as having an delegate constructor -> and DI breaks.
We fix this by expanding the rather naive RegExp patterns used for the reflection capabilities
so that downleveled pass-through/delegate constructors are properly detected. There is a risk
of a false-positive as we cannot detect whether `__spread` is actually the TypeScript spread
helper, but given the reflection patterns already make lots of assumptions (e.g. that `super` is
actually the superclass, we should be fine making this assumption too. The false-positive would
not result in a broken app, but rather in unnecessary providers being injected (as a noop).
Fixes #38453
PR Close #38463
2020-08-14 04:23:53 -04:00
# Needed for the ES5 downlevel reflector test in `packages/core/test/reflection`.
2021-05-22 13:18:31 -04:00
mkdir -p dist/all/@angular/core/test/reflection/
fix(core): detect DI parameters in JIT mode for downleveled ES2015 classes (#38463)
In the Angular Package Format, we always shipped UMD bundles and previously even ES5 module output.
With V10, we removed the ES5 module output but kept the UMD ES5 output.
For this, we were able to remove our second TypeScript transpilation. Instead we started only
building ES2015 output and then downleveled it to ES5 UMD for the NPM packages. This worked
as expected but unveiled an issue in the `@angular/core` reflection capabilities.
In JIT mode, Angular determines constructor parameters (for DI) using the `ReflectionCapabilities`. The
reflection capabilities basically read runtime metadata of classes to determine the DI parameters. Such
metadata can be either stored in static class properties like `ctorParameters` or within TypeScript's `design:params`.
If Angular comes across a class that does not have any parameter metadata, it tries to detect if the
given class is actually delegating to an inherited class. It does this naively in JIT by checking if the
stringified class (function in ES5) matches a certain pattern. e.g.
```js
function MatTable() {
var _this = _super.apply(this, arguments) || this;
```
These patterns are reluctant to changes of the class output. If a class is not recognized properly, the
DI parameters will be assumed empty and the class is **incorrectly** constructed without arguments.
This actually happened as part of v10 now. Since we downlevel ES2015 to ES5 (instead of previously
compiling sources directly to ES5), the class output changed slightly so that Angular no longer detects
it. e.g.
```js
var _this = _super.apply(this, __spread(arguments)) || this;
```
This happens because the ES2015 output will receive an auto-generated constructor if the class
defines class properties. This constructor is then already containing an explicit `super` call.
```js
export class MatTable extends CdkTable {
constructor() {
super(...arguments);
this.disabled = true;
}
}
```
If we then downlevel this file to ES5 with `--downlevelIteration`, TypeScript adjusts the `super` call so that
the spread operator is no longer used (not supported in ES5). The resulting super call is different to the
super call that would have been emitted if we would directly transpile to ES5. Ultimately, Angular no
longer detects such classes as having an delegate constructor -> and DI breaks.
We fix this by expanding the rather naive RegExp patterns used for the reflection capabilities
so that downleveled pass-through/delegate constructors are properly detected. There is a risk
of a false-positive as we cannot detect whether `__spread` is actually the TypeScript spread
helper, but given the reflection patterns already make lots of assumptions (e.g. that `super` is
actually the superclass, we should be fine making this assumption too. The false-positive would
not result in a broken app, but rather in unnecessary providers being injected (as a noop).
Fixes #38453
PR Close #38463
2020-08-14 04:23:53 -04:00
cp dist/bin/packages/core/test/reflection/es5_downleveled_inheritance_fixture.js \
dist/all/@angular/core/test/reflection/es5_downleveled_inheritance_fixture.js
2021-05-22 13:18:31 -04:00
# Locale files are needed for i18n tests running within Saucelabs. These are added
# directly as sources so that the TypeScript compilation of `/packages/tsconfig.json`
# can succeed. Note that the base locale and currencies files are checked-in, so
# we do not need to re-generate those through Bazel.
mkdir -p packages/common/locales/extra
cp dist/bin/packages/common/locales/*.ts packages/common/locales
cp dist/bin/packages/common/locales/extra/*.ts packages/common/locales/extra
# add module umd tsc compile option so the test can work
# properly in the legacy browsers
- run : yarn tsc -p packages/tsconfig-legacy-saucelabs.json --module UMD
- run : yarn tsc -p modules --module UMD
- run : yarn bazel build //packages/zone.js:npm_package
2020-01-13 17:40:21 -05:00
- run :
# Waiting on ready ensures that we don't run tests too early without Saucelabs not being ready.
name : Waiting for Saucelabs tunnel to connect
command : ./tools/saucelabs/sauce-service.sh ready-wait
2020-02-06 08:17:03 -05:00
- run :
name : Running tests on Saucelabs.
command : |
browsers=$(node -e 'console.log(require("./browser-providers.conf").sauceAliases.CI_REQUIRED.join(","))')
yarn karma start ./karma-js.conf.js --single-run --browsers=${browsers}
2020-01-13 17:40:21 -05:00
- run :
name : Stop Saucelabs tunnel service
command : ./tools/saucelabs/sauce-service.sh stop
2019-01-04 14:58:33 -05:00
2020-01-22 15:54:16 -05:00
# Job that runs all unit tests of the `angular/components` repository.
components-repo-unit-tests :
2019-09-18 10:23:29 -04:00
executor :
2020-01-22 15:54:16 -05:00
name : default-executor
2019-09-18 10:23:29 -04:00
resource_class : xlarge
2019-01-14 20:47:39 -05:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2019-07-23 16:54:56 -04:00
# Restore the cache before cloning the repository because the clone script re-uses
# the restored repository if present. This reduces the amount of times the components
# repository needs to be cloned (this is slow and increases based on commits in the repo).
2019-03-18 14:25:19 -04:00
- restore_cache :
keys :
2020-01-22 15:54:16 -05:00
- *components_repo_unit_tests_cache_key
# Whenever the `angular/components` SHA is updated, the cache key will no longer
# match. The fallback cache will still match, and CircleCI will restore the most
# recently cached repository folder. Without the fallback cache, we'd need to download
# the repository from scratch and it would slow down the job. This is because we can't
# clone the repository with reduced `--depth`, but rather need to clone the whole
# repository to be able to support arbitrary SHAs.
- *components_repo_unit_tests_cache_key_fallback
2019-07-23 16:54:56 -04:00
- run :
2021-05-14 13:54:35 -04:00
name : 'Fetching angular/components repository'
2020-01-22 15:54:16 -05:00
command : ./scripts/ci/clone_angular_components_repo.sh
2019-03-18 14:25:19 -04:00
- run :
2020-01-22 15:54:16 -05:00
# Run yarn install to fetch the Bazel binaries as used in the components repo.
name : Installing dependencies.
2021-04-28 09:42:10 -04:00
command : yarn --cwd ${COMPONENTS_REPO_TMP_DIR} install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2019-03-18 14:25:19 -04:00
- save_cache :
2020-01-22 15:54:16 -05:00
key : *components_repo_unit_tests_cache_key
2019-03-18 14:25:19 -04:00
paths :
2020-01-22 15:54:16 -05:00
# Temporary directory must be kept in sync with the `$COMPONENTS_REPO_TMP_DIR` env
# variable. It needs to be hardcoded here, because env variables interpolation is
# not supported.
2021-05-14 13:54:35 -04:00
- '/tmp/angular-components-repo'
2020-01-11 06:35:18 -05:00
- run :
2020-01-22 15:54:16 -05:00
# Updates the `angular/components` `package.json` file to refer to the release output
2021-04-28 09:42:10 -04:00
# inside the `packages-dist` directory.
2021-05-24 11:07:07 -04:00
name : Setting up framework release packages.
command : node scripts/ci/update-framework-deps-to-dist-packages.js ${COMPONENTS_REPO_TMP_DIR}/package.json dist/packages-dist/
2021-04-28 09:42:10 -04:00
- run :
# Run `yarn install` again to install the Angular packages from `packages-dist/` and update the lockfile.
# NOTE: We cannot rely on Bazel to run `yarn install`, because it uses the `--frozen-lockfile` flag and fails.
name : Installing local Angular packages.
command : yarn --cwd ${COMPONENTS_REPO_TMP_DIR} install --non-interactive --cache-folder ~/.cache/yarn
2019-03-20 07:43:20 -04:00
- run :
2021-05-14 13:54:35 -04:00
name : 'Running `angular/components` unit tests'
2020-01-31 18:26:51 -05:00
command : ./scripts/ci/run_angular_components_unit_tests.sh
2019-01-14 20:47:39 -05:00
2019-05-31 11:56:07 -04:00
test_zonejs :
2019-10-14 13:16:13 -04:00
executor :
name : default-executor
resource_class : xlarge
2019-05-31 11:56:07 -04:00
steps :
2019-09-18 11:22:50 -04:00
- custom_attach_workspace
- init_environment
2020-10-03 23:31:14 -04:00
- install_java
2019-05-31 11:56:07 -04:00
# Install
2021-04-06 09:15:57 -04:00
- run : yarn --cwd packages/zone.js install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2019-05-31 11:56:07 -04:00
# Run zone.js tools tests
- run : yarn --cwd packages/zone.js promisetest
- run : yarn --cwd packages/zone.js promisefinallytest
2019-07-18 12:42:23 -04:00
- run : yarn bazel build //packages/zone.js:npm_package &&
2021-04-10 12:30:33 -04:00
cp dist/bin/packages/zone.js/npm_package/bundles/zone-mix.umd.js ./packages/zone.js/test/extra/ &&
cp dist/bin/packages/zone.js/npm_package/bundles/zone-patch-electron.umd.js ./packages/zone.js/test/extra/ &&
cp dist/bin/packages/zone.js/npm_package/bundles/zone.umd.js ./packages/zone.js/build/test/closure/zone.js
2020-09-22 09:52:20 -04:00
- run : yarn --cwd packages/zone.js jest:test
- run : yarn --cwd packages/zone.js jest:nodetest
2020-10-03 23:31:14 -04:00
- run : yarn --cwd packages/zone.js electrontest
- run : yarn --cwd packages/zone.js closuretest
2021-04-06 09:15:57 -04:00
- run : yarn --cwd packages/zone.js/test/typings install --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn
2020-08-26 04:12:04 -04:00
- run : yarn --cwd packages/zone.js/test/typings test
2019-05-31 11:56:07 -04:00
2019-07-25 10:47:02 -04:00
# Windows jobs
# Docs: https://circleci.com/docs/2.0/hello-world-windows/
test_win :
2019-09-18 10:23:29 -04:00
executor : windows-executor
2019-07-25 10:47:02 -04:00
steps :
2019-09-18 11:41:56 -04:00
- setup_win
2019-07-25 10:47:02 -04:00
- run :
2020-10-15 11:58:38 -04:00
name : Build all windows CI targets
2021-07-01 11:49:21 -04:00
command : yarn bazel build --build_tag_filters=-ivy-only //packages/compiler-cli/...
2020-10-15 11:58:38 -04:00
no_output_timeout : 15m
- run :
name : Test all windows CI targets
2021-07-01 11:49:21 -04:00
command : yarn bazel test --test_tag_filters="-ivy-only,-browser:chromium-local" //packages/compiler-cli/...
2020-10-15 11:58:38 -04:00
no_output_timeout : 15m
2019-09-18 11:41:56 -04:00
2019-07-25 10:47:02 -04:00
test_ivy_aot_win :
2019-09-18 10:23:29 -04:00
executor : windows-executor
2019-07-25 10:47:02 -04:00
steps :
2019-09-18 11:41:56 -04:00
- setup_win
2019-07-25 10:47:02 -04:00
- run :
2020-10-15 11:58:38 -04:00
name : Build all windows CI targets
2021-07-01 11:49:21 -04:00
command : yarn bazel build --config=ivy --build_tag_filters=-no-ivy-aot,-fixme-ivy-aot //packages/compiler-cli/...
2020-10-15 11:58:38 -04:00
no_output_timeout : 15m
- run :
name : Test all windows CI targets
2021-07-01 11:49:21 -04:00
command : yarn bazel test --config=ivy --test_tag_filters="-no-ivy-aot,-fixme-ivy-aot,-browser:chromium-local" //packages/compiler-cli/... //packages/localize/...
2020-10-15 11:58:38 -04:00
no_output_timeout : 15m
2021-04-06 07:11:07 -04:00
# Save dependencies to use on subsequent runs.
- save_cache :
key : *cache_key_win
paths :
- ~/.cache/yarn
2019-07-25 10:47:02 -04:00
2017-06-14 19:38:27 -04:00
workflows :
version : 2
default_workflow :
jobs :
2019-08-19 20:52:25 -04:00
- setup :
filters :
branches :
ignore : g3
2019-02-22 12:30:19 -05:00
- lint :
requires :
2019-07-18 16:33:45 -04:00
- setup
2019-02-22 12:30:19 -05:00
- test :
requires :
2019-07-18 16:33:45 -04:00
- setup
2019-02-22 12:30:19 -05:00
- test_ivy_aot :
requires :
2019-07-18 16:33:45 -04:00
- setup
2019-02-22 12:30:19 -05:00
- build-npm-packages :
requires :
2019-07-18 16:33:45 -04:00
- setup
2019-02-22 12:30:19 -05:00
- build-ivy-npm-packages :
requires :
2019-07-18 16:33:45 -04:00
- setup
2019-03-12 14:44:03 -04:00
- legacy-unit-tests-saucelabs :
requires :
2019-07-18 16:33:45 -04:00
- setup
- test_aio :
requires :
- setup
2018-10-25 07:01:24 -04:00
- deploy_aio :
requires :
- test_aio
2018-10-10 16:55:45 -04:00
- test_aio_local :
requires :
2019-01-14 20:47:39 -05:00
- build-npm-packages
2018-10-10 16:55:45 -04:00
- test_aio_tools :
requires :
2019-01-14 20:47:39 -05:00
- build-npm-packages
2019-01-06 09:37:55 -05:00
- test_docs_examples :
2018-10-10 16:55:45 -04:00
requires :
2019-01-14 20:47:39 -05:00
- build-npm-packages
2018-09-20 04:21:53 -04:00
- aio_preview :
2019-10-22 07:30:09 -04:00
# Only run on PR builds. (There can be no previews for non-PR builds.)
<< : *only_on_pull_requests
2019-02-22 12:30:19 -05:00
requires :
2019-02-22 16:33:53 -05:00
- setup
2018-08-25 17:40:58 -04:00
- test_aio_preview :
requires :
- aio_preview
2019-10-22 09:57:13 -04:00
- publish_packages_as_artifacts :
requires :
- build-npm-packages
2018-04-23 14:46:02 -04:00
- publish_snapshot :
2021-04-29 06:42:13 -04:00
<< : *only_release_branches
2018-04-23 14:46:02 -04:00
requires :
2018-04-23 19:41:10 -04:00
# Only publish if tests and integration tests pass
2018-04-23 19:14:34 -04:00
- test
2018-06-05 14:38:46 -04:00
- test_ivy_aot
2018-10-24 09:51:00 -04:00
# Only publish if `aio`/`docs` tests using the locally built Angular packages pass
- test_aio_local
2019-01-06 09:37:55 -05:00
- test_docs_examples
2019-02-05 16:20:05 -05:00
# Get the artifacts to publish from the build-packages-dist job
2018-04-23 19:14:34 -04:00
# since the publishing script expects the legacy outputs layout.
2019-01-14 20:47:39 -05:00
- build-npm-packages
- build-ivy-npm-packages
2019-03-12 14:44:03 -04:00
- legacy-unit-tests-saucelabs
2021-04-28 09:42:10 -04:00
- components-repo-unit-tests :
requires :
- build-npm-packages
2019-05-31 11:56:07 -04:00
- test_zonejs :
requires :
- setup
2019-07-25 10:47:02 -04:00
- test_win :
requires :
2020-10-06 16:05:39 -04:00
- setup
2019-07-25 10:47:02 -04:00
- test_ivy_aot_win :
requires :
2020-10-06 16:05:39 -04:00
- setup
2019-01-04 14:58:33 -05:00
2020-02-24 12:17:32 -05:00
monitoring :
2019-04-27 05:56:34 -04:00
jobs :
- setup
2021-05-21 18:28:04 -04:00
- aio_misc :
requires :
- setup
2019-04-27 05:56:34 -04:00
- aio_monitoring_stable :
requires :
- setup
- aio_monitoring_next :
requires :
- setup
2020-02-24 12:17:32 -05:00
- saucelabs_ivy :
# Testing saucelabs via Bazel currently taking longer than the legacy saucelabs job as it
# each karma_web_test target is provisioning and tearing down browsers which is adding
# a lot of overhead. Running once daily on master only to avoid wasting resources and
# slowing down CI for PRs.
# TODO: Run this job on all branches (including PRs) once karma_web_test targets can
# share provisioned browsers and we can remove the legacy saucelabs job.
requires :
- setup
- saucelabs_view_engine :
# Testing saucelabs via Bazel currently taking longer than the legacy saucelabs job as it
# each karma_web_test target is provisioning and tearing down browsers which is adding
# a lot of overhead. Running once daily on master only to avoid wasting resources and
# slowing down CI for PRs.
# TODO: Run this job on all branches (including PRs) once karma_web_test targets can
# share provisioned browsers and we can remove the legacy saucelabs job.
requires :
- setup
2019-04-27 05:56:34 -04:00
triggers :
- schedule :
2019-10-22 07:30:09 -04:00
<< : *only_on_master
2020-02-24 12:17:32 -05:00
# Runs monitoring jobs at 10:00AM every day.
2021-05-14 13:54:35 -04:00
cron : '0 10 * * *'