release-policy.test.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { expect, test } from "bun:test"
  2. import { execFileSync } from "node:child_process"
  3. function config(unsigned: boolean) {
  4. return JSON.parse(
  5. execFileSync(
  6. process.execPath,
  7. [
  8. "-e",
  9. `
  10. import config from "./electron-builder.config.ts";
  11. import { Arch } from "electron-builder";
  12. let rejected = false;
  13. try { await config.beforePack({ electronPlatformName: "other", arch: Arch.arm64 }); }
  14. catch { rejected = true; }
  15. console.log(JSON.stringify({ forceCodeSigning: config.forceCodeSigning, rejected }));
  16. `,
  17. ],
  18. {
  19. cwd: new URL("..", import.meta.url),
  20. env: {
  21. ...process.env,
  22. OPENCODE_CHANNEL: "beta",
  23. LAMBDA_AGENT_EXTERNAL_SERVICES: "0",
  24. LAMBDA_AGENT_ALLOW_UNSIGNED: unsigned ? "1" : "0",
  25. },
  26. encoding: "utf8",
  27. },
  28. ),
  29. )
  30. }
  31. test("release packaging requires signatures on supported platforms and rejects foreign runtimes", () => {
  32. expect(config(false)).toEqual({ forceCodeSigning: process.platform !== "linux", rejected: true })
  33. })
  34. test("explicit internal previews may be unsigned but still require a matching runtime", () => {
  35. expect(config(true)).toEqual({ forceCodeSigning: false, rejected: true })
  36. })