Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

remove failures from discord release channels (#3057)

shagun-singh-inkeep8e3f58e82564
diff --git a/.github/scripts/build-smoke-alert-payload.mjs b/.github/scripts/build-smoke-alert-payload.mjs
index 2f183af46..85c72749e 100644
--- a/.github/scripts/build-smoke-alert-payload.mjs
+++ b/.github/scripts/build-smoke-alert-payload.mjs
@@ -4,16 +4,20 @@
*
* When the DMG smoke gate refuses a release, the operator needs to learn it
* from the channel they already watch, not by noticing that a release never
- * appeared. This builds the Slack and Discord payloads for that page.
+ * appeared. This builds the Slack payload for that page.
+ *
+ * Slack is the only recipient. Discord is the public community server, open to
+ * users and to anyone evaluating OpenKnowledge, and it carries shipped
+ * releases only.
*
* The alert must be UNMISTAKABLY different from the routine
* "πŸŽ‰ OpenKnowledge X.Y.Z released" announcement that posts to the same
- * channels: different emoji, different headline, red rather than blue, and an
- * explicit statement that nothing shipped. A reader scanning the channel has
- * to be able to tell a blocked release from a successful one at a glance.
+ * channel: different emoji, different headline, and an explicit statement that
+ * nothing shipped. A reader scanning the channel has to be able to tell a
+ * blocked release from a successful one at a glance.
*
* Usage:
- * node build-smoke-alert-payload.mjs --channel slack|discord \
+ * node build-smoke-alert-payload.mjs \
* --tag vX.Y.Z --verdict fail|error --reason "…" --run-url "…" [--repo owner/name]
*
* Emits the payload as JSON on stdout. Everything is assembled through
@@ -23,8 +27,6 @@
import { pathToFileURL } from 'node:url';
-/** Red. The routine release announcement uses 3638527 (blue) β€” see desktop-release.yml. */
-export const ALERT_COLOR_DECIMAL = 14357800; // #DB1E28
const ALERT_HEADLINE = 'RELEASE BLOCKED';
const DEFAULT_REPO = 'inkeep/open-knowledge';
@@ -92,25 +94,6 @@ export function buildSlackPayload({ tag, verdict, reason, runUrl, repo = DEFAULT
};
}
-export function buildDiscordPayload({ tag, verdict, reason, runUrl, repo = DEFAULT_REPO }) {
- return {
- username: 'OpenKnowledge',
- allowed_mentions: { parse: [] },
- content: summaryLine(tag, verdict),
- embeds: [
- {
- title: summaryLine(tag, verdict),
- url: runUrl,
- color: ALERT_COLOR_DECIMAL,
- description: bodyLines({ tag, verdict, reason, runUrl, repo })
- .join('\n')
- // Slack mrkdwn bolds with single asterisks; Discord needs two.
- .replace(/\*([^*]+)\*/g, '**$1**'),
- },
- ],
- };
-}
-
export function parseArgs(argv) {
const args = {};
const rest = argv.slice(2);
@@ -120,12 +103,8 @@ export function parseArgs(argv) {
args[key.slice(2)] = rest[i + 1] ?? '';
i += 1;
}
- if (!args.channel || !['slack', 'discord'].includes(args.channel)) {
- throw new Error('--channel must be "slack" or "discord"');
- }
if (!args.tag) throw new Error('--tag is required');
return {
- channel: args.channel,
tag: args.tag,
verdict: args.verdict || 'error',
reason: args.reason || '(no reason recorded)',
@@ -134,13 +113,9 @@ export function parseArgs(argv) {
};
}
-export function buildPayload(opts) {
- return opts.channel === 'slack' ? buildSlackPayload(opts) : buildDiscordPayload(opts);
-}
-
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
try {
- process.stdout.write(JSON.stringify(buildPayload(parseArgs(process.argv))));
+ process.stdout.write(JSON.stringify(buildSlackPayload(parseArgs(process.argv))));
} catch (err) {
process.stderr.write(`${err.message}\n`);
process.exit(1);
diff --git a/.github/scripts/build-smoke-alert-payload.test.mjs b/.github/scripts/build-smoke-alert-payload.test.mjs
index ea8407615..e9a4f52c8 100644
--- a/.github/scripts/build-smoke-alert-payload.test.mjs
+++ b/.github/scripts/build-smoke-alert-payload.test.mjs
@@ -3,9 +3,6 @@ import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
- ALERT_COLOR_DECIMAL,
- buildDiscordPayload,
- buildPayload,
buildSlackPayload,
describeVerdict,
parseArgs,
@@ -18,6 +15,17 @@ const desktopRelease = readFileSync(
'utf8',
);
+/**
+ * Exact bounds of the alert step: its `- name:` up to the next sibling step.
+ * The fixed-length slices this replaces (400 / 4000 / 5000 chars) could run
+ * past the step and assert against a neighbouring step's shell.
+ */
+const alertStep = () => {
+ const rest = desktopRelease.slice(desktopRelease.indexOf('- name: Alert on a blocked release'));
+ const end = rest.indexOf('\n - name: ');
+ return end === -1 ? rest : rest.slice(0, end);
+};
+
const base = {
tag: 'v1.2.3',
verdict: 'fail',
@@ -31,10 +39,6 @@ describe('alert content', () => {
for (const needle of ['v1.2.3', 'fail', base.runUrl, 'event_type=desktop-release']) {
expect(slack).toContain(needle);
}
- const discord = JSON.stringify(buildDiscordPayload(base));
- for (const needle of ['v1.2.3', 'fail', base.runUrl, 'event_type=desktop-release']) {
- expect(discord).toContain(needle);
- }
});
test('states that nothing shipped', () => {
@@ -64,28 +68,15 @@ describe('alert content', () => {
});
describe('distinctness from the routine release announcement', () => {
- test('does not reuse the celebratory headline or the announcement colour', () => {
+ test('does not reuse the celebratory headline', () => {
const slack = JSON.stringify(buildSlackPayload(base));
- const discord = buildDiscordPayload(base);
expect(slack).not.toContain('πŸŽ‰');
expect(slack).not.toContain('released');
expect(slack).toContain('🚨');
expect(slack).toContain('RELEASE BLOCKED');
- // 3638527 is the blue the routine announcement uses in desktop-release.yml.
- expect(desktopRelease).toContain('color: 3638527');
- expect(discord.embeds[0].color).toBe(ALERT_COLOR_DECIMAL);
- expect(discord.embeds[0].color).not.toBe(3638527);
});
- test('the Discord alert suppresses mentions like the announcement does', () => {
- expect(buildDiscordPayload(base).allowed_mentions).toEqual({ parse: [] });
- });
-
- test('bold markup is Discord-flavoured in the Discord payload', () => {
- const discord = buildDiscordPayload(base);
- expect(discord.embeds[0].description).toContain('**Tag:**');
- expect(discord.embeds[0].description).not.toMatch(/(^|[^*])\*Tag:\*/);
- // Slack keeps its own single-asterisk mrkdwn.
+ test('uses Slack mrkdwn bold', () => {
expect(buildSlackPayload(base).blocks[1].text.text).toContain('*Tag:*');
});
});
@@ -100,7 +91,7 @@ describe('escaping', () => {
const slack = buildSlackPayload(nasty);
const roundTripped = JSON.parse(JSON.stringify(slack));
expect(roundTripped.text).toContain('v1.0.0"; rm -rf /; echo "');
- expect(JSON.stringify(buildDiscordPayload(nasty))).toContain('line one\\nline');
+ expect(JSON.stringify(slack)).toContain('line one\\nline');
});
});
@@ -110,8 +101,6 @@ describe('parseArgs', () => {
test('reads every flag the workflow step passes', () => {
const parsed = parseArgs(
argv(
- '--channel',
- 'discord',
'--tag',
'v1.2.3',
'--verdict',
@@ -123,7 +112,6 @@ describe('parseArgs', () => {
),
);
expect(parsed).toEqual({
- channel: 'discord',
tag: 'v1.2.3',
verdict: 'error',
reason: 'mount failed',
@@ -132,75 +120,70 @@ describe('parseArgs', () => {
});
});
- test('rejects a missing or unknown channel rather than emitting a half-built payload', () => {
- expect(() => parseArgs(argv('--tag', 'v1'))).toThrow(/--channel/);
- expect(() => parseArgs(argv('--channel', 'email', '--tag', 'v1'))).toThrow(/--channel/);
- });
-
test('rejects a missing tag', () => {
- expect(() => parseArgs(argv('--channel', 'slack'))).toThrow(/--tag/);
+ expect(() => parseArgs(argv('--verdict', 'fail'))).toThrow(/--tag/);
});
test('defaults an absent verdict to error rather than silently claiming a pass', () => {
- expect(parseArgs(argv('--channel', 'slack', '--tag', 'v1')).verdict).toBe('error');
- });
-
- test('buildPayload dispatches on channel', () => {
- expect(buildPayload({ ...base, channel: 'slack' }).blocks).toBeDefined();
- expect(buildPayload({ ...base, channel: 'discord' }).embeds).toBeDefined();
+ expect(parseArgs(argv('--tag', 'v1')).verdict).toBe('error');
});
});
describe('workflow wiring', () => {
test('the alert step is failure-conditioned, not success-conditioned', () => {
- const step = desktopRelease.slice(desktopRelease.indexOf('- name: Alert on a blocked release'));
- expect(step.slice(0, 400)).toContain('if: failure()');
- expect(step.slice(0, 400)).not.toContain('if: success()');
+ expect(alertStep()).toContain('if: failure()');
+ expect(alertStep()).not.toContain('if: success()');
});
test('the alert reads its builder from the workflow commit, not the release tag', () => {
// On repository_dispatch the workflow runs from the default branch while
// the job checks out client_payload.ref β€” a tag that can predate this
// script. v0.41.0 lost its Slack announcement to exactly that.
- const step = desktopRelease.slice(desktopRelease.indexOf('- name: Alert on a blocked release'));
+ const step = alertStep();
expect(step).toContain('git fetch --depth=1 origin "$GITHUB_SHA"');
expect(step).toContain(
'git show "${GITHUB_SHA}:.github/scripts/build-smoke-alert-payload.mjs"',
);
});
- test('the alert reuses the existing webhook secrets and introduces none', () => {
- const step = desktopRelease
- .slice(desktopRelease.indexOf('- name: Alert on a blocked release'))
- .slice(0, 4000);
- expect(step).toContain('secrets.SLACK_WEBHOOK_URL');
- expect(step).toContain('secrets.DISCORD_WEBHOOK_URL');
- const secretNames = new Set(
- [...desktopRelease.matchAll(/secrets\.([A-Z0-9_]+)/g)].map((m) => m[1]),
- );
- expect(secretNames.has('SLACK_WEBHOOK_URL')).toBe(true);
- expect(secretNames.has('DISCORD_WEBHOOK_URL')).toBe(true);
+ test('the alert reuses the existing webhook secret and introduces none', () => {
+ // "Introduces none" is a claim about THIS step, so it has to be measured at
+ // step scope: every secret the step names must already be consumed
+ // elsewhere in the workflow. Scanning the whole file for the secret the
+ // step uses proves nothing β€” the announcement steps reference it too, so
+ // the assertion holds even if this step is deleted outright.
+ expect(alertStep()).toContain('secrets.SLACK_WEBHOOK_URL');
+ const secretsIn = (yaml) =>
+ new Set([...yaml.matchAll(/secrets\.([A-Z0-9_]+)/g)].map((m) => m[1]));
+ const stepSecrets = secretsIn(alertStep());
+ const elsewhere = secretsIn(desktopRelease.split(alertStep()).join(''));
+ expect(stepSecrets.size).toBeGreaterThan(0);
+ for (const name of stepSecrets) {
+ expect(elsewhere.has(name), `${name} is introduced by the alert step`).toBe(true);
+ }
});
test('an unset webhook is a notice-level skip, and a failed POST is a warning', () => {
- const step = desktopRelease
- .slice(desktopRelease.indexOf('- name: Alert on a blocked release'))
- .slice(0, 5000);
+ const step = alertStep();
// Unset secret: annotate and return 0 β€” never fail the step.
expect(step).toContain('::notice::${label} webhook not set');
expect(step).toMatch(/if \[\[ -z "\$webhook" \]\]; then[\s\S]{0,200}?return 0/);
// A dead webhook warns; it must not mask the smoke failure that caused it.
expect(step).toContain('::warning::${label} smoke alert failed to POST');
- // Both channels are actually driven.
- expect(step).toContain('post slack "${SLACK_WEBHOOK_URL:-}"');
- expect(step).toContain('post discord "${DISCORD_WEBHOOK_URL:-}"');
+ // The channel is actually driven.
+ expect(step).toContain('post "${SLACK_WEBHOOK_URL:-}" Slack');
+ });
+
+ test('a blocked release never pages Discord', () => {
+ // Rationale: this module's docstring. This test is the ratchet for it.
+ const step = alertStep();
+ expect(step).not.toMatch(/^\s*post\s+.*Discord\s*$/m);
+ expect(step).not.toContain('DISCORD_WEBHOOK_URL');
});
test('the annotation is emitted in addition to the page, not instead of it', () => {
- const step = desktopRelease
- .slice(desktopRelease.indexOf('- name: Alert on a blocked release'))
- .slice(0, 5000);
- const slackAt = step.indexOf('post slack');
+ const step = alertStep();
+ const slackAt = step.indexOf('post "${SLACK_WEBHOOK_URL:-}" Slack');
const annotationAt = step.indexOf('::error::RELEASE BLOCKED');
expect(slackAt).toBeGreaterThan(-1);
expect(annotationAt).toBeGreaterThan(slackAt);
diff --git a/.github/scripts/evaluate-smoke-alarm.test.mjs b/.github/scripts/evaluate-smoke-alarm.test.mjs
index fb2879a95..54e9496f2 100644
--- a/.github/scripts/evaluate-smoke-alarm.test.mjs
+++ b/.github/scripts/evaluate-smoke-alarm.test.mjs
@@ -209,6 +209,30 @@ describe('buildHistory', () => {
expect(wf).toContain("Smoke the fast-tier candidate's DMG");
expect(wf).toContain('Dispatch promote-stable for the smoke-proven candidate');
});
+
+ test('the alarm pages Slack and never Discord', () => {
+ // Same rule as the per-cut blocked-release alert in desktop-release.yml
+ // (see build-smoke-alert-payload.mjs's module docstring for why): Discord
+ // carries shipped releases, not gate health. Without this the aggregate
+ // alarm is the one remaining path that could quietly re-acquire a Discord
+ // leg.
+ const wf = readFileSync(
+ join(
+ dirname(fileURLToPath(import.meta.url)),
+ '..',
+ 'workflows',
+ 'select-beta-to-promote.yml',
+ ),
+ 'utf8',
+ );
+ const step = wf.slice(wf.indexOf('- name: Page the release channel'));
+ expect(step).toContain('SLACK_WEBHOOK_URL');
+ expect(step).not.toContain('DISCORD_WEBHOOK_URL');
+ // Scoped to a `post … Discord` leg, not to the word: the step's comments
+ // explain why Discord is absent, and a ratchet that bans naming the thing
+ // it rules out would be paid for in workarounds.
+ expect(step).not.toMatch(/^\s*post\s+.*Discord\s*$/m);
+ });
});
describe('classifyHistoryFailure', () => {
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjs
index 9acc863eb..e1d0c839f 100644
--- a/.github/scripts/release-cascade-shape.test.mjs
+++ b/.github/scripts/release-cascade-shape.test.mjs
@@ -14,7 +14,7 @@ import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { afterAll, describe, expect, test } from 'vitest';
-import { buildDiscordPayload, buildSlackPayload } from './build-smoke-alert-payload.mjs';
+import { buildSlackPayload } from './build-smoke-alert-payload.mjs';
import { selectPromotion } from './select-beta-to-promote.mjs';
import { smokePackagedDmg, VERDICT } from './smoke-packaged-dmg.mjs';
@@ -200,7 +200,7 @@ describe('a deliberately broken DMG never reads as a pass', () => {
});
});
-describe('a forced smoke failure pages both channels, not just an annotation', () => {
+describe('a forced smoke failure pages Slack, not just an annotation', () => {
const forced = {
tag: 'v9.9.9',
verdict: 'fail',
@@ -208,24 +208,20 @@ describe('a forced smoke failure pages both channels, not just an annotation', (
runUrl: 'https://example.test/run/1',
};
- test('both payloads are produced and both name the blocked release', () => {
+ test('the payload is produced and names the blocked release', () => {
const slack = buildSlackPayload(forced);
- const discord = buildDiscordPayload(forced);
expect(slack.blocks.length).toBeGreaterThan(0);
- expect(discord.embeds.length).toBeGreaterThan(0);
- for (const s of [JSON.stringify(slack), JSON.stringify(discord)]) {
- expect(s).toContain('RELEASE BLOCKED');
- expect(s).toContain('v9.9.9');
- }
+ const s = JSON.stringify(slack);
+ expect(s).toContain('RELEASE BLOCKED');
+ expect(s).toContain('v9.9.9');
});
- test('the workflow posts to both webhooks in addition to annotating', () => {
+ test('the workflow posts to the Slack webhook in addition to annotating', () => {
const step = desktopRelease.slice(
desktopRelease.indexOf('- name: Alert on a blocked release'),
desktopRelease.indexOf('- name: Warn on stuck draft'),
);
- expect(step).toContain('post slack');
- expect(step).toContain('post discord');
+ expect(step).toContain('post "${SLACK_WEBHOOK_URL:-}" Slack');
expect(step).toContain('::error::RELEASE BLOCKED');
});
});
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 6ac13a0eb..a2621ab2a 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -785,7 +785,7 @@ jobs:
# Without this a blocked release is silent: the Release simply never
# appears and nobody learns why until someone goes looking. The alert is
# deliberately loud and visually unlike the routine
- # "πŸŽ‰ OpenKnowledge X.Y.Z released" post that lands in the same channels.
+ # "πŸŽ‰ OpenKnowledge X.Y.Z released" post that lands in the same channel.
#
# `if: failure()` (not `success()`) β€” this is the one step that must run
# precisely when the rest of the job did not. It fires for ANY job
@@ -794,9 +794,13 @@ jobs:
# came from elsewhere, which is the honest reading (the gate never
# returned a product verdict).
#
- # No new secret: SLACK_WEBHOOK_URL / DISCORD_WEBHOOK_URL already exist
- # and are consumed by the announcement steps above with the same
- # unset -> ::notice:: -> skip tolerance.
+ # No new secret: SLACK_WEBHOOK_URL already exists and is consumed by the
+ # announcement step above with the same unset -> ::notice:: -> skip
+ # tolerance.
+ #
+ # Slack only, deliberately β€” rationale lives in the module docstring of
+ # .github/scripts/build-smoke-alert-payload.mjs. Ratcheted by
+ # build-smoke-alert-payload.test.mjs so this cannot drift back.
- name: Alert on a blocked release (FR5c)
# Stable only, matching the gate's own scope. A failed beta cut keeps
# its existing STUCK-DRAFT warning below; paging the release channel for
@@ -804,7 +808,6 @@ jobs:
if: failure() && steps.channel.outputs.channel == 'latest'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
RELEASE_TAG: ${{ github.event.client_payload.release_tag || inputs.release_tag }}
SMOKE_VERDICT: ${{ steps.dmg_smoke.outputs.verdict }}
SMOKE_REASON: ${{ steps.dmg_smoke.outputs.reason }}
@@ -837,21 +840,21 @@ jobs:
# `${var^}` (bash 4) is deliberately avoided: macOS runners ship
# bash 3.2, so the label is passed in already-cased instead.
post() {
- local channel="$1" webhook="$2" label="$3"
+ local webhook="$1" label="$2"
if [[ -z "$webhook" ]]; then
echo "::notice::${label} webhook not set β€” skipping the ${label} smoke alert for ${RELEASE_TAG}."
return 0
fi
local payload=""
if [[ -f "$BUILDER" ]]; then
- payload="$(node "$BUILDER" --channel "$channel" --tag "$RELEASE_TAG" \
+ payload="$(node "$BUILDER" --tag "$RELEASE_TAG" \
--verdict "$VERDICT" --reason "$REASON" --run-url "$RUN_URL" || true)"
fi
if [[ -z "$payload" ]]; then
# Never go silent. Losing the formatting is a degradation; losing
# the page is the outage this step exists to prevent.
echo "::warning::Smoke-alert payload builder unavailable for ${RELEASE_TAG}; sending the plain-text alert."
- payload="$(jq -nc --arg t "🚨 RELEASE BLOCKED: ${RELEASE_TAG} DMG smoke ${VERDICT} β€” nothing shipped. ${REASON} ${RUN_URL}" '{content: $t, text: $t}')"
+ payload="$(jq -nc --arg t "🚨 RELEASE BLOCKED: ${RELEASE_TAG} DMG smoke ${VERDICT} β€” nothing shipped. ${REASON} ${RUN_URL}" '{text: $t}')"
fi
# The failing curl sits in an `if` condition, so a webhook outage
# routes to the warning instead of masking the smoke failure.
@@ -862,8 +865,7 @@ jobs:
fi
}
- post slack "${SLACK_WEBHOOK_URL:-}" Slack
- post discord "${DISCORD_WEBHOOK_URL:-}" Discord
+ post "${SLACK_WEBHOOK_URL:-}" Slack
# The annotation is emitted IN ADDITION to the page, so the run page
# tells the same story as the channel.
echo "::error::RELEASE BLOCKED: ${RELEASE_TAG} DMG smoke ${VERDICT} β€” ${REASON}. The Release stays a draft and npm latest is untouched."
diff --git a/.github/workflows/select-beta-to-promote.yml b/.github/workflows/select-beta-to-promote.yml
index cf20fd01d..bc93164f8 100644
--- a/.github/workflows/select-beta-to-promote.yml
+++ b/.github/workflows/select-beta-to-promote.yml
@@ -420,20 +420,22 @@ jobs:
FAST_TIER_ARMED: ${{ env.FAST_TIER_ARMED }}
run: node .github/scripts/evaluate-smoke-alarm.mjs
- # Routed to the same channels as the per-cut smoke alert, not to a
+ # Routed to the same channel as the per-cut smoke alert, not to a
# workflow annotation alone β€” an annotation on a scheduled job nobody
- # opens is indistinguishable from silence.
+ # opens is indistinguishable from silence. Slack only, for the reason the
+ # per-cut alert is: Discord carries shipped releases, not gate health.
- name: Page the release channel
if: steps.alarm.outputs.alarm == 'true'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
REASONS: ${{ steps.alarm.outputs.reasons }}
run: |
set -uo pipefail
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
TEXT="🚨 DMG SMOKE GATE ALARM β€” ${REASONS}. Investigate before trusting the fast tier. ${RUN_URL}"
- payload="$(jq -nc --arg t "$TEXT" '{content: $t, text: $t}')"
+ # `text` only: `content` was Discord's field, and Slack is now the
+ # sole recipient.
+ payload="$(jq -nc --arg t "$TEXT" '{text: $t}')"
post() {
local webhook="$1" label="$2"
if [[ -z "$webhook" ]]; then
@@ -447,5 +449,4 @@ jobs:
fi
}
post "${SLACK_WEBHOOK_URL:-}" Slack
- post "${DISCORD_WEBHOOK_URL:-}" Discord
echo "::warning::DMG smoke gate alarm: ${REASONS}"