diff --git a/.circleci/config.yml b/.circleci/config.yml index 01b7b5f4acac..9454be12fd03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,237 +1,16 @@ -# Configuration file for https://circleci.com/gh/angular/components +# This config is remaining in place to prevent pull requests failing because of CircleCI config missing. -# 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. -# See http://blog.daemonl.com/2016/02/yaml.html -# To validate changes, use an online parser, eg. -# http://yaml-online-parser.appspot.com/ - -var_1: &docker_image cimg/node:18.17.0 -var_2: &docker-browser-image cimg/node:18.17.0-browsers - -# **Note**: When updating the beginning of the cache key, also update the cache key to match -# the new cache key prefix. This allows us to take advantage of CircleCI's fallback caching. -# Read more here: https://circleci.com/docs/2.0/caching/#restoring-cache. -var_3: &cache_key v16-ng-mat-{{ checksum ".bazelversion" }}-{{ checksum "tools/postinstall/apply-patches.js" }}-{{ checksum "WORKSPACE" }}-{{ checksum "yarn.lock" }} -# We want to invalidate the cache if the postinstall patches change. In order to apply new -# patches, a clean version of the node modules is needed. Additionally, we invalidate the cache -# if the Bazel version changes. We do this because otherwise the `bazelisk` cache folder will -# contain all previously used versions and ultimately cause the cache restoring to be slower. -var_4: &cache_fallback_key v16-ng-mat-{{ checksum ".bazelversion" }}-{{ checksum "tools/postinstall/apply-patches.js" }}- - -# Settings common to each job -var_5: &job_defaults - working_directory: ~/ng - docker: - - image: *docker_image - -# Restores the cache that could be available for the current Yarn lock file. The cache usually -# includes the node modules and the Bazel repository cache. -var_7: &restore_cache - restore_cache: - keys: - - *cache_key - - *cache_fallback_key - -# Saves the cache for the current Yarn lock file. We store the node modules and the Bazel -# repository cache in order to make subsequent builds faster. -var_8: &save_cache - save_cache: - key: *cache_key - paths: - - 'node_modules' - - '~/.cache/bazelisk' - - '~/bazel_repository_cache' - -# Decryption token that is used to decode the GCP credentials file in ".circleci/gcp_token". -var_9: &gcp_decrypt_token 'angular' - -# Job step that ensures that the node module dependencies are installed and up-to-date. We use -# Yarn with the frozen lockfile option in order to make sure that lock file and package.json are -# in sync. Unlike in Travis, we don't need to manually purge the node modules if stale because -# CircleCI automatically discards the cache if the checksum of the lock file has changed. -var_10: &yarn_install - run: - name: 'Installing project dependencies' - command: yarn install --frozen-lockfile --non-interactive - -# Installs all dependencies but does not enforce a frozen lockfile. Helpful when -# the "package.json" is updated as part of a CI job. e.g. when setting up snapshots. -var_11: &yarn_install_loose_lockfile - run: - name: 'Installing project dependencies' - command: yarn install --non-interactive - -# Sets up the Bazel config which is specific for CircleCI builds. -var_12: &setup_bazel_ci_config - run: - name: 'Setting up Bazel configuration for CI' - # Note: We add the remote config flag to the user bazelrc file that is not tracked - # by Git. This is necessary to avoid stamping builds with `.with-local-changes`. - command: echo "import %workspace%/.circleci/bazel.rc" >> ./.bazelrc.user - -# Attaches the release output which has been stored in the workspace to the current job. -# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs -var_13: &attach_release_output - attach_workspace: - at: dist/ - -# Branch filter that we can specify for jobs that should only run on publish branches. This filter -# is used to ensure that not all upstream branches will be published as Github builds -# (e.g. revert branches, feature branches) -var_14: &publish_branches_filter - branches: - only: - - main - # 6.0.x, 7.1.x, etc. - - /\d+\.\d+\.x/ - -# Branch filter that is usually applied to all jobs. Since there is no way within CircleCI to -# exclude a branch for all defined jobs, we need to manually specify the filters for each job. -# In order to reduce duplication we use a YAML anchor that just always excludes the "_presubmit" -# branch. We don't want to run Circle for the temporary "_presubmit" branch which is reserved -# for the caretaker. -var_15: &ignore_presubmit_branch_filter - branches: - ignore: - - '_presubmit' - -# Runs a script that sets up the Bazel remote execution. This will be used by jobs that run -# Bazel primarily and should benefit from remote caching and execution. -var_16: &setup_bazel_remote_execution - devinfra/setup-bazel-remote-exec: - bazelrc: ./.bazelrc.user - -# Sets up the bazel binary globally. We don't want to access bazel through Yarn and NodeJS -# because it could mean that the Bazel child process only has access to limited memory. -var_17: &setup_bazel_binary - run: - name: 'Setting up global Bazel binary' - command: ./scripts/circleci/setup_bazel_binary.sh - -# Sets up the Angular snapshot builds. -var_18: &setup_snapshot_builds - run: - name: 'Setting up Angular snapshot builds' - command: node ./scripts/circleci/setup-angular-snapshots.js main - -# Filter which ensures that jobs only run for pull requests. -var_19: &only_on_pull_requests_filter - branches: - only: - - /pull\/\d+/ - -# Anchor for a step that notifies Slack when preceding steps failed. -var_20: &slack_notify_on_failure - run: - name: 'Notifying team about job failure' - when: on_fail - command: yarn ci-notify-slack-failure - -# Branch filter that only matches the main branch. -var_21: &only_main_branch_filter - branches: - only: - - main - -# ----------------------------- -# Container version of CircleCI -# ----------------------------- version: 2.1 -# Configures CircleCI orbs for this pipeline. Orbs allow consumption of publicly shared -# CircleCI commands, jobs, configuration elements or executors. Read more about orbs here: -# https://circleci.com/docs/2.0/orb-intro/ -orbs: - # Set up the `queue` orb that allows us to queue up builds across jobs. We use it - # to make sure that snapshot builds are not deployed out of order, resulting in Git - # push conflicts. - queue: eddiewebb/queue@1.5.0 - devinfra: angular/dev-infra@1.0.8 - -commands: - checkout_and_rebase: - description: Checkout and rebase the repository - steps: - - checkout - # After checkout, rebase on top of target branch. - - devinfra/rebase-pr-on-target-branch: - base_revision: << pipeline.git.base_revision >> - head_revision: << pipeline.git.revision >> - -# ----------------------------------------------------------------------------------------- -# Job definitions. Jobs which are defined just here, will not run automatically. Each job -# must be part of a workflow definition in order to run for PRs and push builds. -# ----------------------------------------------------------------------------------------- jobs: - # ------------------------------------------------------------------------------------------- - # Job that builds all release packages. The built packages can be then used in the same - # workflow to publish snapshot builds. - # ------------------------------------------------------------------------------------------- - build_release_packages: - <<: *job_defaults - resource_class: xlarge - environment: - GCP_DECRYPT_TOKEN: *gcp_decrypt_token - steps: - - checkout_and_rebase - - *restore_cache - - *setup_bazel_ci_config - - *setup_bazel_remote_execution - - *yarn_install - - *setup_bazel_binary - - - run: yarn build-and-check-release-output - - run: yarn check-tooling-setup - - # TODO(devversion): replace this with bazel tests that run Madge. This is - # cumbersome and doesn't guarantee no circular deps for other entry-points. - - run: yarn madge --circular dist/releases/cdk/schematics/index.js - - # Store the release output in the workspace storage. This means that other jobs - # in the same workflow can attach the release output to their job. - - persist_to_workspace: - root: dist - paths: - - 'releases/**/*' - - *slack_notify_on_failure - - # ---------------------------------------- - # Job that publishes the docs site - # ---------------------------------------- - deploy_docs_site: + pass: docker: - - image: *docker-browser-image - resource_class: xlarge - environment: - GCP_DECRYPT_TOKEN: *gcp_decrypt_token + - image: cimg/base:2022.05 steps: - - checkout_and_rebase - - *restore_cache - - *setup_bazel_ci_config - - *setup_bazel_remote_execution - - *yarn_install - - *setup_bazel_binary - - - run: yarn ci-push-deploy-docs-app - - *slack_notify_on_failure + - run: echo "This too shall pass (always)" -# ---------------------------------------------------------------------------------------- -# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if -# one job depends on another. -# -# NOTE: When updating this configuration section, make sure to update GitHub robot -# config to match the new workflow jobs. -# ---------------------------------------------------------------------------------------- workflows: version: 2 - default_workflow: jobs: - - build_release_packages: - filters: *ignore_presubmit_branch_filter - - deploy_docs_site: - filters: *publish_branches_filter - requires: - - build_release_packages + - pass diff --git a/.github/actions/slack/action.yml b/.github/actions/slack/action.yml new file mode 100644 index 000000000000..404bce59a8a8 --- /dev/null +++ b/.github/actions/slack/action.yml @@ -0,0 +1,20 @@ +name: 'Notify slack on failure' +description: 'Notifying Slack of failure' + +inputs: + JOB_NAME: + description: 'Name of the job' + required: true + SLACK_BOT_TOKEN: + required: true + +runs: + using: 'composite' + steps: + - name: Notify about failed test + uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + with: + channel-id: 'C015EBF2XB6' + slack-message: '${{ inputs.JOB_NAME }} job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + env: + SLACK_BOT_TOKEN: ${{ inputs.SLACK_BOT_TOKEN }} diff --git a/.github/angular-robot.yml b/.github/angular-robot.yml index 0e6be3bbc272..1987139fe751 100644 --- a/.github/angular-robot.yml +++ b/.github/angular-robot.yml @@ -52,10 +52,6 @@ merge: - 'pr: needs*' - 'presubmit failures' - # list of PR statuses that need to be successful - requiredStatuses: - - 'ci/circleci: build_release_packages' - # the comment that will be added when the merge label is added despite failing checks, leave empty or set to false to disable # {{MERGE_LABEL}} will be replaced by the value of the mergeLabel option # {{PLACEHOLDER}} will be replaced by the list of failing checks diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6702fffaa9f9..d0f45954e425 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,13 +56,10 @@ jobs: # it has been merged. if: github.event_name == 'pull_request' run: yarn ng-dev format changed --check ${{ github.event.pull_request.base.sha }} - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Lint test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Lint check' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} api_golden_checks: @@ -80,13 +77,10 @@ jobs: run: yarn install --frozen-lockfile - name: Check API Goldens run: yarn bazel test tools/public_api_guard/... - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'API Goldens test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'API Golden Checks' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} e2e: @@ -104,13 +98,10 @@ jobs: run: yarn install --frozen-lockfile - name: Run e2e tests run: yarn e2e --flaky_test_attempts=2 - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'E2E test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'E2E test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} integration: @@ -131,13 +122,10 @@ jobs: - name: Running size integration tests run: yarn integration-tests:size-test continue-on-error: true - - name: Notify about failed integration size-test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Integration testing job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Integration test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} linker_aot_tests: @@ -155,13 +143,10 @@ jobs: run: yarn install --frozen-lockfile - name: Run linker AOT tests run: yarn test-linker-aot - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Linker AOT test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Link AOT test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} linker_jit_tests: @@ -179,13 +164,10 @@ jobs: run: yarn install --frozen-lockfile - name: Run linker JIT tests run: yarn test-linker-jit - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Linker JIT test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Link JIT test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} test: @@ -203,13 +185,10 @@ jobs: run: yarn install --frozen-lockfile - name: Run tests run: bazel test --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only -- src/... - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Browser test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} build: @@ -227,13 +206,10 @@ jobs: run: yarn install --frozen-lockfile - name: Run tests run: bazel build --build_tag_filters=-docs-package,-release-package -- src/... - - name: Notify about failed test - if: ${{ failure() && github.event_name == 'push'}} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Build job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Build' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} publish_snapshots: @@ -262,13 +238,10 @@ jobs: run: ./scripts/circleci/publish-snapshots.sh env: SNAPSHOT_BUILDS_GITHUB_TOKEN: ${{ secrets.SNAPSHOT_BUILDS_GITHUB_TOKEN }} - - name: Notify about failed publish - if: ${{ failure() }} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Snapshot publishing failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Snapshot publishing' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} upload_package_artifacts: @@ -296,3 +269,29 @@ jobs: with: name: Package Artifacts path: dist/release-archives + + deploy_doc_site: + if: ${{ github.event_name == 'push'}} + runs-on: ubuntu-latest-4core + steps: + - name: Initialize environment + uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@9931e1a8d1b62fcd2267e89f9993a494856cc1cd + with: + cache-node-modules: true + - name: Setup Bazel + uses: angular/dev-infra/github-actions/bazel/setup@9931e1a8d1b62fcd2267e89f9993a494856cc1cd + - name: Setup Bazel RBE + uses: angular/dev-infra/github-actions/bazel/configure-remote@9931e1a8d1b62fcd2267e89f9993a494856cc1cd + - name: Install node modules + run: yarn install --frozen-lockfile + - name: Build and Verify Release Output + run: yarn build-and-check-release-output + - name: Verify tooling setup + run: yarn check-tooling-setup + - name: Deploy the docs app + run: yarn ci-push-deploy-docs-app + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} + with: + JOB_NAME: 'Docs site deployment' + SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} diff --git a/.github/workflows/scheduled-ci.yml b/.github/workflows/scheduled-ci.yml index ff6d623f5399..1511336bb7e4 100644 --- a/.github/workflows/scheduled-ci.yml +++ b/.github/workflows/scheduled-ci.yml @@ -15,7 +15,7 @@ defaults: shell: bash jobs: - test_browsers: + browsers_snapshot_test: runs-on: ubuntu-latest-4core steps: - name: Initialize environment @@ -34,16 +34,13 @@ jobs: run: yarn install - name: Run Browser tests run: yarn bazel test --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only -- src/... - - name: Notify about failed test - if: ${{ failure() }} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Browser snapshot test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Browser snapshot test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} - linker_tests: + linker_snapshot_tests: runs-on: ubuntu-latest-4core steps: - name: Initialize environment @@ -64,13 +61,10 @@ jobs: run: yarn test-linker-aot - name: Run linker tests using JIT run: yarn test-linker-jit - - name: Notify about failed test - if: ${{ failure() }} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Snapshot linker test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Linker snapshot test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} mdc_snapshot_test: @@ -94,13 +88,10 @@ jobs: run: yarn install - name: Run browser tests using MDC Canary run: bazel test --build_tag_filters=-docs-package,-e2e --test_tag_filters=-e2e --build_tests_only -- src/... - - name: Notify about failed test - if: ${{ failure() }} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'MDC snapshot test job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'MDC Snapshot test' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }} monitor-docs-site: @@ -114,11 +105,8 @@ jobs: run: yarn install --frozen-lockfile - name: Check Docs Site run: yarn ci-docs-monitor-test - - name: Notify about failed test - if: ${{ failure() }} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v=v1.24.0 + - uses: ./.github/actions/slack + if: ${{ failure() && github.event_name == 'push' }} with: - channel-id: 'C015EBF2XB6' - slack-message: 'Docs site monitoring job failed for ${{ github.base_ref }} branch failed on build ${{ github.event.after }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: + JOB_NAME: 'Docs site monitoring' SLACK_BOT_TOKEN: ${{ secrets.ANGULAR_ROBOT_SLACK_TOKEN }}