Skip to content

Commit a11f20d

Browse files
committed
ci: fix slack notification script failing due to missing ts-node (#25062)
TS node is no longer automatically registering in the `ng-dev` tool, so the config cannot be loaded anymore. Callers of `getConfig()` are required to manually wire up TS-Node, mostly now because ESM ts-node **cannot** be registered at runtime anymore. So, the fix here is to either run the slack notify script with `node --loader ts-node/esm` or just run it using `ts-node` directly, while writing it in TS. The latter one seems the most reasonable. (cherry picked from commit 7f5bff7)
1 parent 1ba432a commit a11f20d

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ var_20: &slack_notify_on_failure
128128
run:
129129
name: 'Notifying team about job failure'
130130
when: on_fail
131-
command: node ./scripts/circleci/notify-slack-job-failure.mjs
131+
command: yarn ci-notify-slack-failure
132132

133133
# Branch filter that only matches the main branch.
134134
var_21: &only_main_branch_filter
@@ -509,7 +509,7 @@ jobs:
509509
name: Running size integration tests (failures are reported in Slack only).
510510
command: |
511511
# If the size integration tests fail, report the failure to a dedicated #components-ci-size-tracking Slack channel.
512-
yarn integration-tests:size-test || node ./scripts/circleci/notify-slack-job-failure.mjs components-ci-size-tracking
512+
yarn integration-tests:size-test || yarn ci-notify-slack-failure components-ci-size-tracking
513513
- *slack_notify_on_failure
514514

515515
# ----------------------------------------------------------------------------

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"tsc": "node ./node_modules/typescript/bin/tsc",
5252
"ci-push-deploy-docs-app": "ts-node --esm --project scripts/tsconfig.json scripts/docs-deploy/deploy-ci-push.mts",
5353
"ci-docs-monitor-test": "ts-node --esm --project scripts/tsconfig.json scripts/docs-deploy/monitoring/ci-test.mts",
54+
"ci-notify-slack-failure": "ts-node --esm --project scripts/tsconfig.json scripts/circleci/notify-slack-job-failure.mts",
5455
"prepare": "husky install"
5556
},
5657
"version": "14.0.1",

scripts/circleci/notify-slack-job-failure.mjs renamed to scripts/circleci/notify-slack-job-failure.mts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ import {
1111
assertValidGithubConfig,
1212
} from '@angular/dev-infra-private/ng-dev';
1313

14-
if (process.env.CIRCLE_PR_NUMBER) {
14+
if (process.env.CIRCLE_PR_NUMBER !== undefined) {
1515
console.info('Skipping notifications for pull requests.');
1616
process.exit(0);
1717
}
1818

19-
const {
20-
CIRCLE_JOB: jobName,
21-
CIRCLE_BRANCH: branchName,
22-
CIRCLE_BUILD_URL: jobUrl,
23-
SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL: webhookUrl,
24-
} = process.env;
19+
const jobName = process.env.CIRCLE_JOB!;
20+
const branchName = process.env.CIRCLE_BRANCH!;
21+
const jobUrl = process.env.CIRCLE_BUILD_URL!;
22+
const webhookUrl = process.env.SLACK_COMPONENTS_CI_FAILURES_WEBHOOK_URL!;
2523

2624
const {github} = await getConfig([assertValidGithubConfig]);
2725
const isPublishBranch = isVersionBranch(branchName) || branchName === github.mainBranchName;
@@ -35,7 +33,7 @@ if (isPublishBranch === false) {
3533
const {echo, set} = require('shelljs');
3634

3735
const text = `\`${jobName}\` failed in branch: ${branchName}: ${jobUrl}`;
38-
const payload = {text};
36+
const payload: {text: string; channel?: string} = {text};
3937
const [channelName] = process.argv.slice(2);
4038

4139
set('-e');

0 commit comments

Comments
 (0)