Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 2 additions & 3 deletions .github/workflows/compatibility-matrix-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ jobs:
TSIO_POLL_DELAY_MS: 5000
COMMIT_STATUS_CONTEXT: e2e/compatibility-matrix-testing
# Incoming webhook for the Desktop CMT/RC results channel (separate from
# PR/master MM_DESKTOP_E2E_WEBHOOK_URL). Optional — when unset, TSIO
# status still flips and channel notify is skipped.
# RC / CMT channel (same destination as master E2E via resolveWebhookUrl).
# PR MM_DESKTOP_E2E_WEBHOOK_URL and master MM_E2E_MASTER_HEALTH_WEBHOOK_URL).
# Optional — when unset, TSIO status still flips and channel notify is skipped.
MATTERMOST_CMT_WEBHOOK_URL: ${{ secrets.MM_E2E_RELEASE_WEBHOOK_URL }}
# TSIO only sees test-case-level results — a job-level failure with no
# matching failed test (hung worker teardown, crashed runner, npm ci
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/e2e-functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ jobs:
TSIO_POLL_DELAY_MS: 5000
COMMIT_STATUS_CONTEXT: e2e-test/desktop-playwright
UPSTREAM_JOBS_SUCCEEDED: ${{ needs.e2e-tests.result == 'success' && needs.e2e-policy-tests.result == 'success' }}
# Master shares the CMT/RC channel; PR posts to the E2E QA channel.
# PR → MM_DESKTOP_E2E_WEBHOOK_URL; master → MM_E2E_MASTER_HEALTH_WEBHOOK_URL;
# CMT/RC uses MM_E2E_RELEASE_WEBHOOK_URL (compatibility-matrix-testing.yml).
# Routing is by compositeIdentity.name in cmt-channel-notify.js.
MATTERMOST_CMT_WEBHOOK_URL: ${{ secrets.MM_E2E_RELEASE_WEBHOOK_URL }}
MATTERMOST_E2E_WEBHOOK_URL: ${{ secrets.MM_DESKTOP_E2E_WEBHOOK_URL }}
MATTERMOST_MASTER_HEALTH_WEBHOOK_URL: ${{ secrets.MM_E2E_MASTER_HEALTH_WEBHOOK_URL }}
with:
script: |
const {reportUrl, status, stats} = await require('./e2e/utils/tsio-report-status.js')({
Expand Down
22 changes: 14 additions & 8 deletions e2e/utils/cmt-channel-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,28 @@ function parseCmtJobName(jobName) {
}

/**
* Webhook routing:
* cmt-desktop + desktop-master → MM_E2E_RELEASE_WEBHOOK_URL (RC / master channel)
* desktop-pr → MM_DESKTOP_E2E_WEBHOOK_URL (PR channel)
* Webhook routing (fail closed for named report groups):
* cmt-desktop → MATTERMOST_CMT_WEBHOOK_URL only (MM_E2E_RELEASE_WEBHOOK_URL)
* desktop-master → MATTERMOST_MASTER_HEALTH_WEBHOOK_URL only (MM_E2E_MASTER_HEALTH_WEBHOOK_URL)
* desktop-pr → MATTERMOST_E2E_WEBHOOK_URL only (MM_DESKTOP_E2E_WEBHOOK_URL)
*
* MATTERMOST_WEBHOOK_URL remains a fallback for workflows that set only one URL.
* Named groups never fall back to MATTERMOST_WEBHOOK_URL (avoids posting
* CMT/PR/master to the wrong channel when a dedicated secret is missing).
* Unknown names still use MATTERMOST_WEBHOOK_URL as a generic fallback.
*
* @param {string} reportName - compositeIdentity.name
* @param {NodeJS.ProcessEnv} [env]
* @returns {string}
*/
function resolveWebhookUrl(reportName, env = process.env) {
if (reportName === 'cmt-desktop' || reportName === 'desktop-master') {
return env.MATTERMOST_CMT_WEBHOOK_URL || env.MATTERMOST_WEBHOOK_URL || '';
if (reportName === 'cmt-desktop') {
return env.MATTERMOST_CMT_WEBHOOK_URL || '';
}
if (reportName === 'desktop-master') {
return env.MATTERMOST_MASTER_HEALTH_WEBHOOK_URL || '';
}
if (reportName === 'desktop-pr') {
return env.MATTERMOST_E2E_WEBHOOK_URL || env.MATTERMOST_WEBHOOK_URL || '';
return env.MATTERMOST_E2E_WEBHOOK_URL || '';
}
return env.MATTERMOST_WEBHOOK_URL || '';
}
Expand Down Expand Up @@ -451,7 +457,7 @@ async function fetchPerJobCountsFromConsolidated(baseUrl, compositeIdentity, gro
*/
async function postMattermostWebhook({core, webhookUrl, text, username = 'Desktop E2E'}) {
if (!webhookUrl) {
core.info('MATTERMOST_WEBHOOK_URL not set — skipping E2E channel notify');
core.info('Mattermost webhook URL not set — skipping E2E channel notify');
return;
}

Expand Down
40 changes: 36 additions & 4 deletions e2e/utils/cmt-channel-notify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,56 @@ describe('cmt-channel-notify', () => {
const env = {
MATTERMOST_CMT_WEBHOOK_URL: 'https://mm.example/hooks/cmt',
MATTERMOST_E2E_WEBHOOK_URL: 'https://mm.example/hooks/e2e',
MATTERMOST_MASTER_HEALTH_WEBHOOK_URL: 'https://mm.example/hooks/master-health',
MATTERMOST_WEBHOOK_URL: 'https://mm.example/hooks/fallback',
};

it('sends CMT and master to the CMT webhook', () => {
it('sends CMT to the release webhook', () => {
assert.equal(resolveWebhookUrl('cmt-desktop', env), env.MATTERMOST_CMT_WEBHOOK_URL);
assert.equal(resolveWebhookUrl('desktop-master', env), env.MATTERMOST_CMT_WEBHOOK_URL);
});

it('sends master runs to the master-health webhook', () => {
assert.equal(resolveWebhookUrl('desktop-master', env), env.MATTERMOST_MASTER_HEALTH_WEBHOOK_URL);
});

it('sends PR runs to the E2E webhook', () => {
assert.equal(resolveWebhookUrl('desktop-pr', env), env.MATTERMOST_E2E_WEBHOOK_URL);
});

it('does not fall back master to the PR webhook when CMT secret is missing', () => {
it('does not fall back CMT to the E2E webhook when release secret is missing', () => {
assert.equal(
resolveWebhookUrl('cmt-desktop', {MATTERMOST_E2E_WEBHOOK_URL: env.MATTERMOST_E2E_WEBHOOK_URL}),
'',
);
});

it('does not use the shared webhook when a dedicated CMT secret is missing', () => {
assert.equal(
resolveWebhookUrl('desktop-master', {MATTERMOST_E2E_WEBHOOK_URL: env.MATTERMOST_E2E_WEBHOOK_URL}),
resolveWebhookUrl('cmt-desktop', {MATTERMOST_WEBHOOK_URL: env.MATTERMOST_WEBHOOK_URL}),
'',
);
});

it('does not use the shared or PR webhook when master-health secret is missing', () => {
assert.equal(
resolveWebhookUrl('desktop-master', {
MATTERMOST_WEBHOOK_URL: env.MATTERMOST_WEBHOOK_URL,
MATTERMOST_E2E_WEBHOOK_URL: env.MATTERMOST_E2E_WEBHOOK_URL,
}),
'',
);
});

it('does not use the shared webhook when a dedicated E2E secret is missing for PR', () => {
assert.equal(
resolveWebhookUrl('desktop-pr', {MATTERMOST_WEBHOOK_URL: env.MATTERMOST_WEBHOOK_URL}),
'',
);
});

it('still uses the shared webhook for unknown report names', () => {
assert.equal(resolveWebhookUrl('unknown-report', env), env.MATTERMOST_WEBHOOK_URL);
});
});

describe('formatCmtChannelMessage', () => {
Expand Down
5 changes: 3 additions & 2 deletions e2e/utils/tsio-report-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ async function reportTsioStatus({
});

// Channel notify (best-effort). Routing (see resolveWebhookUrl):
// cmt-desktop / desktop-master → MM_E2E_RELEASE_WEBHOOK_URL
// desktop-pr → MM_DESKTOP_E2E_WEBHOOK_URL
// cmt-desktop → MM_E2E_RELEASE_WEBHOOK_URL
// desktop-master → MM_E2E_MASTER_HEALTH_WEBHOOK_URL
// desktop-pr → MM_DESKTOP_E2E_WEBHOOK_URL
// Failures here must not undo a successfully written commit status.
try {
const notifyNames = new Set(['cmt-desktop', 'desktop-pr', 'desktop-master']);
Expand Down
Loading