Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ module.exports = {
},
},

{
files: ['.github/actions/release-slack-summaries/**/*.mjs'],
// The composite action passes inputs through the environment, same as
// the scripts under .github/scripts.
rules: {
'n/no-process-env': 'off',
},
},

{
files: ['.github/scripts/**/*.test.mts'],
rules: {
Expand Down
139 changes: 139 additions & 0 deletions .github/actions/release-slack-summaries/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Release Slack summaries
description: >-
Posts the daily release blocker summary (Zap 596) or release validation
summary (Zap 597) to Slack. Jira is read-only. The caller passes short-lived
GitHub tokens from `.github/actions/get-token`; this action does not mint
tokens. Dry-run defaults to true and writes the message to the job summary.
The release PR checklist is rewritten only when allow-pr-write is true,
dry-run is false, and test-channel is empty. A test channel never writes
a pull request body.

inputs:
mode:
description: 'blocker-summary (Zap 596) or release-validation (Zap 597).'
required: true
platform:
description: 'extension or mobile.'
required: true
github-token:
description: >-
Short-lived token for the client repository (pull_requests: write, or
read for blocker-summary). Obtained by the caller via get-token.
required: true
planning-token:
description: >-
Short-lived contents: read token for MetaMask/MetaMask-planning
(topology.json). Obtained by the caller via get-token.
required: true
slack-bot-token:
description: Existing SLACK_BOT_TOKEN secret. Used only when dry-run is false.
required: true
jira-base-url:
description: Jira site origin. Read-only search.
required: false
default: https://consensyssoftware.atlassian.net
jira-email:
description: >-
Atlassian account email for the read-only Jira token (POC secret
JIRA_EMAIL in the release-notifications environment).
required: true
jira-api-token:
description: >-
Read-only Jira API token (POC secret JIRA_API_TOKEN). Never written back
to Jira.
required: true
jira-release-blocker-jql:
description: >-
Base JQL for release blockers. The saved filter is not created yet: leave
this empty and the step logs OPEN and skips the blocker section. Per
release the action appends AND cf[14565] = "V".
required: false
default: ''
jira-regression-jql:
description: >-
Optional base JQL for Found-in regressions. Empty uses the v10 proposal
default (issuetype = Bug, project in the §4 list) and the action appends
AND cf[16946] = "V". OPEN until the field id and project list are confirmed.
required: false
default: ''
topology-jira-project-field:
description: >-
topology.json field holding Jira project keys. PROPOSED name jiraProject
(array or string). OPEN until the schema change lands. Missing keys do
not guess a team.
required: false
default: jiraProject
test-channel:
description: >-
When set, post only to this channel and do not write any release PR body,
even if allow-pr-write is true. Real release channels are not used.
required: false
default: ''
dry-run:
description: >-
Default true. Build the Slack message and any PR-body diff into the job
summary. Post nothing and write nothing.
required: false
default: 'true'
allow-pr-write:
description: >-
Default false. Zap 597 rewrites the release PR checklist only when this
is true, dry-run is false, and test-channel is empty. Blocker summary
never writes.
required: false
default: 'false'
github-tools-repository:
description: Repository that contains this action. Defaults to the action repository.
required: false
default: ${{ github.action_repository }}
github-tools-ref:
description: Git ref of github-tools to check out. Defaults to the current action ref.
required: false
default: ${{ github.action_ref }}

runs:
using: composite
steps:
- name: Checkout GitHub tools repository
uses: actions/checkout@v6
with:
repository: ${{ inputs.github-tools-repository }}
ref: ${{ inputs.github-tools-ref }}
path: ./github-tools

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: ./github-tools/.nvmrc
cache-dependency-path: ./github-tools/yarn.lock
cache: yarn

- name: Enable Corepack
shell: bash
run: corepack enable
working-directory: ./github-tools

- name: Install dependencies
working-directory: ./github-tools
shell: bash
run: yarn --immutable

- name: Post release Slack summaries
working-directory: ./github-tools
shell: bash
env:
MODE: ${{ inputs.mode }}
PLATFORM: ${{ inputs.platform }}
GITHUB_TOKEN: ${{ inputs.github-token }}
PLANNING_TOKEN: ${{ inputs.planning-token }}
SLACK_BOT_TOKEN: ${{ inputs.slack-bot-token }}
JIRA_BASE_URL: ${{ inputs.jira-base-url }}
JIRA_EMAIL: ${{ inputs.jira-email }}
JIRA_API_TOKEN: ${{ inputs.jira-api-token }}
JIRA_RELEASE_BLOCKER_JQL: ${{ inputs.jira-release-blocker-jql }}
JIRA_REGRESSION_JQL: ${{ inputs.jira-regression-jql }}
TOPOLOGY_JIRA_PROJECT_FIELD: ${{ inputs.topology-jira-project-field }}
TEST_CHANNEL: ${{ inputs.test-channel }}
DRY_RUN: ${{ inputs.dry-run }}
ALLOW_PR_WRITE: ${{ inputs.allow-pr-write }}
run: node .github/actions/release-slack-summaries/run.mjs
127 changes: 127 additions & 0 deletions .github/actions/release-slack-summaries/adapter.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { describe, it } from 'node:test';

import { jiraIssueToRcBug, mergeJiraIssues } from './lib/adapter.mjs';
import { indexTeams } from './lib/teams.mjs';

const BROWSE = 'https://consensyssoftware.atlassian.net';

/**
* Reads one fixture shipped with this action.
*
* @param {string} name - Fixture file name.
* @returns {string} File contents.
*/
function fixture(name) {
return readFileSync(new URL(`./fixtures/${name}`, import.meta.url), 'utf8');
}

describe('jiraIssueToRcBug', () => {
it('maps an open unassigned issue and omits the team label when none is known', () => {
const bug = jiraIssueToRcBug(
{
key: 'PRED-4',
fields: {
summary: 'Unmapped project blocker',
assignee: null,
project: { key: 'PRED' },
status: { statusCategory: { key: 'new' } },
},
},
{ teamLabel: undefined, inBlockersSet: true, browseBaseUrl: BROWSE },
);

assert.deepEqual(bug, {
key: 'PRED-4',
projectKey: 'PRED',
name: 'Unmapped project blocker',
url: 'https://consensyssoftware.atlassian.net/browse/PRED-4',
closed: 'false',
assigneesLength: 0,
labels: ['release-blocker'],
});
});

it('marks Done issues closed and keeps a single team label', () => {
const bug = jiraIssueToRcBug(
{
key: 'CEUX-3',
fields: {
summary: 'Closed regression',
assignee: { displayName: 'Cy' },
project: { key: 'CEUX' },
status: { statusCategory: { key: 'done' } },
},
},
{
teamLabel: 'team-extension-platform',
inBlockersSet: false,
browseBaseUrl: `${BROWSE}/`,
},
);

assert.equal(bug.closed, 'true');
assert.equal(bug.assigneesLength, 1);
assert.deepEqual(bug.labels, ['team-extension-platform']);
assert.equal(
bug.url,
'https://consensyssoftware.atlassian.net/browse/CEUX-3',
);
});
});

describe('mergeJiraIssues', () => {
it('dedupes by key and adds release-blocker only for the blocker set', () => {
const issues = JSON.parse(fixture('jira-issues.json'));
const { projectToLabel } = indexTeams(
JSON.parse(fixture('topology.json')),
'jiraProject',
);
const bugs = mergeJiraIssues(issues.regressions, issues.blockers, {
teamLabelFor: (projectKey) => projectToLabel[projectKey],
browseBaseUrl: BROWSE,
});

assert.deepEqual(
bugs.map((bug) => bug.key),
['ASSETS-1', 'ASSETS-2', 'DSYS-9', 'PRED-4', 'CEUX-3'],
);
const login = bugs.find((bug) => bug.key === 'ASSETS-1');
assert.deepEqual(login.labels, [
'team-extension-platform',
'release-blocker',
]);
assert.equal(login.closed, 'false');
assert.equal(login.assigneesLength, 0);
const icon = bugs.find((bug) => bug.key === 'ASSETS-2');
assert.deepEqual(icon.labels, ['team-extension-platform']);
assert.equal(bugs.find((bug) => bug.key === 'PRED-4').projectKey, 'PRED');
assert.equal(bugs.find((bug) => bug.key === 'CEUX-3').closed, 'true');
});

it('keeps a blocker that the regression search did not return', () => {
const bugs = mergeJiraIssues(
[],
[
{
key: 'SWAPS-1',
fields: {
summary: 'Swap halt',
assignee: { displayName: 'Dee' },
project: { key: 'SWAPS' },
status: { statusCategory: { key: 'indeterminate' } },
},
},
],
{
teamLabelFor: () => undefined,
browseBaseUrl: BROWSE,
},
);

assert.equal(bugs.length, 1);
assert.deepEqual(bugs[0].labels, ['release-blocker']);
assert.equal(bugs[0].projectKey, 'SWAPS');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>Builds ready for testing.</p>
<p><a href="https://github.com/MetaMask/metamask-extension/releases/download/build-dist-browserify/builds/metamask-chrome-13.53.0.zip">chrome</a></p>
<p><a href="https://github.com/MetaMask/metamask-extension/releases/download/build-dist-mv2-browserify/builds/metamask-firefox-13.53.0.zip">firefox</a></p>
78 changes: 78 additions & 0 deletions .github/actions/release-slack-summaries/fixtures/jira-issues.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"regressions": [
{
"key": "ASSETS-1",
"fields": {
"summary": "Login crash",
"assignee": null,
"project": { "key": "ASSETS" },
"status": { "statusCategory": { "key": "indeterminate" } }
}
},
{
"key": "ASSETS-2",
"fields": {
"summary": "Icon glitch",
"assignee": { "displayName": "Ada" },
"project": { "key": "ASSETS" },
"status": { "statusCategory": { "key": "indeterminate" } }
}
},
{
"key": "DSYS-9",
"fields": {
"summary": "Token icon blocks sign-off",
"assignee": { "displayName": "Bea" },
"project": { "key": "DSYS" },
"status": { "statusCategory": { "key": "indeterminate" } }
}
},
{
"key": "PRED-4",
"fields": {
"summary": "Unmapped project blocker",
"assignee": null,
"project": { "key": "PRED" },
"status": { "statusCategory": { "key": "new" } }
}
},
{
"key": "CEUX-3",
"fields": {
"summary": "Closed regression",
"assignee": { "displayName": "Cy" },
"project": { "key": "CEUX" },
"status": { "statusCategory": { "key": "done" } }
}
}
],
"blockers": [
{
"key": "ASSETS-1",
"fields": {
"summary": "Login crash",
"assignee": null,
"project": { "key": "ASSETS" },
"status": { "statusCategory": { "key": "indeterminate" } }
}
},
{
"key": "DSYS-9",
"fields": {
"summary": "Token icon blocks sign-off",
"assignee": { "displayName": "Bea" },
"project": { "key": "DSYS" },
"status": { "statusCategory": { "key": "indeterminate" } }
}
},
{
"key": "PRED-4",
"fields": {
"summary": "Unmapped project blocker",
"assignee": null,
"project": { "key": "PRED" },
"status": { "statusCategory": { "key": "new" } }
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Summary

Testing plan: https://docs.google.com/spreadsheets/d/SHEETID/edit?gid=99#gid=99

# Team sign-off checklist

- [x] Mobile Platform
- [ ] Extension Platform
- [x] QA Team

Follow the checklist before release.
Loading
Loading