Skip to content

build: setup slack notifications for circleci jobs #19608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ var_20: &only_on_pull_requests_filter
only:
- /pull\/\d+/

# Anchor for a step that notifies Slack when preceding steps failed.
var_21: &slack_notify_on_failure
run:
name: "Notifying team about job failure"
when: on_fail
command: ./scripts/notify-slack-job-failure.sh

# -----------------------------
# Container version of CircleCI
# -----------------------------
Expand Down Expand Up @@ -168,6 +175,7 @@ jobs:
# Exclude release and docs packages here as those will be built within
# the "build_release_packages" and "publish_snapshots" jobs.
- run: bazel build src/... --build_tag_filters=-docs-package,-release-package
- *slack_notify_on_failure

# -----------------------------------
# Job which ensures that all non-test Bazel targets build properly
Expand All @@ -189,6 +197,7 @@ jobs:
# Exclude release and docs packages here as those will be built within
# the "build_release_packages" and "publish_snapshots" jobs.
- run: bazel build src/... --build_tag_filters=-docs-package,-release-package --config=view-engine
- *slack_notify_on_failure

# --------------------------------------------------------------------------------------------
# Job that runs ts-api-guardian against our API goldens in "tools/public_api_guard".
Expand All @@ -208,6 +217,7 @@ jobs:
- *setup_bazel_binary

- run: bazel test tools/public_api_guard/...
- *slack_notify_on_failure

# -----------------------------------------------------------------
# Job that runs the e2e tests with Protractor and Chromium headless
Expand All @@ -226,6 +236,7 @@ jobs:
- *setup_bazel_binary

- run: bazel test src/... --build_tag_filters=e2e --test_tag_filters=e2e --build_tests_only
- *slack_notify_on_failure

# ------------------------------------------------------------------------------------------
# Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless).
Expand All @@ -245,6 +256,7 @@ jobs:
- *setup_bazel_binary

- run: bazel test src/... --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs the unit tests on Browserstack. The browsers that will be used
Expand All @@ -263,6 +275,7 @@ jobs:
- *yarn_install

- run: ./scripts/circleci/run-browserstack-tests.sh
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs the unit tests on Saucelabs. The browsers that will be used
Expand All @@ -284,6 +297,7 @@ jobs:
- *yarn_install

- run: ./scripts/circleci/run-saucelabs-tests.sh
- *slack_notify_on_failure

# ----------------------------------
# Lint job.
Expand Down Expand Up @@ -315,6 +329,7 @@ jobs:
- run: yarn tslint
- run: yarn -s ts-circular-deps:check

- *slack_notify_on_failure
- *save_cache

# -------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -369,6 +384,7 @@ jobs:
- store_artifacts:
path: /tmp/cdk-umd-minified-bundles
destination: /angular_material/cdk_release_output/
- *slack_notify_on_failure

upload_release_packages:
<<: *job_defaults
Expand Down Expand Up @@ -411,8 +427,8 @@ jobs:
# as part of this job to the docs-content repository. It's not contained in the
# attached release output, so we need to build it here.
- run: bazel build src/components-examples:npm_package --config=release

- run: ./scripts/circleci/publish-snapshots.sh
- *slack_notify_on_failure

# -----------------------------------------------------------------
# Job that ensures that the release output is compatible with ngcc.
Expand All @@ -435,6 +451,7 @@ jobs:
# tsconfig parsing as that causes the release packages to be incorrectly resolved
# to the sources due to path mapping.
- run: yarn ngcc --error-on-failed-entry-point --no-tsconfig
- *slack_notify_on_failure

# -----------------------------------------------------------------
# Job that ensures that the release output is compatible with the
Expand All @@ -459,6 +476,7 @@ jobs:
# tsconfig parsing as that causes the release packages to be incorrectly resolved
# to the sources due to path mapping.
- run: yarn ngcc --error-on-failed-entry-point --no-tsconfig
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs the local browser tests against the Angular Github snapshots
Expand All @@ -479,6 +497,7 @@ jobs:
- *setup_bazel_binary

- run: bazel test src/... --build_tag_filters=-e2e --test_tag_filters=-e2e --build_tests_only
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs all Bazel tests against View Engine with the current Angular version
Expand All @@ -499,6 +518,7 @@ jobs:

# Run project tests with NGC and View Engine.
- run: bazel test src/... --build_tag_filters=-docs-package,-e2e --test_tag_filters=-e2e --config=view-engine --build_tests_only
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs all Bazel tests against View Engine from angular/angular#master.
Expand All @@ -519,6 +539,7 @@ jobs:

# Run project tests with NGC and View Engine.
- run: bazel test src/... --build_tag_filters=-docs-package,-e2e --test_tag_filters=-e2e --config=view-engine --build_tests_only
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs all Bazel integration tests.
Expand All @@ -537,6 +558,7 @@ jobs:
- *setup_bazel_binary
- run: yarn integration-tests
- run: yarn integration-tests:view-engine
- *slack_notify_on_failure

# ----------------------------------------------------------------------------
# Job that runs all Bazel tests against material-components-web@canary
Expand All @@ -560,6 +582,7 @@ jobs:
# Setup the components repository to use the MDC snapshot builds.
# Run project tests with the MDC canary builds.
- run: bazel test src/... --build_tag_filters=-docs-package,-e2e --test_tag_filters=-e2e --build_tests_only
- *slack_notify_on_failure

# ----------------------------------------------------------------------------------------
# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if
Expand Down
17 changes: 17 additions & 0 deletions scripts/circleci/notify-slack-job-failure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# Script that notifies Slack about the currently failing job. This script
# will be a noop when running for forked builds (i.e. PRs).

if [[ -z "${CIRCLE_PR_NUMBER}" ]]; then
echo "Skipping notification for pull request."
exit 0
fi

message="\`${CIRCLE_JOB}\` failed in branch: ${CIRCLE_BRANCH}: ${CIRCLE_BUILD_URL}"
data="{\"text\": \"${message}\"}"

curl --request POST --header "Content-Type: application/json" --data "${data}" \
${SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL}

echo "Notified Slack about job failure."