diff --git a/.circleci/config.yml b/.circleci/config.yml index cc411ceb4c..4e484c905d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,11 +30,6 @@ var_4: &cache_key_fallback v7-angular-node-12-{{ checksum ".bazelversion" }} var_3_win: &cache_key_win v7-angular-win-node-12-{{ checksum ".bazelversion" }}-{{ checksum "yarn.lock" }}-{{ checksum "WORKSPACE" }}-{{ checksum "packages/bazel/package.bzl" }}-{{ checksum "aio/yarn.lock" }} var_4_win: &cache_key_win_fallback v7-angular-win-node-12-{{ checksum ".bazelversion" }} -# 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. -var_5: &components_repo_unit_tests_cache_key v9-angular-components-09e68db8ed5b1253f2fe38ff954ef0df019fc25a -var_6: &components_repo_unit_tests_cache_key_fallback v9-angular-components- - # 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 @@ -156,27 +151,6 @@ commands: git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true git config --global gc.auto 0 || true - init_saucelabs_environment: - description: Sets up a domain that resolves to the local host. - steps: - - run: - name: Preparing environment for running tests on Sauce Labs. - 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 - # host. This domain is helpful in Sauce Labs tests where devices are not able to - # 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 - # Normally this would be an individual job instead of a command. # But startup and setup time for each individual windows job are high enough to discourage # many small jobs, so instead we use a command for setup unless the gain becomes significant. @@ -272,109 +246,8 @@ jobs: - run: yarn -s tslint - run: yarn -s ng-dev format changed $CI_GIT_BASE_REVISION --check - run: yarn -s ts-circular-deps:check - - run: yarn -s ng-dev pullapprove verify - run: yarn -s ng-dev commit-message validate-range --range $CI_COMMIT_RANGE - test: - executor: - name: default-executor - # 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 - resource_class: 2xlarge+ - steps: - - custom_attach_workspace - - init_environment - - install_chrome_libs - - install_java - - run: - command: yarn bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only - no_output_timeout: 20m - - # Temporary job to test what will happen when we flip the Ivy flag to true - test_ivy_aot: - executor: - name: default-executor - resource_class: medium - steps: - - custom_attach_workspace - - init_environment - - install_chrome_libs - # We need to explicitly specify the --symlink_prefix option because otherwise we would - # not be able to easily find the output bin directory when uploading artifacts for size - # measurements. - - run: - command: yarn test-ivy-aot //... --symlink_prefix=dist/ - no_output_timeout: 20m - - # 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 - - # NOTE: This is currently limited to master builds only. See the `monitoring` configuration. - saucelabs_view_engine: - 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: medium - steps: - - custom_attach_workspace - - init_environment - - init_saucelabs_environment - - run: - name: Run Bazel tests on Saucelabs with ViewEngine - # See /tools/saucelabs/README.md for more info - command: | - yarn bazel run //tools/saucelabs:sauce_service_setup - 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", ...)') - yarn bazel test --config=saucelabs ${TESTS} - yarn bazel run //tools/saucelabs:sauce_service_stop - no_output_timeout: 40m - - notify_webhook_on_fail: - webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL - - # NOTE: This is currently limited to master builds only. See the `monitoring` configuration. - 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: medium - steps: - - custom_attach_workspace - - init_environment - - init_saucelabs_environment - - run: - name: Run Bazel tests on Saucelabs with Ivy - # See /tools/saucelabs/README.md for more info - command: | - yarn bazel run //tools/saucelabs:sauce_service_setup - 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", ...)') - yarn bazel test --config=saucelabs --config=ivy ${TESTS} - yarn bazel run //tools/saucelabs:sauce_service_stop - no_output_timeout: 40m - - notify_webhook_on_fail: - webhook_url_env_var: SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL - test_aio: executor: default-executor steps: @@ -489,7 +362,6 @@ jobs: name: Wait for preview and run tests command: node aio/scripts/test-preview.js $CI_PULL_REQUEST $CI_COMMIT $CI_AIO_MIN_PWA_SCORE - # 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 @@ -523,246 +395,6 @@ jobs: - "~/bazel_repository_cache" - "~/.cache/bazelisk" - # Build the ivy npm packages. - build-ivy-npm-packages: - executor: - name: default-executor - resource_class: medium - steps: - - custom_attach_workspace - - init_environment - - run: node scripts/build/build-ivy-npm-packages.js - - # Save the npm packages from //packages/... for other workflow jobs to read - - persist_to_workspace: - root: *workspace_location - paths: - - ng/dist/packages-dist-ivy-aot - - ng/dist/zone.js-dist-ivy-aot - - # 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: - 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' - steps: - - custom_attach_workspace - - init_environment - # Publish `@angular/*` packages. - - run: - name: Create artifacts for @angular/* packages - command: ./scripts/ci/create-package-archives.sh $CI_BRANCH $CI_COMMIT $NG_PACKAGES_DIR $NG_PACKAGES_ARCHIVES_DIR - - store_artifacts: - path: *ng_packages_archives_dir - destination: angular - # Publish `zone.js` package. - - run: - name: Create artifacts for zone.js package - command: ./scripts/ci/create-package-archives.sh $CI_BRANCH $CI_COMMIT $ZONEJS_PACKAGES_DIR $ZONEJS_PACKAGES_ARCHIVES_DIR - - store_artifacts: - path: *zonejs_packages_archives_dir - destination: zone.js - - # This job updates the content of repos like github.com/angular/core-builds - # for every green build on angular/angular. - publish_snapshot: - executor: default-executor - steps: - # See below - ideally this job should not trigger for non-upstream builds. - # But since it does, we have to check this condition. - - run: - name: Skip this job for Pull Requests and Fork builds - # Note: Using `CIRCLE_*` env variables (instead of those defined in `env.sh` so that this - # step can be run before `init_environment`. - command: > - if [[ -n "${CIRCLE_PR_NUMBER}" ]] || - [[ "$CIRCLE_PROJECT_USERNAME" != "angular" ]] || - [[ "$CIRCLE_PROJECT_REPONAME" != "angular" ]]; then - circleci step halt - fi - - custom_attach_workspace - - init_environment - # 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" - - run: - name: Decrypt github credentials - # We need ensure that the same default digest is used for encoding and decoding with - # 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 - command: 'openssl aes-256-cbc -d -in .circleci/github_token -md md5 -k "${KEY}" -out ~/.git_credentials' - - run: ./scripts/ci/publish-build-artifacts.sh - - aio_monitoring_stable: - executor: default-executor - steps: - - custom_attach_workspace - - init_environment - - install_chrome_libs - - run: setPublicVar_CI_STABLE_BRANCH - - run: - name: Check out `aio/` and yarn from the stable branch - command: | - git fetch origin $CI_STABLE_BRANCH - git checkout --force origin/$CI_STABLE_BRANCH -- aio/ .yarn/ .yarnrc - # 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. - - run: yarn config set ignore-engines true - - run: - name: Run tests against https://angular.io/ - command: ./aio/scripts/test-production.sh https://angular.io/ $CI_AIO_MIN_PWA_SCORE - - 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 - - aio_monitoring_next: - executor: default-executor - steps: - - custom_attach_workspace - - init_environment - - install_chrome_libs - - run: - name: Run tests against https://next.angular.io/ - command: ./aio/scripts/test-production.sh https://next.angular.io/ $CI_AIO_MIN_PWA_SCORE - - 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 - - legacy-unit-tests-saucelabs: - 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: medium - steps: - - custom_attach_workspace - - init_environment - - init_saucelabs_environment - - run: - name: Starting Saucelabs tunnel service - command: ./tools/saucelabs/sauce-service.sh run - background: true - - run: yarn tsc -p packages - - run: yarn tsc -p modules - - run: yarn bazel build //packages/zone.js:npm_package - - 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 - - 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} - - run: - name: Stop Saucelabs tunnel service - command: ./tools/saucelabs/sauce-service.sh stop - - # Job that runs all unit tests of the `angular/components` repository. - components-repo-unit-tests: - executor: - name: default-executor - resource_class: medium - steps: - - custom_attach_workspace - - init_environment - # 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). - - restore_cache: - keys: - - *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 - - run: - name: "Fetching angular/components repository" - command: ./scripts/ci/clone_angular_components_repo.sh - - run: - # Run yarn install to fetch the Bazel binaries as used in the components repo. - name: Installing dependencies. - # TODO: remove this once the repo has been updated to use NodeJS v12 and Yarn 1.19.1. - # We temporarily ignore the "engines" because the Angular components repository has - # minimum dependency on NodeJS v12 and Yarn 1.19.1, but the framework repository uses - # older versions. - command: yarn --ignore-engines --cwd ${COMPONENTS_REPO_TMP_DIR} install --frozen-lockfile --non-interactive - - save_cache: - key: *components_repo_unit_tests_cache_key - paths: - # 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. - - "/tmp/angular-components-repo" - - run: - # Updates the `angular/components` `package.json` file to refer to the release output - # inside the `packages-dist` directory. Note that it's not necessary to perform a yarn - # install as Bazel runs Yarn automatically when needed. - name: Setting up release packages. - command: node scripts/ci/update-deps-to-dist-packages.js ${COMPONENTS_REPO_TMP_DIR}/package.json dist/packages-dist/ - - run: - name: "Running `angular/components` unit tests" - command: ./scripts/ci/run_angular_components_unit_tests.sh - - test_zonejs: - executor: - name: default-executor - resource_class: medium - steps: - - custom_attach_workspace - - init_environment - # Install - - run: yarn --cwd packages/zone.js install --frozen-lockfile --non-interactive - # Run zone.js tools tests - - run: yarn --cwd packages/zone.js promisetest - - run: yarn --cwd packages/zone.js promisefinallytest - - run: yarn bazel build //packages/zone.js:npm_package && - 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/ && - yarn --cwd packages/zone.js electrontest - - run: yarn --cwd packages/zone.js jesttest - - # Windows jobs - # Docs: https://circleci.com/docs/2.0/hello-world-windows/ - test_win: - executor: windows-executor - steps: - - setup_win - - run: - # Ran into a command parsing problem where `-browser:chromium-local` was converted to - # `-browser: chromium-local` (a space was added) in https://circleci.com/gh/angular/angular/357511. - # Probably a powershell command parsing thing. There's no problem using a yarn script though. - command: yarn circleci-win-ve - no_output_timeout: 45m - # Save bazel repository cache to use on subsequent runs. - # We don't save node_modules because it's faster to use the linux workspace and reinstall. - - save_cache: - key: *cache_key_win - paths: - - "C:/Users/circleci/bazel_repository_cache" - - test_ivy_aot_win: - executor: windows-executor - steps: - - setup_win - - run: - command: yarn circleci-win-ivy - no_output_timeout: 45m - workflows: version: 2 @@ -775,21 +407,9 @@ workflows: - lint: requires: - setup - - test: - requires: - - setup - - test_ivy_aot: - requires: - - setup - build-npm-packages: requires: - setup - - build-ivy-npm-packages: - requires: - - setup - - legacy-unit-tests-saucelabs: - requires: - - setup - test_aio: requires: - setup @@ -823,78 +443,3 @@ workflows: - test_aio_preview: requires: - aio_preview - - publish_packages_as_artifacts: - requires: - - build-npm-packages - - publish_snapshot: - # Note: no filters on this job because we want it to run for all upstream branches - # We'd really like to filter out pull requests here, but not yet available: - # https://discuss.circleci.com/t/workflows-pull-request-filter/14396/4 - # Instead, the job just exits immediately at the first step. - requires: - # Only publish if tests and integration tests pass - - test - - test_ivy_aot - # Only publish if `aio`/`docs` tests using the locally built Angular packages pass - - test_aio_local - - test_aio_local_viewengine - - test_docs_examples - - test_docs_examples_viewengine - # Get the artifacts to publish from the build-packages-dist job - # since the publishing script expects the legacy outputs layout. - - build-npm-packages - - build-ivy-npm-packages - - legacy-unit-tests-saucelabs - - components-repo-unit-tests: - requires: - - build-npm-packages - - test_zonejs: - requires: - - setup - # Windows Jobs - # These are very slow so we run them on non-PRs only for now. - # TODO: remove the filter when CircleCI makes Windows FS faster. - # The Windows jobs are only run after their non-windows counterparts finish successfully. - # This isn't strictly necessary as there is no artifact dependency, but helps economize - # CI resources by not attempting to build when we know should fail. - - test_win: - <<: *skip_on_pull_requests - requires: - - test - - test_ivy_aot_win: - <<: *skip_on_pull_requests - requires: - - test_ivy_aot - - monitoring: - jobs: - - setup - - aio_monitoring_stable: - requires: - - setup - - aio_monitoring_next: - requires: - - setup - - 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 - triggers: - - schedule: - <<: *only_on_master - # Runs monitoring jobs at 10:00AM every day. - cron: "0 10 * * *"