Skip to content

Commit 5f238b7

Browse files
committed
Use memoize to remove unnecessary calls to git
1 parent 08a8f63 commit 5f238b7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.github/actions/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111
"dependencies": {
1212
"@actions/core": "^1.11.1",
13-
"@actions/exec": "^1.1.1"
13+
"@actions/exec": "^1.1.1",
14+
"lodash": "^4.17.21"
1415
},
1516
"scripts": {
1617
"build": "node ./build.js",

.github/actions/src/info/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import pathlib from 'path';
33
import utils from 'util';
44
import * as core from '@actions/core';
55
import { getExecOutput } from '@actions/exec';
6+
import memoize from 'lodash/memoize.js';
67
import getGitRoot from './gitRoot.js';
78

89
interface RawPackageRecord<T = boolean | null> {
@@ -51,7 +52,7 @@ type PackageRecord = BundlePackageRecord | TabPackageRecord | BasePackageRecord;
5152
* the master branch\
5253
* Used to determine, particularly for libraries if running tests and tsc are necessary
5354
*/
54-
export async function checkForChanges(directory: string) {
55+
export const checkForChanges = memoize(async (directory: string) => {
5556
const { exitCode } = await getExecOutput(
5657
'git',
5758
['--no-pager', 'diff', '--quiet', 'origin/master', '--', directory],
@@ -61,7 +62,7 @@ export async function checkForChanges(directory: string) {
6162
}
6263
);
6364
return exitCode !== 0;
64-
}
65+
});
6566

6667
/**
6768
* Retrieves the information for all packages in the repository
@@ -227,6 +228,11 @@ async function main() {
227228
...libs
228229
};
229230

231+
// Remove the root packages from the bundles and tabs collection
232+
// of packages cause they're not supposed be used like that
233+
delete bundles['@sourceacademy/bundles'];
234+
delete tabs['@sourceacademy/tabs'];
235+
230236
const summaryItems = Object.values(packages).map(packageInfo => {
231237
const relpath = pathlib.relative(gitRoot, packageInfo.directory);
232238
return `<div>

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,6 +3199,7 @@ __metadata:
31993199
"@actions/exec": "npm:^1.1.1"
32003200
"@sourceacademy/modules-repotools": "workspace:^"
32013201
"@types/node": "npm:^22.15.30"
3202+
lodash: "npm:^4.17.21"
32023203
typescript: "npm:^5.8.2"
32033204
vitest: "npm:^3.2.3"
32043205
languageName: unknown

0 commit comments

Comments
 (0)