Skip to content

Commit 60f8d0c

Browse files
authored
chore: ensure AUTHORS are generated automatically MONGOSH-647 (#745)
1 parent f296bec commit 60f8d0c

File tree

5 files changed

+59
-41
lines changed

5 files changed

+59
-41
lines changed

.github/workflows/cron-tasks.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
# Once a week or on pushes to master
3+
schedule:
4+
- cron: "0 3 * * 0"
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
update_third_party_notices_and_authors:
11+
name: Update THIRD_PARTY_NOTICES and AUTHORS
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: actions/setup-node@v2
16+
- name: Install Dependencies
17+
run: npm run bootstrap-ci
18+
- name: Set up Git
19+
run: |
20+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
21+
git config --local user.name "github-actions[bot]"
22+
- name: Update THIRD_PARTY_NOTICES.md
23+
run: npm run update-third-party-notices
24+
- name: Commit THIRD_PARTY_NOTICES changes
25+
run: |
26+
git commit --no-allow-empty -m "chore: update THIRD_PARTY_NOTICES" THIRD_PARTY_NOTICES.md || true
27+
- name: Update AUTHORS
28+
run: npm run update-authors
29+
- name: Commit AUTHORS changes
30+
run: |
31+
git add AUTHORS \*/AUTHORS
32+
git commit --no-allow-empty -m "chore: update AUTHORS" || true
33+
- name: Push updates
34+
uses: ad-m/[email protected]
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/update-third-party-notices.yml

-28
This file was deleted.

.mailmap

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ Massimiliano Marcon <[email protected]>Massimiliano Marcon <[email protected]>
88
Maurizio Casimirri <[email protected]> mcasimir <[email protected]>
99
Rhys Howell <rhys@[email protected]> Rhys <[email protected]>
1010
Rhys Howell <rhys@[email protected]> Rhys Howell <[email protected]>
11+
Rhys Howell <rhys@[email protected]> Anemy <rhys@[email protected]>
12+
Michael Rose <[email protected]> rosem <[email protected]>
13+
Sergey Petushkov <[email protected]> Sergey Petushkov <[email protected]>
14+
Sergey Petushkov <[email protected]> Sergey <[email protected]>

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"report-supported-api": "lerna run --stream --scope @mongosh/shell-api report-supported-api",
5454
"report-coverage": "nyc report --reporter=text --reporter=html && nyc check-coverage --lines=95",
5555
"generate-error-overview": "lerna run --stream --scope @mongosh/errors generate-error-overview",
56+
"update-authors": "ts-node -P config/tsconfig.base.json scripts/generate-authors.ts",
5657
"update-third-party-notices": "ts-node -P config/tsconfig.base.json scripts/gather-licenses.ts packages/cli-repl/ > THIRD_PARTY_NOTICES.md"
5758
},
5859
"config": {

scripts/generate-authors.js renamed to scripts/generate-authors.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env node
1+
#!/usr/bin/env ts-node
22

33
/*
44
* Generate an AUTHOR file on the repo root and on each lerna package based on git log.
@@ -7,22 +7,20 @@
77
* names / emails.
88
*/
99

10-
const { execSync } = require('child_process');
11-
const path = require('path');
12-
const fs = require('fs');
10+
import { execSync } from 'child_process';
11+
import path from 'path';
12+
import fs from 'fs';
1313

1414
const packageRootPath = path.resolve(__dirname, '..');
1515

16-
17-
18-
function getAuthorsGitLog(packagePath) {
16+
function getAuthorsGitLog(packagePath: string): string[] {
1917
return execSync(
2018
`git log --reverse --format='%aN <%aE>' --use-mailmap -- ${packagePath}`,
2119
{ cwd: packageRootPath }
2220
).toString().trim().split('\n');
2321
}
2422

25-
function getAuthorsOrderedByFirstCommit(packagePath) {
23+
function getAuthorsOrderedByFirstCommit(packagePath: string): string[] {
2624
const alreadyAdded = new Set();
2725
const authors = [];
2826

@@ -35,13 +33,20 @@ function getAuthorsOrderedByFirstCommit(packagePath) {
3533
return authors;
3634
}
3735

38-
function getAllPackages() {
39-
return JSON.parse(execSync(`lerna list -a --loglevel=error --json`,
40-
{ cwd: packageRootPath }
41-
).toString().trim());
36+
interface Package {
37+
location: string;
38+
}
39+
40+
function getAllPackages(): Package[] {
41+
return JSON.parse(
42+
execSync(
43+
`lerna list -a --loglevel=error --json`,
44+
{ cwd: packageRootPath }
45+
).toString().trim()
46+
);
4247
}
4348

44-
function renderAuthorsFileContent(authors) {
49+
function renderAuthorsFileContent(authors: string[]): string {
4550
return `${authors.join('\n')}\n`;
4651
}
4752

0 commit comments

Comments
 (0)