Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5a5a73b
feat(dependabot-reminder): classify pull requests by owning team
cryptodev-2s Nov 3, 2026
a3731a0
feat(dependabot-reminder): build Slack payload with topology team tags
cryptodev-2s Nov 3, 2026
c51d38c
feat(dependabot-reminder): fetch Dependabot PRs and add CLI entry point
cryptodev-2s Nov 3, 2026
f21a1be
feat(dependabot-reminder): add composite action and reusable workflow
cryptodev-2s Nov 3, 2026
0b14185
docs: document the Dependabot PR reminder workflow
cryptodev-2s Nov 3, 2026
f650a00
fix(dependabot-reminder): match GraphQL bot author, read teams via RE…
cryptodev-2s Nov 3, 2026
3e82046
docs: shorten Dependabot reminder section in README
cryptodev-2s Nov 3, 2026
a06137a
docs: fix capitalization in README
cryptodev-2s Nov 3, 2026
2e8e3fd
refactor: split Dependabot reminder script into domain modules
cryptodev-2s Nov 3, 2026
d50c4e3
test: port dependabot reminder tests to vitest and fix lint
cryptodev-2s Nov 17, 2026
8dab76c
docs: drop Dependabot reminder section from README
cryptodev-2s Nov 17, 2026
cffaa3e
refactor: use shared helpers and one GraphQL search in the Dependabot…
cryptodev-2s Nov 17, 2026
26c86be
fix: tag teams with their Slack handle from topology
cryptodev-2s Nov 24, 2026
ee081e8
chore: drop the unused suppression and raise coverage thresholds
cryptodev-2s Nov 24, 2026
831f226
feat: list teams that share the same PRs once
cryptodev-2s Nov 24, 2026
b1f0057
feat: add a closing note to the Dependabot reminder
cryptodev-2s Nov 24, 2026
20b1ba0
fix: show the reminder note at normal size
cryptodev-2s Nov 24, 2026
67719e6
feat: show the reminder note under the headline
cryptodev-2s Nov 24, 2026
6b5f80c
feat: keep failing CI PRs with their teams and show a CI icon on each PR
cryptodev-2s Nov 24, 2026
344650e
refactor: drop CI status from the Dependabot reminder
cryptodev-2s Nov 24, 2026
7526b94
feat: list PRs requested from many teams under the fallback team
cryptodev-2s Nov 24, 2026
ecdff8a
feat: set the default shared team threshold to 5
cryptodev-2s Nov 24, 2026
1985cf6
docs: mention the changelog in the default reminder note
cryptodev-2s Nov 24, 2026
f2be3da
feat: list each PR once under all of its teams
cryptodev-2s Nov 24, 2026
cf11d15
refactor: send PRs with no team to the fallback team, whatever their …
cryptodev-2s Nov 24, 2026
1c7aa1d
feat: show a CI status icon on each PR again
cryptodev-2s Nov 24, 2026
45acfef
feat: use a check mark for passing CI and a warning for failing CI
cryptodev-2s Nov 24, 2026
10b1532
feat: tell teams exactly what to do in the reminder
cryptodev-2s Nov 24, 2026
d4bdbed
feat: redesign the Dependabot reminder message
cryptodev-2s Nov 25, 2026
e15026b
fix: run the reminder script when started through a symlinked path
cryptodev-2s Nov 25, 2026
2d08bb0
test: use a path that really contains parent segments
cryptodev-2s Nov 25, 2026
9d6c706
docs: say the script needs Node 22.18 or newer
cryptodev-2s Nov 25, 2026
16f8aa0
feat: let the reminder report on another repository
cryptodev-2s Nov 25, 2026
ce9a1a6
Revert "feat: let the reminder report on another repository"
cryptodev-2s Dec 2, 2026
f4a4cde
refactor: simplify the Dependabot reminder
cryptodev-2s Dec 2, 2026
7e80bfc
fix: shorten Dependabot titles that name a directory and a group
cryptodev-2s Dec 2, 2026
bf5fab1
feat: list the passing PRs first
cryptodev-2s Dec 2, 2026
507794a
refactor: cut titles by their escaped length
cryptodev-2s Dec 2, 2026
b2768ae
test: structure the reminder tests as arrange, act, assert
cryptodev-2s Dec 2, 2026
4a8bd15
test: one describe per file and drop assertions that only restated co…
cryptodev-2s Dec 2, 2026
1f09684
refactor: run the reminder script directly, without the entry check
cryptodev-2s Dec 2, 2026
e47f083
refactor: drop the unused topology ref input and the ReminderBlock ex…
cryptodev-2s Dec 2, 2026
b31f398
feat: tag a team that owns every PR once, and make the note fit one t…
cryptodev-2s Dec 2, 2026
78d24ca
feat: let callers override the reminder note and restore the multi te…
cryptodev-2s Dec 2, 2026
161f1f8
refactor: rename fallback-team to maintainer-team and make it required
cryptodev-2s Dec 2, 2026
01c0373
fix: address review feedback on the reminder
cryptodev-2s Dec 2, 2026
bddbed6
refactor: use Octokit in the reminder
cryptodev-2s Dec 3, 2026
819c17d
refactor: rely on the Octokit retry plugin in the PR search
cryptodev-2s Dec 3, 2026
cbaacdc
refactor: import the Octokit type from octokit
cryptodev-2s Dec 3, 2026
3b79a3d
chore: lower coverage thresholds to match CI
cryptodev-2s Dec 3, 2026
7f557f5
docs: use JSDoc on the reminder helpers
cryptodev-2s Dec 3, 2026
43ac938
refactor: apply the easy review suggestions in the reminder
cryptodev-2s Dec 3, 2026
ebe8385
chore: lower the branches coverage threshold to match CI
cryptodev-2s Dec 3, 2026
fac0641
docs: document each property of the reminder types
cryptodev-2s Dec 3, 2026
936323e
chore: raise the coverage thresholds to match CI
cryptodev-2s Dec 3, 2026
1a52d4e
docs: describe the reminder type properties on the type itself
cryptodev-2s Dec 3, 2026
2164cb6
refactor: group the reminder PRs by owner
cryptodev-2s Dec 3, 2026
066a5a0
refactor: split building the Slack message into functions
cryptodev-2s Dec 3, 2026
4250f9b
refactor: paginate the PR search with Octokit
cryptodev-2s Dec 3, 2026
7e04f21
chore: update the coverage thresholds to match CI
cryptodev-2s Dec 3, 2026
977f6f0
refactor: keep the reminder tests next to the source
cryptodev-2s Dec 3, 2026
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
72 changes: 72 additions & 0 deletions .github/actions/remind-dependabot-prs/action.yml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an action if we already have a workflow? Can we just ship a workflow in this case?

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Remind Dependabot PRs
description: 'Builds a Slack payload listing open Dependabot PRs grouped by owning team.'

inputs:
github-token:
description: 'Token used to read the pull requests of this repository.'
required: true
planning-token:
description: 'Token with read access to MetaMask/MetaMask-planning (for topology.json).'
required: true
owner-teams:
description: 'Comma-separated list of team slugs that own the invoking repository. May be empty.'
required: false
default: ''
maintainer-team:
description: 'Team that looks after the PRs no team is requested on, and coordinates the ones many teams share.'
required: true
shared-team-threshold:
description: 'A PR requested from more than this many teams is listed under the maintainer team.'
required: false
default: '5'
guide-url:
description: 'Link to a guide for handling these PRs, shown in the message. Empty for none.'
required: false
default: ''
reminder-note:
description: 'Note shown under the counts, as Slack mrkdwn. Empty uses the built in note.'
required: false
default: ''

outputs:
has-prs:
description: '"true" when there are open Dependabot PRs to report, otherwise "false".'
value: ${{ steps.reminder.outputs.has-prs }}
payload-path:
description: 'Path to the JSON file containing the Slack payload.'
value: ${{ steps.reminder.outputs.payload-path }}

runs:
using: composite
steps:
# The script is a .mts file, which requires Node 22.18+ to run directly.
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '24'

# Corepack resolves Yarn from the working directory, so install from the
# github-tools root to use its own pinned Yarn and lockfile.
- name: Install github-tools dependencies
shell: bash
working-directory: ${{ github.action_path }}/../../..
run: |
set -euo pipefail
corepack enable
corepack yarn install --immutable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use action-checkout-and-setup?


- name: Build Dependabot PR reminder
id: reminder
shell: bash
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ inputs.github-token }}
PLANNING_TOKEN: ${{ inputs.planning-token }}
OWNER_TEAMS: ${{ inputs.owner-teams }}
MAINTAINER_TEAM: ${{ inputs.maintainer-team }}
SHARED_TEAM_THRESHOLD: ${{ inputs.shared-team-threshold }}
GUIDE_URL: ${{ inputs.guide-url }}
REMINDER_NOTE: ${{ inputs.reminder-note }}
run: |
set -euo pipefail
node "$GITHUB_ACTION_PATH/../../scripts/dependabot-pr-reminder/cli.mts"
53 changes: 53 additions & 0 deletions .github/scripts/dependabot-pr-reminder/classify-pull-requests.mts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding JSDoc to these types and functions?

Also what do you think about calling this classify-pull-requests.mts?

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { normalizeTeamSlug } from '../shared/topology.mts';
import type { PullRequest, PullRequests } from './types.mts';

/**
* Groups PRs by the teams still requested as reviewers. A PR with more than
* `sharedTeamThreshold` owners has no single owner, so the maintainer team
* handles it, like a PR with no owner.
*
* @param pullRequests - The open Dependabot PRs.
* @param options - The options.
* @param options.ownerTeams - Only these teams are reminded, or every team when omitted.
* @param options.sharedTeamThreshold - The most owners a PR can have and still be owned by them.
* @returns The PRs grouped by owner.
*/
export function classifyPullRequests(
pullRequests: PullRequest[],
{
ownerTeams,
sharedTeamThreshold,
}: { ownerTeams?: string[] | undefined; sharedTeamThreshold: number },
): PullRequests {
const allowedOwners = ownerTeams?.map(normalizeTeamSlug);
const grouped: PullRequests = {
byOwner: new Map(),
sharedByManyOwners: [],
withNoOwners: [],
};

for (const pullRequest of pullRequests) {
const requestedOwners = new Set(
pullRequest.requestedTeams
.map(normalizeTeamSlug)
.filter((team) => !allowedOwners || allowedOwners.includes(team)),
);

if (requestedOwners.size > sharedTeamThreshold) {
grouped.sharedByManyOwners.push(pullRequest);
} else if (requestedOwners.size > 0) {
for (const owner of requestedOwners) {
const ownerPullRequests = grouped.byOwner.get(owner);
if (ownerPullRequests) {
ownerPullRequests.push(pullRequest);
} else {
grouped.byOwner.set(owner, [pullRequest]);
}
}
} else {
grouped.withNoOwners.push(pullRequest);
}
}

return grouped;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about placing these tests side by side with the implementation files for consistency with other projects/repos?

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { describe, expect, it } from 'vitest';

import { classifyPullRequests } from './classify-pull-requests.mts';
import { pr } from './fixtures.mts';

const options = { sharedTeamThreshold: 3 };

describe('classify-pull-requests', () => {
describe('classifyPullRequests', () => {
it('lists a PR under each requested team', () => {
const pullRequest = pr({ requestedTeams: ['a', 'b'] });

const { byOwner } = classifyPullRequests([pullRequest], options);

expect(byOwner).toStrictEqual(
new Map([
['a', [pullRequest]],
['b', [pullRequest]],
]),
);
});

it('puts a PR with no team with the maintainer team', () => {
const pullRequest = pr();

const { withNoOwners } = classifyPullRequests([pullRequest], options);

expect(withNoOwners).toStrictEqual([pullRequest]);
});

it('keeps a PR with exactly the threshold under its teams', () => {
const pullRequest = pr({ requestedTeams: ['a', 'b', 'c'] });

const { byOwner, sharedByManyOwners } = classifyPullRequests(
[pullRequest],
options,
);

expect([...byOwner.keys()]).toStrictEqual(['a', 'b', 'c']);
expect(sharedByManyOwners).toStrictEqual([]);
});

it('puts a PR with more teams than the threshold with the maintainer team', () => {
const pullRequest = pr({ requestedTeams: ['a', 'b', 'c', 'd'] });

const { byOwner, sharedByManyOwners } = classifyPullRequests(
[pullRequest],
options,
);

expect(byOwner.size).toBe(0);
expect(sharedByManyOwners).toStrictEqual([pullRequest]);
});

it('only counts the owner teams, ignoring case and repeats', () => {
const pullRequest = pr({
requestedTeams: ['a', 'A', 'b', 'x', 'y', 'z'],
});

const { byOwner, sharedByManyOwners } = classifyPullRequests(
[pullRequest],
{
...options,
ownerTeams: ['@MetaMask/a', 'b'],
},
);

expect([...byOwner.keys()]).toStrictEqual(['a', 'b']);
expect(sharedByManyOwners).toStrictEqual([]);
});

it('puts a PR with the maintainer team when no owner team is left', () => {
const pullRequest = pr({ requestedTeams: ['ui'] });

const { byOwner, withNoOwners } = classifyPullRequests([pullRequest], {
...options,
ownerTeams: ['extension-platform'],
});

expect(byOwner.size).toBe(0);
expect(withNoOwners).toStrictEqual([pullRequest]);
});

it('lists a team named like an object property', () => {
const pullRequest = pr({ requestedTeams: ['constructor'] });

const { byOwner } = classifyPullRequests([pullRequest], options);

expect(byOwner.get('constructor')).toStrictEqual([pullRequest]);
});
});
});
79 changes: 79 additions & 0 deletions .github/scripts/dependabot-pr-reminder/cli.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { appendFile, writeFile } from 'node:fs/promises';
import * as path from 'node:path';

import { createOctokit } from '../shared/octokit.mts';
import { fetchTopology } from '../shared/topology.mts';
import type { Topology } from '../shared/topology.mts';
import { classifyPullRequests } from './classify-pull-requests.mts';
import { fetchDependabotPullRequests } from './github-api.mts';
import { buildSlackPayload } from './slack-payload.mts';
import { parseOwnerTeams, parseSharedTeamThreshold } from './teams.mts';

/**
* Builds the Slack payload for the open Dependabot PRs and writes it, with the
* step outputs, for the workflow to post.
*/
async function main(): Promise<void> {
const environment = process.env;
const repository = environment.GITHUB_REPOSITORY;
const maintainerTeam = environment.MAINTAINER_TEAM;
const githubToken = environment.GH_TOKEN;
const planningToken = environment.PLANNING_TOKEN;
const outputPath = environment.GITHUB_OUTPUT;
if (
!repository ||
!maintainerTeam ||
!githubToken ||
!planningToken ||
!outputPath
) {
throw new Error(
'GITHUB_REPOSITORY, MAINTAINER_TEAM, GH_TOKEN, PLANNING_TOKEN and GITHUB_OUTPUT are required',
);
}

const pullRequests = await fetchDependabotPullRequests(
createOctokit(githubToken),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub has an @actions/github package that sets up an Octokit instance for you already, see: https://github.com/actions/toolkit/tree/main/packages/github

repository,
);
if (pullRequests.length === 0) {
console.log('No open Dependabot pull requests to report.');
await appendFile(outputPath, 'has-prs=false\n');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub has an @actions/core package which does this for you, see: https://github.com/actions/toolkit/tree/main/packages/core#inputsoutputs

return;
}

const grouped = classifyPullRequests(pullRequests, {
ownerTeams: parseOwnerTeams(environment.OWNER_TEAMS),
sharedTeamThreshold:
parseSharedTeamThreshold(environment.SHARED_TEAM_THRESHOLD) ?? 5,
});

let topology: Topology = {};
try {
topology = await fetchTopology(createOctokit(planningToken));
} catch (error) {
console.log(
`::warning::Could not read topology.json, posting without Slack tags: ${String(error)}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also output annotated messages using @actions/core, see: https://github.com/actions/toolkit/tree/main/packages/core#annotations

);
}

const payload = buildSlackPayload(grouped, topology, {
maintainerTeam,
repository,
guideUrl: environment.GUIDE_URL?.trim(),
note: environment.REMINDER_NOTE?.trim(),
});
const payloadPath = path.join(
environment.RUNNER_TEMP ?? '.',
'dependabot-reminder-payload.json',
);
await writeFile(payloadPath, JSON.stringify(payload));
await appendFile(outputPath, `has-prs=true\npayload-path=${payloadPath}\n`);
}

try {
await main();
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
20 changes: 20 additions & 0 deletions .github/scripts/dependabot-pr-reminder/cli.test.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { execFile } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';
import { describe, expect, it } from 'vitest';

const execFileAsync = promisify(execFile);

const SCRIPT = fileURLToPath(new URL('./cli.mts', import.meta.url));

describe('cli', () => {
it('stops with a message when the required settings are missing', async () => {
const run = execFileAsync(process.execPath, [SCRIPT], {
env: { PATH: process.env.PATH },
});

await expect(run).rejects.toMatchObject({
stderr: expect.stringContaining('are required'),
});
});
});
39 changes: 39 additions & 0 deletions .github/scripts/dependabot-pr-reminder/dependabot-title.mts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding JSDoc to these constants and functions?

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { escapeSlack } from '../shared/slack-blocks.mts';

/**
* Matches `chore(deps-dev): bump foo from 1.0.0 to 2.0.0` and
* `chore(deps): bump the foo group across 1 directory with 7 updates`. The
* scope is captured to tell `deps-dev` from `deps`.
*/
const PREFIX = String.raw`(?:[a-z]+(?:\(([^)]*)\))?!?:\s*)?`;
const PACKAGE = new RegExp(
`^${PREFIX}bump\\s+(\\S+)\\s+from\\s+(\\S+)\\s+to\\s+(\\S+?)(?:\\s+in\\s.*)?$`,
'iu',
);
const GROUP = new RegExp(
`^${PREFIX}bump\\s+the\\s+(\\S+)\\s+group(?:\\s+(?:across\\s+\\d+\\s+director(?:y|ies)|in\\s+\\S+))?\\s+with\\s+(\\d+)\\s+updates?$`,
'iu',
);

const code = (value: string): string =>
`\`${escapeSlack(value).replaceAll('`', "'")}\``;

/**
* Shortens a Dependabot title to `foo 1.0.0 → 2.0.0`.
*
* @param title - The pull request title.
* @returns The short description, or `undefined` if the title isn't a Dependabot one.
*/
export function describeUpdate(title: string): string | undefined {
const [, scope, name, from, to] = PACKAGE.exec(title.trim()) ?? [];
if (name && from && to) {
return `${code(name)} ${escapeSlack(from)} → ${escapeSlack(to)}${scope?.includes('dev') ? ' (dev)' : ''}`;
}

const [, , group, count] = GROUP.exec(title.trim()) ?? [];
if (group && count) {
return `${code(group)} group, ${count} ${count === '1' ? 'update' : 'updates'}`;
}

return undefined;
}
Loading