Skip to content

Commit 264bd4a

Browse files
test: smoke-test production notify script against test channel
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent cacec47 commit 264bd4a

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

‎.github/workflows/release-slack-notify-test.yml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,29 @@ jobs:
5656
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
5757
RUN_ID: ${{ github.run_id }}
5858
run: node .github/workflows/scripts/slack-release-demo.mjs
59+
60+
# Smoke-test the REAL production notify script (slack-sprint-cut-notify.mjs
61+
# from the sprint-cut wiring) with mock step outcomes, posting to the TEST
62+
# channel — proves the exact production rendering without a real cut.
63+
- name: Smoke-test production notify script
64+
env:
65+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
66+
CHANNEL_ID: ${{ github.event.inputs.channel_id || env.DEFAULT_CHANNEL_ID }}
67+
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
68+
RUN_ID: ${{ github.run_id }}
69+
CUT_LINE: '1.199'
70+
NEXT_LINE: '1.200'
71+
PR: 'https://github.com/UiPath/skills/pull/1234'
72+
run: |
73+
set -e
74+
echo "1/3 all success"
75+
CUT_OUTCOME=success PUBLISH_OUTCOME=success BUMP_OUTCOME=success \
76+
BUMP_URL="$PR" PREVIEW_VERSION=1.199.0-preview.777 \
77+
node .github/workflows/scripts/slack-sprint-cut-notify.mjs
78+
echo "2/3 preview publish failed, bump opened anyway"
79+
CUT_OUTCOME=success PUBLISH_OUTCOME=failure BUMP_OUTCOME=success \
80+
BUMP_URL="$PR" \
81+
node .github/workflows/scripts/slack-sprint-cut-notify.mjs
82+
echo "3/3 branch cut failed"
83+
CUT_OUTCOME=failure PUBLISH_OUTCOME=skipped BUMP_OUTCOME=skipped \
84+
node .github/workflows/scripts/slack-sprint-cut-notify.mjs
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Posts the sprint-cut announcement to Slack (chat.postMessage; mirrors
2+
// UiPath/cli). Driven by the real step outcomes passed in as env vars, so the
3+
// message reflects what actually happened. Emojis match Studio's Sprint Release
4+
// Bot (#dev-studio-robot): :checkbox_ticked: succeeded · :warning: failed/skipped.
5+
6+
const SLACK_URL = "https://slack.com/api/chat.postMessage";
7+
8+
const token = requireEnv("SLACK_BOT_TOKEN");
9+
const channel = requireEnv("CHANNEL_ID");
10+
const repo = process.env.REPO_URL || "https://github.com/UiPath/skills";
11+
const runUrl = process.env.RUN_ID ? `${repo}/actions/runs/${process.env.RUN_ID}` : repo;
12+
13+
const line = requireEnv("CUT_LINE"); // e.g. 1.199
14+
const version = `${line}.0`; // 1.199.0
15+
const nextVersion = `${requireEnv("NEXT_LINE")}.0`; // 1.200.0
16+
17+
const cutOk = process.env.CUT_OUTCOME === "success";
18+
const publishOk = process.env.PUBLISH_OUTCOME === "success";
19+
const bumpOk = process.env.BUMP_OUTCOME === "success";
20+
const bumpUrl = process.env.BUMP_URL || "";
21+
22+
const branchUrl = `${repo}/tree/release/v${line}`;
23+
// Exact preview version is stamped by publish.yml (<version>-preview.<run>).
24+
// If we have it, link the precise npmjs version; else fall back to versions tab.
25+
const previewVersion = process.env.PREVIEW_VERSION || "";
26+
const npmUrl = previewVersion
27+
? `https://www.npmjs.com/package/@uipath/skills/v/${previewVersion}`
28+
: "https://www.npmjs.com/package/@uipath/skills?activeTab=versions";
29+
const previewLabel = previewVersion
30+
? `\`@uipath/skills@${previewVersion}\``
31+
: `\`@uipath/skills@${version}-preview\``;
32+
33+
const OK = ":checkbox_ticked:";
34+
const WARN = ":warning:";
35+
36+
// Branch line
37+
const branchLine = cutOk
38+
? `${OK} Release branch \`release/v${line}\` cut from \`main\` (version \`${version}\`, <${branchUrl}|view branch>)`
39+
: `${WARN} Release branch \`release/v${line}\` cut from \`main\` FAILED (<${runUrl}|see logs>)`;
40+
41+
// Preview package line
42+
let previewLine;
43+
if (publishOk) {
44+
previewLine = `${OK} Preview package published to npmjs — ${previewLabel} (<${npmUrl}|view on npmjs>)`;
45+
} else if (!cutOk) {
46+
previewLine = `${WARN} Preview package publish skipped`;
47+
} else {
48+
previewLine = `${WARN} Preview package publish to npmjs FAILED — ${previewLabel} (<${runUrl}|see logs>)`;
49+
}
50+
51+
// Version-bump PR line
52+
let bumpLine;
53+
if (bumpOk && bumpUrl) {
54+
bumpLine = publishOk
55+
? `${OK} Version-bump PR opened: \`main\` → \`${nextVersion}\` (<${bumpUrl}|PR>)`
56+
: `${OK} Version-bump PR opened anyway: \`main\` → \`${nextVersion}\` (<${bumpUrl}|PR>) — ${WARN} verify the failed publish before merging`;
57+
} else if (bumpOk && !bumpUrl) {
58+
bumpLine = `${OK} \`main\` already on \`${nextVersion}\` — no bump PR needed`;
59+
} else {
60+
bumpLine = `${WARN} Version-bump PR not opened — \`main\` stays on \`${version}\``;
61+
}
62+
63+
const overall = cutOk && publishOk ? OK : WARN;
64+
const text = [
65+
`${overall} *Sprint release cut — \`${line}\`*`,
66+
branchLine,
67+
previewLine,
68+
bumpLine,
69+
].join("\n");
70+
71+
const res = await fetch(SLACK_URL, {
72+
method: "POST",
73+
headers: {
74+
Authorization: `Bearer ${token}`,
75+
"Content-Type": "application/json; charset=utf-8",
76+
},
77+
body: JSON.stringify({ channel, text, unfurl_links: false }),
78+
});
79+
const data = await res.json();
80+
// Slack returns HTTP 200 even on logical failure — check the ok field.
81+
if (!res.ok || data.ok !== true) {
82+
throw new Error(`Slack post failed: ${data.error || `${res.status} ${res.statusText}`}`);
83+
}
84+
console.log(`Posted sprint-cut announcement to ${channel} (ts=${data.ts}).`);
85+
86+
function requireEnv(name) {
87+
const v = process.env[name];
88+
if (!v) throw new Error(`Missing ${name} environment variable.`);
89+
return v;
90+
}

0 commit comments

Comments
 (0)