From 477cc51aa58c0b238f6f68e8909a80db3bec1e64 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 2 Jun 2025 09:25:36 -0400 Subject: [PATCH 1/2] fix(icr): workflow changes --- .../scripts/report-inactive-collaborators.mjs | 60 +++++++++++-------- .../workflows/find-inactive-collaborators.yml | 3 +- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/.github/scripts/report-inactive-collaborators.mjs b/.github/scripts/report-inactive-collaborators.mjs index 5f441474e2ce3..1d4da88ba74a1 100644 --- a/.github/scripts/report-inactive-collaborators.mjs +++ b/.github/scripts/report-inactive-collaborators.mjs @@ -15,6 +15,20 @@ const getDateMonthsAgo = (months = CONFIG.INACTIVE_MONTHS) => { return date.toISOString().split('T')[0]; }; +// Check if there's already an open issue +async function hasOpenIssue(github, context) { + const { owner, repo } = context.repo; + const { data: issues } = await github.rest.issues.listForRepo({ + owner, + repo, + state: 'open', + labels: CONFIG.ISSUE_LABELS[1], + per_page: 1, + }); + + return issues.length > 0; +} + // Parse collaborator usernames from governance file async function parseCollaborators() { const content = await readFile(CONFIG.GOVERNANCE_FILE, 'utf8'); @@ -41,12 +55,20 @@ async function getInactiveUsers(github, usernames, repo, cutoffDate) { const inactiveUsers = []; for (const username of usernames) { - const { data } = await github.rest.search.commits({ + // Check commits + const { data: commits } = await github.rest.search.commits({ q: `author:${username} repo:${repo} committer-date:>=${cutoffDate}`, per_page: 1, }); - if (data.total_count === 0) { + // Check issues and PRs + const { data: issues } = await github.rest.search.issuesAndPullRequests({ + q: `author:${username} repo:${repo} updated:>=${cutoffDate}`, + per_page: 1, + }); + + // User is inactive if they have no commits AND no issues/PRs + if (commits.total_count === 0 && issues.total_count === 0) { inactiveUsers.push(username); } } @@ -75,37 +97,25 @@ ${inactiveMembers.map(m => `| @${m} |`).join('\n')} @nodejs/nodejs-website should review this list and contact inactive collaborators to confirm their continued interest in participating in the project.`; } -async function createOrUpdateIssue(github, context, report) { +async function createIssue(github, context, report) { if (!report) return; const { owner, repo } = context.repo; - const { data: issues } = await github.rest.issues.listForRepo({ + await github.rest.issues.create({ owner, repo, - state: 'open', - labels: CONFIG.ISSUE_LABELS[1], - per_page: 1, + title: CONFIG.ISSUE_TITLE, + body: report, + labels: CONFIG.ISSUE_LABELS, }); - - if (issues.total_count > 0) { - await github.rest.issues.update({ - owner, - repo, - issue_number: issues.items[0].number, - body: report, - }); - } else { - await github.rest.issues.create({ - owner, - repo, - title: CONFIG.ISSUE_TITLE, - body: report, - labels: CONFIG.ISSUE_LABELS, - }); - } } export default async function (github, context) { + // Check for existing open issue first - exit early if one exists + if (await hasOpenIssue(github, context)) { + return; + } + const cutoffDate = getDateMonthsAgo(); const collaborators = await parseCollaborators(); @@ -117,5 +127,5 @@ export default async function (github, context) { ); const report = formatReport(inactiveMembers, cutoffDate); - await createOrUpdateIssue(github, context, report); + await createIssue(github, context, report); } diff --git a/.github/workflows/find-inactive-collaborators.yml b/.github/workflows/find-inactive-collaborators.yml index d537b4d425bbb..c790fe3910ab6 100644 --- a/.github/workflows/find-inactive-collaborators.yml +++ b/.github/workflows/find-inactive-collaborators.yml @@ -2,8 +2,7 @@ name: Find inactive collaborators on: schedule: - # Run every Monday at 4:05 AM UTC. - - cron: 5 4 * * 1 + - cron: '0 0 1 * *' # Runs at 00:00 UTC on the 1st day of every month workflow_dispatch: From c42c0444937175cf9522aa0caf7398214f3a2bf9 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Tue, 3 Jun 2025 09:06:09 -0400 Subject: [PATCH 2/2] involves Signed-off-by: Aviv Keller --- .github/scripts/report-inactive-collaborators.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/report-inactive-collaborators.mjs b/.github/scripts/report-inactive-collaborators.mjs index 1d4da88ba74a1..a1b306dba9786 100644 --- a/.github/scripts/report-inactive-collaborators.mjs +++ b/.github/scripts/report-inactive-collaborators.mjs @@ -63,7 +63,7 @@ async function getInactiveUsers(github, usernames, repo, cutoffDate) { // Check issues and PRs const { data: issues } = await github.rest.search.issuesAndPullRequests({ - q: `author:${username} repo:${repo} updated:>=${cutoffDate}`, + q: `involves:${username} repo:${repo} updated:>=${cutoffDate}`, per_page: 1, });