From 6df2067a2ccab55ad46f8fa960f8e317c0bd5d36 Mon Sep 17 00:00:00 2001 From: Will Gillis <40799239+t-will-gillis@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:45:48 -0700 Subject: [PATCH 1/5] Update get-contributors-data.js Adjustments made to `oneMonthAgo` for Feb and Aug runs, also add "Skills Issue" --- .../get-contributors-data.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js b/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js index add9ab048a..d3abf43cc7 100644 --- a/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js +++ b/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js @@ -11,13 +11,12 @@ const botMembers = ['elizabethhonest', 'hfla-website-checklist', 'HackforLABot'] // Set date limits: we are sorting inactive members into groups to notify after 1 month and remove after 2 months. // Since the teams take off December and July, the Jan. 1st and Aug. 1st runs are skipped (via `schedule-monthly.yml`). -// The Feb. 1st and Sept. 1st runs account for skipped months: 'oneMonth' & 'twoMonths' = 2 & 3 months respectively +// The Feb. 1st and Sept. 1st runs account for skipped months: 'oneMonth' & 'twoMonths' = 1 & 3 months respectively let today = new Date(); -let oneMonth = (today.getMonth() === 1 || today.getMonth() === 8) ? 2 : 1; let twoMonths = (today.getMonth() === 1 || today.getMonth() === 8) ? 3 : 2; -let oneMonthAgo = new Date(); // oneMonthAgo instantiated with date of "today" -oneMonthAgo.setMonth(oneMonthAgo.getMonth() - oneMonth); // then set oneMonthAgo from "today" +let oneMonthAgo = new Date(); // oneMonthAgo instantiated with date of "today" +oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1); // then set oneMonthAgo from "today" oneMonthAgo = oneMonthAgo.toISOString(); let twoMonthsAgo = new Date(); // twoMonthsAgo instantiated with date of "today" twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - twoMonths); // then set twoMonthsAgo from "today" @@ -37,7 +36,7 @@ async function main({ g, c }) { context = c; const [contributorsOneMonthAgo, contributorsTwoMonthsAgo, inactiveWithOpenIssue] = await fetchContributors(dates); - console.log('-------------------------------------------------------'); + console.log(`-`.repeat(60)); console.log('List of active contributors since ' + dates[0].slice(0, 10) + ':'); console.log(contributorsOneMonthAgo); @@ -122,10 +121,11 @@ async function fetchContributors(dates){ if(responseObject.result === false){ allContributorsSince[assignee] = true; } - // If timeline is more than two months ago, add to open issues with inactive - // comments with flag = true if issue is "Pre-work Checklist", false otherwise - else if(date === dates[1]){ - if(contributorInfo.title.includes("Pre-work Checklist")){ + // If timeline is more than two months ago, add to open issues with inactive. Then check if + // issue title includes "Pre-work Checklist" or "Skills Issue" and set flag = true, else set false + else if (date === dates[1]) { + const regex = /Pre-work checklist|Skills Issue/i; + if (regex.test(contributorInfo.title)) { inactiveWithOpenIssue[assignee] = [issueNum, true]; } else { inactiveWithOpenIssue[assignee] = [issueNum, false]; From 52cca3374cc921add913f0ac81efd1f921859964 Mon Sep 17 00:00:00 2001 From: Will Gillis <40799239+t-will-gillis@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:48:57 -0700 Subject: [PATCH 2/5] Update inactive-members.md Change "Pre-work checklist" --> "Skills Issue" --- .../trigger-schedule/list-inactive-members/inactive-members.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-actions/trigger-schedule/list-inactive-members/inactive-members.md b/github-actions/trigger-schedule/list-inactive-members/inactive-members.md index ccd3daffc3..02efe8f359 100644 --- a/github-actions/trigger-schedule/list-inactive-members/inactive-members.md +++ b/github-actions/trigger-schedule/list-inactive-members/inactive-members.md @@ -22,7 +22,7 @@ The bot is checking for the following activity: - If you are assigned to an issue, that you have provided an update on the issue in the past 30 days. The updates are due weekly. - If your issue is a `Draft` in the "New Issue Approval" column, that you have added to it within the last 30 days. - If you are reviewing PRs, that you have posted a review comment within the past 30 days. -- If you are newly onboarded, that you are assigned to your "Pre-work checklist" and you have cloned the HfLA website repo to your personal repo. +- If you are newly onboarded, that you are assigned to your "Skills Issue" and you have cloned the HfLA website repo to your personal repo. If you have been inactive in the last 30 days (using the above measurements), you can become active again by doing at least one of the above actions. If you do not do at least one of the above actions, the bot will automatically remove you from the 'website-write' team in the next 30 days. From 2aad50b131baceac62dab868295aec2e06c73ad7 Mon Sep 17 00:00:00 2001 From: Will Gillis <40799239+t-will-gillis@users.noreply.github.com> Date: Sat, 26 Oct 2024 10:06:19 -0700 Subject: [PATCH 3/5] Update trim-inactive-members.js Change "Pre-work Checklist" --> "Skills Issue", add REST API ref comments, remove excess calc for `currentTeamMembers` --- .../trim-inactive-members.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js b/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js index 27fc4740fa..0c070bc49e 100644 --- a/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js +++ b/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js @@ -29,23 +29,23 @@ async function main({ g, c }, { recentContributors, previousContributors, inacti context = c; const currentTeamMembers = await getTeamMembers(github, context, writeTeam); - console.log('-------------------------------------------------------'); + console.log(`-`.repeat(60)); console.log('Current members of ' + writeTeam + ':'); console.log(currentTeamMembers); - const [removedContributors, cannotRemoveYet] = await removeInactiveMembers(previousContributors, inactiveWithOpenIssue); - console.log('-------------------------------------------------------'); + const [removedContributors, cannotRemoveYet] = await removeInactiveMembers(previousContributors, inactiveWithOpenIssue, currentTeamMembers); + console.log(`-`.repeat(60)); console.log('Removed members from ' + writeTeam + ' inactive since ' + dates[1].slice(0, 10) + ':'); console.log(removedContributors); - console.log('-------------------------------------------------------'); + console.log(`-`.repeat(60)); console.log('Members inactive since ' + dates[1].slice(0, 10) + ' with open issues preventing removal:'); console.log(cannotRemoveYet); // Repeat getTeamMembers() after removedContributors to compare with recentContributors const updatedTeamMembers = await getTeamMembers(github, context, writeTeam); const notifiedContributors = await notifyInactiveMembers(updatedTeamMembers, recentContributors); - console.log('-------------------------------------------------------'); + console.log(`-`.repeat(60)); console.log('Notified members from ' + writeTeam + ' inactive since ' + dates[0].slice(0, 10) + ':'); console.log(notifiedContributors); @@ -61,11 +61,10 @@ async function main({ g, c }, { recentContributors, previousContributors, inacti * @returns {Array} removedMembers - List of members that were removed * @returns {Object} cannotRemoveYet - List of members that cannot be removed due to open issues */ -async function removeInactiveMembers(previousContributors, inactiveWithOpenIssue){ +async function removeInactiveMembers(previousContributors, inactiveWithOpenIssue, currentTeamMembers){ const removedMembers = []; const cannotRemoveYet = {}; const previouslyNotified = await readPreviousNotifyList(); - const currentTeamMembers = await getTeamMembers(github, context, writeTeam); // Loop over team members and remove them from the team if they are not in previousContributors list for(const username in currentTeamMembers){ @@ -81,6 +80,7 @@ async function removeInactiveMembers(previousContributors, inactiveWithOpenIssue // Remove member from all teams (except baseTeam) const teams = [writeTeam, mergeTeam]; for(const team of teams){ + // https://docs.github.com/en/rest/teams/members?apiVersion=2022-11-28#remove-team-membership-for-a-user await github.request('DELETE /orgs/{org}/teams/{team_slug}/memberships/{username}', { org: context.repo.owner, team_slug: team, @@ -101,20 +101,20 @@ async function removeInactiveMembers(previousContributors, inactiveWithOpenIssue /** - * Function to close a just-removed inactive member's "Pre-work checklist", if open, and add a comment - * @param {String} member - name of member whose "Pre-work checklist" will be closed - * @param {Number} issueNum - number of member's "Pre-work checklist" + * Function to close a just-removed inactive member's "Skills Issue", if open, and add a comment + * @param {String} member - name of member whose "Skills Issue" will be closed + * @param {Number} issueNum - number of member's "Skills Issue" */ async function closePrework(member, issueNum){ - // Close the assignee's "Pre-work Checklist" and add comment + // https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#update-an-issue await github.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', { owner: context.repo.owner, repo: context.repo.repo, issue_number: issueNum, state: 'closed' }); - console.log('Closing "Pre-work Checklist" issue number ' + issueNum + ' for ' + member); - // Add comment to issue + console.log(`Closing "Skills Issue" issue number ${issueNum} for ${member}`); + // https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#create-an-issue-comment await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', { owner: context.repo.owner, repo: context.repo.repo, @@ -211,8 +211,8 @@ function writeData(removedContributors, notifiedContributors, cannotRemoveYet){ fs.writeFile(filepath, JSON.stringify(inactiveMemberLists, null, 2), (err) => { if (err) throw err; - console.log('-------------------------------------------------------'); - console.log("File 'inactive-members.json' saved successfully!"); + console.log(`-`.repeat(60)); + console.log("File `inactive-members.json` saved successfully!"); }); } From 5c80b63d0bee181e2f29932348d41e18a8820392 Mon Sep 17 00:00:00 2001 From: Will Gillis <40799239+t-will-gillis@users.noreply.github.com> Date: Sat, 26 Oct 2024 10:45:09 -0700 Subject: [PATCH 4/5] Update trim-inactive-members.js Changing comment "Pre-work Checklist" --> "Skills Issue" --- .../list-inactive-members/trim-inactive-members.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js b/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js index 0c070bc49e..57be88d3fd 100644 --- a/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js +++ b/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js @@ -88,7 +88,7 @@ async function removeInactiveMembers(previousContributors, inactiveWithOpenIssue }); } removedMembers.push(username); - // After removal, close member's "Pre-work checklist" if open + // After removal, close member's "Skills Issue", if open if(username in inactiveWithOpenIssue && inactiveWithOpenIssue[username][1] === true){ closePrework(username, inactiveWithOpenIssue[username][0]); } From e889ac372d8b1752e20198e64a98dfae0f3bdafc Mon Sep 17 00:00:00 2001 From: Will Gillis <40799239+t-will-gillis@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:04:27 -0700 Subject: [PATCH 5/5] Update get-contributors-data.js Added third main update to consider comments if the `created_at` date is recent (in order to avoid a minimizing of a comment being considered as an update) --- .../list-inactive-members/get-contributors-data.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js b/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js index d3abf43cc7..0c8551563d 100644 --- a/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js +++ b/github-actions/trigger-schedule/list-inactive-members/get-contributors-data.js @@ -105,8 +105,8 @@ async function fetchContributors(dates){ if(contributorInfo.author){ allContributorsSince[contributorInfo.author.login] = true; } - // Check for username in `user.login`, but skip `user.login` covered by 3rd API - else if(contributorInfo.user && api != 'GET /repos/{owner}/{repo}/issues'){ + // Check for username in `user.login`, check only comment's `created_at` time, and skip `user.login` covered by 3rd API + else if(contributorInfo.user && contributorInfo.created_at > date && api != 'GET /repos/{owner}/{repo}/issues'){ allContributorsSince[contributorInfo.user.login] = true; } // This check is done for `/issues` (3rd) API. Sometimes a user who created an issue is not the same as the