Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 61 additions & 2 deletions scripts/build-desktop-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
readonly copyUnpackedNatives: boolean;
readonly serverEntrySource?: string;
readonly wslRuntime?: "valid" | "loose-server-tree" | "missing-pty" | "bad-digest";
readonly targetArch?: "x64" | "arm64";
readonly ptyPrebuildArch?: "x64" | "arm64";
}) {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
Expand Down Expand Up @@ -212,7 +214,7 @@
yield* fs.writeFileString(path.join(packagedAppDir, "chrome_crashpad_handler.exe"), "crashpad");

if (input.wslRuntime !== undefined) {
const stem = wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64");
const stem = wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, input.targetArch ?? "x64");
const sourceArchivePath =
input.wslRuntime === "loose-server-tree"
? // The old hand-rolled runtime: apps/server/dist + node_modules at the
Expand All @@ -226,9 +228,16 @@
: yield* makeLinuxCliArchiveFixture({
root: path.join(tempDir, "wsl-runtime"),
stem,
...(input.wslRuntime === "missing-pty"
...(input.wslRuntime === "missing-pty" || input.ptyPrebuildArch !== undefined
? { omitMembers: [`${stem}/node_modules/node-pty/build/Release/pty.node`] }
: {}),
...(input.ptyPrebuildArch !== undefined
? {
extraMembers: [
`${stem}/node_modules/node-pty/prebuilds/linux-${input.ptyPrebuildArch}/pty.node`,
],
}
: {}),
});
const archivePath = path.join(resourcesDir, WSL_RUNTIME_ARCHIVE_NAME);
const hashPath = path.join(resourcesDir, WSL_RUNTIME_ARCHIVE_HASH_NAME);
Expand Down Expand Up @@ -1109,7 +1118,7 @@
Effect.gen(function* () {
assert.equal(command._tag, "StandardCommand");
if (command._tag !== "StandardCommand") return mockProcess(1);
assert.equal(command.command, "cargo");

Check failure on line 1121 in scripts/build-desktop-artifact.test.ts

View workflow job for this annotation

GitHub Actions / Test (scripts)

build-desktop-artifact.test.ts > build-desktop-artifact > builds and stages native capture helpers for each Linux architecture

AssertionError: expected 'C:\Users\runneradmin\.cargo\bin\cargo…' to equal 'cargo' Expected: "cargo" Received: "C:\Users\runneradmin\.cargo\bin\cargo.EXE" ❯ build-desktop-artifact.test.ts:1121:26 ❯ IteratorImpl.~effect/Effect/successCont ../node_modules/.pnpm/effect@4.0.0-rc.115_patch_h_bf922b893f5453d0c9f086030e6520b9/node_modules/effect/src/internal/effect.ts:1428:27 ❯ IteratorImpl.~effect/Effect/evaluate ../node_modules/.pnpm/effect@4.0.0-rc.115_patch_h_bf922b893f5453d0c9f086030e6520b9/node_modules/effect/src/internal/effect.ts:1440:25 ❯ FiberImpl.runLoop ../node_modules/.pnpm/effect@4.0.0-rc.115_patch_h_bf922b893f5453d0c9f086030e6520b9/node_modules/effect/src/internal/effect.ts:685:39 ❯ FiberImpl.evaluate ../node_modules/.pnpm/effect@4.0.0-rc.115_patch_h_bf922b893f5453d0c9f086030e6520b9/node_modules/effect/src/internal/effect.ts:628:22 ❯ ../node_modules/.pnpm/effect@4.0.0-rc.115_patch_h_bf922b893f5453d0c9f086030e6520b9/node_modules/effect/src/internal/effect.ts:1167:16 ❯ ../node_modules/.pnpm/@effect+platform-node-share_dbac9bcf61d544da428cc692eefc4cda/node_modules/@effect/platform-node-shared/src/NodeFileSystem.ts:664:10
assert.deepEqual(command.args, [
"build",
"--locked",
Expand Down Expand Up @@ -1206,6 +1215,55 @@
).pipe(Effect.provideService(HostProcessPlatform, "linux")),
);

for (const targetArch of ["x64", "arm64"] as const) {
it.effect(`accepts an embedded archive with the Linux ${targetArch} node-pty prebuild`, () =>
Effect.scoped(
Effect.gen(function* () {
const fixture = yield* makeWindowsPayloadFixture({
copyUnpackedNatives: true,
wslRuntime: "valid",
targetArch,
ptyPrebuildArch: targetArch,
});
const result = yield* validateWindowsPackagedPayload({
stageDistDir: fixture.stageDistDir,
appExecutableName: fixture.appExecutableName,
targetArch,
appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION,
expectWslRuntime: true,
});

assert.equal(result.packagedAppDir, fixture.packagedAppDir);
}),
).pipe(Effect.provideService(HostProcessPlatform, "linux")),
);

it.effect(
`rejects a node-pty prebuild for the wrong architecture in a Linux ${targetArch} archive`,
() =>
Effect.scoped(
Effect.gen(function* () {
const fixture = yield* makeWindowsPayloadFixture({
copyUnpackedNatives: true,
wslRuntime: "valid",
targetArch,
ptyPrebuildArch: targetArch === "x64" ? "arm64" : "x64",
});
const error = yield* validateWindowsPackagedPayload({
stageDistDir: fixture.stageDistDir,
appExecutableName: fixture.appExecutableName,
targetArch,
appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION,
expectWslRuntime: true,
}).pipe(Effect.flip);

assert.instanceOf(error, WindowsPackagedPayloadValidationError);
assert.equal(error.reason, "wsl-runtime-invalid");
}),
),
);
}

it.effect("rejects an embedded archive built for a different release version", () =>
Effect.scoped(
Effect.gen(function* () {
Expand Down Expand Up @@ -1285,6 +1343,7 @@
assert.equal(error.reason, "wsl-runtime-invalid");
assert.deepStrictEqual(error.missingFiles, [
`${wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64")}/node_modules/node-pty/build/Release/pty.node`,
`${wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64")}/node_modules/node-pty/prebuilds/linux-x64/pty.node`,
]);
}),
),
Expand Down
13 changes: 8 additions & 5 deletions scripts/build-desktop-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3291,13 +3291,16 @@ export const validateWindowsPackagedPayload = Effect.fn(
),
);
}
const requiredMembers = [
`${stem}/t3`,
`${stem}/client`,
`${stem}/node_modules`,
const requiredMembers = [`${stem}/t3`, `${stem}/client`, `${stem}/node_modules`];
const missingMembers = requiredMembers.filter((member) => !members.includes(member));
// node-pty can load a source build or the prebuild for the WSL target.
const ptyCandidates = [
`${stem}/node_modules/node-pty/build/Release/pty.node`,
`${stem}/node_modules/node-pty/prebuilds/linux-${input.targetArch}/pty.node`,
];
const missingMembers = requiredMembers.filter((member) => !members.includes(member));
if (!ptyCandidates.some((member) => members.includes(member))) {
missingMembers.push(...ptyCandidates);
}
if (missingMembers.length > 0) {
return yield* new WindowsPackagedPayloadValidationError({
reason: "wsl-runtime-invalid",
Expand Down
Loading