From 9c2d5288d5978ab41d717abd4d4714c5dc4cb7a9 Mon Sep 17 00:00:00 2001 From: Kris Selden Date: Thu, 20 Jan 2022 16:53:17 -0800 Subject: [PATCH 1/2] Ensure OneShot tmp dir cleanup Move builder creation into build() call because when the builder is created it creates temp dirs. If you load the build file but don't build it never cleans up. --- packages/compat/src/one-shot.ts | 55 ++++++++++++++------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/packages/compat/src/one-shot.ts b/packages/compat/src/one-shot.ts index 3bc7e178e..4a993bc19 100644 --- a/packages/compat/src/one-shot.ts +++ b/packages/compat/src/one-shot.ts @@ -22,8 +22,6 @@ let seen = new WeakMap(); // Wraps a broccoli tree such that it (and everything it depends on) will only // build a single time. export default class OneShot extends Plugin { - private builder: NerfHeimdallBuilder | null; - static create(originalTree: Node, privateAddonName: string) { let output = seen.get(originalTree); if (!output) { @@ -33,46 +31,41 @@ export default class OneShot extends Plugin { return output; } - private constructor(originalTree: Node, private addonName: string) { + private constructor(private inner: Node | null, private addonName: string) { // from broccoli's perspective, we don't depend on any input trees! super([], { annotation: `@embroider/compat: ${addonName}`, persistentOutput: true, needsCache: false, }); - - // create a nested builder in order to isolate the specific addon - this.builder = new NerfHeimdallBuilder(originalTree); } async build() { - const { builder } = this; - - // only build the first time - if (builder === null) { - return; - } - this.builder = null; + const { inner } = this; + if (inner === null) return; + this.inner = null; - // Make a heimdall node so that we know for sure, all nodes created during our - // inner builder can be remove easily - const oneshotCookie = heimdall.start({ - name: `@embroider/compat: OneShot (${this.addonName})`, + await suppressNestedHeimdall(`OneShot(${this.addonName})`, async () => { + const builder = new NerfHeimdallBuilder(inner); + try { + await builder.build(); + copySync(builder.outputPath, this.outputPath, { dereference: true }); + } finally { + await builder.cleanup(); + } }); - const oneshotHeimdallNode = heimdall.current; + } +} - try { - await builder.build(); - copySync(builder.outputPath, this.outputPath, { dereference: true }); - await builder.cleanup(); - } finally { - oneshotCookie.stop(); - /* - Remove any of the current node's direct children, this ensures that we do not bloat the - current Broccoli builder's heimdall node graph (e.g. the one that is calling - OneShotPlugin; **not** the one that the OneShotPlugin internally creates). - */ - oneshotHeimdallNode.remove(); - } +async function suppressNestedHeimdall(name: string, using: () => Promise): Promise { + // Make a heimdall node so that we know for sure, all nodes created during our + // inner builder can be remove easily + const token = heimdall.start({ name }); + const node = heimdall.current; + try { + await using(); + } finally { + token.stop(); + node.remove(); } } From ce2ddf5cecc14aa90437301c70e6d6631d9d57dc Mon Sep 17 00:00:00 2001 From: Kris Selden Date: Thu, 20 Jan 2022 17:10:13 -0800 Subject: [PATCH 2/2] Fix CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 819169de6..14be19cb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: tags: - 'v*' pull_request: - branches: [master] + branches: [main] jobs: preflight: