Skip to content

Commit 098a6bb

Browse files
committed
feat(compat): Add no-cache mode to patch generator
1 parent 55d1212 commit 098a6bb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.github/workflows/plugin-compat-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ jobs:
6666
if: github.event.pull_request != ''
6767
env:
6868
TARGET_BRANCH: ${{github.event.pull_request.base.ref}}
69+
GEN_PATCHES_NO_CACHE: '1'

packages/plugin-compat/extra/PatchGenerator.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {logger, spawn} from './utils';
1212
export abstract class PatchGenerator<S extends {id: string, range: string}> {
1313
protected readonly tmp: PortablePath;
1414
protected readonly patches: PortablePath;
15+
protected noCache = process.env.GEN_PATCHES_NO_CACHE !== undefined;
1516

1617
public constructor(
1718
public readonly name: string,
@@ -223,6 +224,18 @@ export abstract class PatchGenerator<S extends {id: string, range: string}> {
223224
}
224225

225226
process.off(`exit`, clearBuildCache);
227+
228+
if (this.noCache) {
229+
await logger.section(`Clean cache`, async () => {
230+
const versions = await this.getValidateVersions(slice);
231+
await Promise.all([
232+
xfs.removePromise(ppath.join(this.tmp, `builds`, slice.id as Filename)),
233+
...versions.map(version => xfs.removePromise(ppath.join(this.tmp, `validate`, version as Filename))),
234+
...versions.map(version => xfs.removePromise(ppath.join(this.tmp, `tarballs`, `${version}.tgz`))),
235+
]);
236+
});
237+
}
238+
226239
return content;
227240
});
228241
}
@@ -284,6 +297,11 @@ export abstract class PatchGenerator<S extends {id: string, range: string}> {
284297
});
285298

286299
await logger.section(`Prune caches`, async () => {
300+
if (this.noCache) {
301+
await xfs.removePromise(this.tmp);
302+
return;
303+
}
304+
287305
const buildNames = new Set(this.slices.map(slice => slice.id as Filename));
288306
const patchNames = new Set(this.slices.map(slice => `patch-${slice.id}.diff` as Filename));
289307

0 commit comments

Comments
 (0)