Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCR PR reviewer: add support for a "do_not_notify" field #2037

Merged
merged 2 commits into from
Sep 18, 2024
Merged
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: 5 additions & 4 deletions actions/bcr-pr-reviewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function fetchAllModifiedModules(octokit, owner, repo, prNumber) {
return accumulate;
}

async function generateMaintainersMap(octokit, owner, repo, modifiedModules) {
async function generateMaintainersMap(octokit, owner, repo, modifiedModules, toNotifyOnly) {
const maintainersMap = new Map(); // Map: maintainer GitHub username -> Set of module they maintain
const modulesWithoutGithubMaintainers = new Set(); // Set of module names without module maintainers
for (const moduleName of modifiedModules) {
Expand All @@ -45,7 +45,8 @@ async function generateMaintainersMap(octokit, owner, repo, modifiedModules) {
const metadata = JSON.parse(Buffer.from(metadataContent.content, 'base64').toString('utf-8'));
let hasGithubMaintainer = false;
metadata.maintainers.forEach(maintainer => {
if (maintainer.github) { // Check if the github field is specified
// Only add maintainers with a github handle set. When `toNotifyOnly`, also exclude those who have set "do_not_notify"
if (maintainer.github && !(toNotifyOnly && maintainer["do_not_notify"])) {
hasGithubMaintainer = true;
if (!maintainersMap.has(maintainer.github)) {
maintainersMap.set(maintainer.github, new Set());
Expand Down Expand Up @@ -256,7 +257,7 @@ async function reviewPR(octokit, owner, repo, prNumber) {
}

// Figure out maintainers for each modified module
const [ maintainersMap, modulesWithoutGithubMaintainers ] = await generateMaintainersMap(octokit, owner, repo, modifiedModules);
const [ maintainersMap, modulesWithoutGithubMaintainers ] = await generateMaintainersMap(octokit, owner, repo, modifiedModules, /* toNotifyOnly= */ false);
console.log('Maintainers Map:');
for (const [maintainer, maintainedModules] of maintainersMap.entries()) {
console.log(`- Maintainer: ${maintainer}, Modules: ${Array.from(maintainedModules).join(', ')}`);
Expand Down Expand Up @@ -332,7 +333,7 @@ async function runNotifier(octokit) {
console.log(`Modified modules: ${Array.from(modifiedModules).join(', ')}`);

// Figure out maintainers for each modified module
const [ maintainersMap, modulesWithoutGithubMaintainers ] = await generateMaintainersMap(octokit, owner, repo, modifiedModules);
const [ maintainersMap, modulesWithoutGithubMaintainers ] = await generateMaintainersMap(octokit, owner, repo, modifiedModules, /* toNotifyOnly= */ true);

// Notify maintainers for modules with module maintainers
await notifyMaintainers(octokit, owner, repo, prNumber, maintainersMap);
Expand Down
Loading