Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions .github/workflows/find-inactive-collaborators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ on:

workflow_dispatch:

env:
NODE_VERSION: 16.x
NUM_COMMITS: 5000

jobs:
find:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: tools/find-inactive-collaborators.mjs '1 year ago'
- uses: actions/checkout@v2
with:
fetch-depth: ${{ env.NUM_COMMITS }}

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Find inactive collaborators
run: tools/find-inactive-collaborators.mjs ${{ env.NUM_COMMITS }}
21 changes: 11 additions & 10 deletions tools/find-inactive-collaborators.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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], {
Expand Down Expand Up @@ -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()
);

Expand Down Expand Up @@ -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) &&
Expand All @@ -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'));
}