release.test.ts

2.7 KB · raw

1import { execFileSync } from "node:child_process";2import { existsSync, mkdtempSync, readFileSync } from "node:fs";3import { fileURLToPath } from "node:url";4import { dirname, join, resolve } from "node:path";5import { tmpdir } from "node:os";6import { describe, expect, it } from "vitest";78const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");9// PB-26-211: packaging/signing logic moved to release-lib.ts. Both release10// entry points import from it, so verifying release-lib.ts covers both.11const RELEASE_LIB = "scripts/release-lib.ts";1213function readReleaseLib(): string {14  return readFileSync(join(ROOT, RELEASE_LIB), "utf8");15}1617describe("Firefox release source submission", () => {18  it("passes the generated source archive to web-ext sign with --upload-source-code", () => {19    const source = readReleaseLib();20    // web-ext sign is called with --upload-source-code and the source zip path.21    expect(source).toContain('"--upload-source-code"');22    expect(source).toContain("sourceZip");23    expect(source.match(/--upload-source-code/g)).toHaveLength(1);24  });2526  it("builds an archive containing the reviewed crypto source and Noise build script", () => {27    const archive = join(mkdtempSync(join(tmpdir(), "peach-source-test-")), "source.zip");28    execFileSync(29      "zip",30      [31        "-q",32        "-r",33        archive,34        "src",35        "scripts",36        "public",37        "crypto-core",38        "manifest.json",39        "manifest.firefox.json",40        "package.json",41        "bun.lock",42        "tsconfig.json",43        "vite.config.ts",44        "--exclude",45        "node_modules/*",46        "--exclude",47        "dist-*/*",48        "--exclude",49        "crypto-core/target/*",50        "--exclude",51        "crypto-core/generated/*",52        "--exclude",53        "*.zip",54        "--exclude",55        ".DS_Store",56        "--exclude",57        "__MACOSX/*",58      ],59      { cwd: ROOT },60    );6162    const contents = execFileSync("unzip", ["-Z1", archive], { encoding: "utf8" }).split("\n");63    expect(contents).toEqual(64      expect.arrayContaining([65        "crypto-core/Cargo.toml",66        "crypto-core/Cargo.lock",67        "crypto-core/src/lib.rs",68        "scripts/build-noise-core.mjs",69      ]),70    );7172    // PB-26-211: verify release-lib.ts includes crypto-core in the source archive.73    const source = readReleaseLib();74    expect(source).toContain('"crypto-core"');75    expect(existsSync(join(ROOT, "crypto-core/Cargo.toml"))).toBe(true);76    expect(existsSync(join(ROOT, "crypto-core/Cargo.lock"))).toBe(true);77    expect(existsSync(join(ROOT, "crypto-core/src/lib.rs"))).toBe(true);78    expect(existsSync(join(ROOT, "scripts/build-noise-core.mjs"))).toBe(true);79  });80});