Skip to content

Commit 1475805

Browse files
authored
ci: report size-test failures to separate slack channel (#20033)
No longer reports size-test failures to the #components-ci-failures Slack channel. This channel should only receive messages for actual job failures. The size tests do not cause CI to turn red, so they should be handled in a separate channel.
1 parent 78dc50b commit 1475805

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ var_21: &slack_notify_on_failure
143143
run:
144144
name: "Notifying team about job failure"
145145
when: on_fail
146-
command: ./scripts/circleci/notify-slack-job-failure.sh
146+
command: node ./scripts/circleci/notify-slack-job-failure.js
147147

148148
# -----------------------------
149149
# Container version of CircleCI
@@ -582,7 +582,8 @@ jobs:
582582
- run:
583583
name: Running size integration tests (failures are reported in Slack only).
584584
command: |
585-
yarn integration-tests:size-test || ./scripts/circleci/notify-slack-job-failure.sh
585+
# If the size integration tests fail, report the failure to a dedicated #components-ci-size-tracking Slack channel.
586+
yarn integration-tests:size-test || node ./scripts/circleci/notify-slack-job-failure.js components-ci-size-tracking
586587
- run: yarn integration-tests:view-engine
587588
- *slack_notify_on_failure
588589

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that notifies Slack about the currently failing job. This script
5+
* will be a noop when running for forked builds (i.e. PRs).
6+
*/
7+
8+
if (process.env.CIRCLE_PR_NUMBER) {
9+
console.info('Skipping notifications for pull requests.');
10+
process.exit(0);
11+
}
12+
13+
const {echo, set} = require('shelljs');
14+
const {
15+
CIRCLE_JOB: jobName,
16+
CIRCLE_BRANCH: branchName,
17+
CIRCLE_BUILD_URL: jobUrl,
18+
SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL: webhookUrl,
19+
} = process.env;
20+
21+
const text = `\`${jobName}\` failed in branch: ${branchName}: ${jobUrl}`;
22+
const payload = {text};
23+
const [channelName] = process.argv.slice(2);
24+
25+
set('-e');
26+
27+
// If an explicit channel has been specified, override the default
28+
// webhook channel to the specified one.
29+
if (channelName !== undefined) {
30+
payload.channel = channelName;
31+
}
32+
33+
echo(JSON.stringify(payload, null, 2))
34+
.exec(`curl -d@- -H "Content-Type: application/json" ${webhookUrl}`);
35+
console.info('Notified Slack about job failure.');

scripts/circleci/notify-slack-job-failure.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)