tools: change commit fetch limiting in find-inactive-collaborators

GitHub Action workflows can be told to clone a certain number of commits
or else everything. Change find-inactive-collaborators to take a number
of commits to examine rather than a date range so that the parameter can
be used in GitHub Actions.

PR-URL: https://github.com/nodejs/node/pull/39362
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Rich Trott
2021-07-12 09:22:27 -07:00
parent 4292264c51
commit 1bb660e2e0
2 changed files with 21 additions and 14 deletions

View File

@@ -7,6 +7,10 @@ on:
workflow_dispatch:
env:
NODE_VERSION: 16.x
NUM_COMMITS: 5000
jobs:
find:
@@ -14,11 +18,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Node.js
with:
fetch-depth: ${{ env.NUM_COMMITS }}
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: ${{ env.NODE_VERSION }}
- name: Find inactive collaborators
run: tools/find-inactive-collaborators.mjs '1 year ago'
run: tools/find-inactive-collaborators.mjs ${{ env.NUM_COMMITS }}

View File

@@ -8,7 +8,7 @@ import cp from 'node:child_process';
import fs from 'node:fs';
import readline from 'node:readline';
const SINCE = process.argv[2] || '6 months ago';
const SINCE = +process.argv[2] || 5000;
async function runGitCommand(cmd, mapFn) {
const childProcess = cp.spawn('/bin/sh', ['-c', cmd], {
@@ -36,19 +36,19 @@ async function runGitCommand(cmd, mapFn) {
// Get all commit authors during the time period.
const authors = await runGitCommand(
`git shortlog -n -s --since="${SINCE}"`,
`git shortlog -n -s --max-count="${SINCE}" HEAD`,
(line) => line.trim().split('\t', 2)[1]
);
// Get all commit landers during the time period.
const landers = await runGitCommand(
`git shortlog -n -s -c --since="${SINCE}"`,
`git shortlog -n -s -c --max-count="${SINCE}" HEAD`,
(line) => line.trim().split('\t', 2)[1]
);
// Get all approving reviewers of landed commits during the time period.
const approvingReviewers = await runGitCommand(
`git log --since="${SINCE}" | egrep "^ Reviewed-By: "`,
`git log --max-count="${SINCE}" | egrep "^ Reviewed-By: "`,
(line) => /^ Reviewed-By: ([^<]+)/.exec(line)[1].trim()
);
@@ -78,10 +78,11 @@ async function retrieveCollaboratorsFromReadme() {
// Get list of current collaborators from README.md.
const collaborators = await retrieveCollaboratorsFromReadme();
console.log(`${authors.size.toLocaleString()} authors have made commits since ${SINCE}.`);
console.log(`${landers.size.toLocaleString()} landers have landed commits since ${SINCE}.`);
console.log(`${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits since ${SINCE}.`);
console.log(`${collaborators.length.toLocaleString()} collaborators currently in the project.`);
console.log(`In the last ${SINCE} commits:\n`);
console.log(`* ${authors.size.toLocaleString()} authors have made commits.`);
console.log(`* ${landers.size.toLocaleString()} landers have landed commits.`);
console.log(`* ${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits.`);
console.log(`* ${collaborators.length.toLocaleString()} collaborators currently in the project.`);
const inactive = collaborators.filter((collaborator) =>
!authors.has(collaborator) &&
@@ -90,6 +91,6 @@ const inactive = collaborators.filter((collaborator) =>
);
if (inactive.length) {
console.log('\nInactive collaborators:');
console.log(inactive.join('\n'));
console.log('\nInactive collaborators:\n');
console.log(inactive.map((name) => `* ${name}`).join('\n'));
}