fix(ci): normalize Windows ASAR paths in package audit

This commit is contained in:
tianma-if committed 2026-08-30 11:30:37 +08:00
1 parent 74d0f340fa
commit 95f2b8acb4
2 files changed
+9 -2

No files matched your search

+4
View File
@@ -3,6 +3,7 @@ import { describe, expect, test } from "bun:test";
const workflow = readFileSync(new URL("../.github/workflows/desktop-build.yml", import.meta.url), "utf8");
const mobileWorkflow = readFileSync(new URL("../.github/workflows/mobile-build.yml", import.meta.url), "utf8");
const desktopPackageVerifier = readFileSync(new URL("./verify-desktop-package.mjs", import.meta.url), "utf8");
function step(name) {
const start = workflow.indexOf(` - name: ${name}\n`);
@@ -78,5 +79,8 @@ describe("desktop release workflow", () => {
expect(workflow).toContain("allow-missing-windows-signature");
expect(workflow).toContain("name: Audit signed Windows update");
expect(workflow).toContain("verify-windows-update-release.mjs");
expect(desktopPackageVerifier).toContain(
'path.replaceAll("\\\\", "/")',
);
});
});
+5 -2
View File
@@ -25,6 +25,9 @@ const files = walk(outputDirectory);
const matchingPrefix = (prefix) => files.filter((path) => basename(path).startsWith(prefix));
const requestedPlatform = process.env.EDGE_EVER_VERIFY_TARGET ?? process.platform;
const requestedArch = process.env.EDGE_EVER_DESKTOP_ARCH ?? process.arch;
const listAsarFiles = (asarPath) => new Set(
listPackage(asarPath).map((path) => path.replaceAll("\\", "/")),
);
const verifyMachOArch = (path, arch, label) => {
const result = spawnSync("lipo", ["-archs", path], { encoding: "utf8" });
@@ -72,7 +75,7 @@ if (requestedPlatform === "darwin") {
verifyMachOArch(sidecar, requestedArch, "Rust sidecar");
const asarPath = join(appResources, "app.asar");
assert.ok(existsSync(asarPath), `macOS app bundle is missing app.asar: ${asarPath}`);
const asarFiles = new Set(listPackage(asarPath));
const asarFiles = listAsarFiles(asarPath);
assert.ok(asarFiles.has("/src/preload/index.cjs"), "macOS app bundle must contain the sandbox-compatible CommonJS preload");
assert.ok(!asarFiles.has("/src/preload/index.mjs"), "macOS app bundle must not contain the unsupported ESM preload");
const appIconPath = join(appResources, "icon.icns");
@@ -100,7 +103,7 @@ if (requestedPlatform === "darwin") {
verifyPeX64(sidecar, "Rust sidecar");
const asarPath = join(resources, "app.asar");
assert.ok(existsSync(asarPath), `Windows app bundle is missing app.asar: ${asarPath}`);
const asarFiles = new Set(listPackage(asarPath));
const asarFiles = listAsarFiles(asarPath);
assert.ok(asarFiles.has("/src/preload/index.cjs"), "Windows app bundle must contain the sandbox-compatible CommonJS preload");
assert.ok(!asarFiles.has("/src/preload/index.mjs"), "Windows app bundle must not contain the unsupported ESM preload");
} else if (requestedPlatform === "linux") {