Skip to content
TypeScript

ci: fail PRs on invalid allowBuilds entries in pnpm-workspace.yaml (#18564)

Theo Browneeac6ba5ae9df
diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts
index 434f7a886a3..2d86a9c89d5 100644
--- a/scripts/build-desktop-artifact.test.ts
+++ b/scripts/build-desktop-artifact.test.ts
@@ -22,6 +22,7 @@ import {
DesktopDmgBackgroundSourceMissingError,
createStageWorkspaceConfig,
createStagePatchedDependencies,
+ readWorkspaceConfig,
createBuildConfig,
DESKTOP_ELECTRON_LANGUAGES,
DESKTOP_FILE_EXCLUSIONS,
@@ -497,6 +498,25 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
});
});
+ // pnpm writes "set this to true or false" placeholders into allowBuilds when a
+ // tarball changes. pnpm ignores them, but the release build decode rejects them.
+ it.effect("decodes the repo allowBuilds and every file: tarball it names exists", () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const { allowBuilds = {} } = yield* readWorkspaceConfig();
+ const repoRoot = path.join(import.meta.dirname, "..");
+ for (const key of Object.keys(allowBuilds)) {
+ const tarball = key.split("@file:")[1];
+ if (tarball === undefined) continue;
+ assert.isTrue(
+ yield* fs.exists(path.join(repoRoot, tarball)),
+ `allowBuilds names a missing tarball: ${key}`,
+ );
+ }
+ }),
+ );
+
it("stages pnpm 11 allowBuilds and patchedDependencies in the workspace yaml", () => {
assert.deepStrictEqual(
createStageWorkspaceConfig({
diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts
index c4ca2e6dd7d..618aec4d6bb 100644
--- a/scripts/build-desktop-artifact.ts
+++ b/scripts/build-desktop-artifact.ts
@@ -111,7 +111,9 @@ const encodeJsonString = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknow
const decodeWorkspaceConfig = Schema.decodeEffect(fromYaml(WorkspaceConfig));
const encodeStageWorkspaceConfig = Schema.encodeEffect(fromYaml(StageWorkspaceConfig));
-const readWorkspaceConfig = Effect.fn("readWorkspaceConfig")(function* () {
+// Decodes the repo's pnpm-workspace.yaml. A PR CI test calls this too, so a bad
+// entry fails the PR instead of the nightly desktop build.
+export const readWorkspaceConfig = Effect.fn("readWorkspaceConfig")(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const repoRoot = yield* RepoRoot;