Файли
openidea/scripts/nightly-prepare.test.ts
T
l0ng-ai e03c5507f7 ci: publish a nightly prerelease of main every day (#6962)
nightly.yml builds main at 18:00 UTC, when it has moved since the last
nightly, as v<next patch>-nightly.<date>: a tag on a commit over main that
only sets the version (scripts/nightly-prepare.ts), built and published by
release.yml, which can now be called with `nightly: true` (notes from the
previous nightly; no official plugins, CNB mirror or Homebrew cask).

Nightly apps update from the rolling `nightly` release, which holds the
newest nightly's latest.json, and skip the CNB mirror, which carries only
stable releases. Stable apps keep reading releases/latest, never a
prerelease. The MSI gets a numeric version (last release + run number),
and the newest 14 nightlies are kept.
2026-11-30 15:55:50 +08:00

65 рядки
2.5 KiB
TypeScript

// @vitest-environment node
import { describe, expect, it } from "vitest";
import { NIGHTLY_ENDPOINT, msiVersion, nightlyVersion, setNightlyConfig } from "./nightly-prepare.ts";
describe("nightlyVersion", () => {
it("is the next patch's nightly once the current version is released", () => {
expect(nightlyVersion("0.1.55", true, "20261130", new Set(["v0.1.55"]))).toBe("0.1.56-nightly.20261130");
});
it("is the current version's nightly while that is not released", () => {
expect(nightlyVersion("0.1.56", false, "20261130", new Set())).toBe("0.1.56-nightly.20261130");
});
it("numbers further nightlies of the same day, which sort after the first", () => {
const tags = new Set(["v0.1.56-nightly.20261130", "v0.1.56-nightly.20261130.2"]);
expect(nightlyVersion("0.1.55", true, "20261130", tags)).toBe("0.1.56-nightly.20261130.3");
});
it("refuses a malformed date or version", () => {
expect(() => nightlyVersion("0.1.55", true, "2026-11-30", new Set())).toThrow();
expect(() => nightlyVersion("0.1", true, "20261130", new Set())).toThrow();
});
});
describe("msiVersion", () => {
it("is the last release with the build number", () => {
expect(msiVersion("0.1.55", true, 42)).toBe("0.1.55.42");
expect(msiVersion("0.1.56", false, 42)).toBe("0.1.55.42");
expect(msiVersion("0.2.0", false, 42)).toBe("0.2.0.42");
});
it("refuses a build number MSI cannot hold", () => {
expect(() => msiVersion("0.1.55", true, 65536)).toThrow();
expect(() => msiVersion("0.1.55", true, Number.NaN)).toThrow();
});
});
describe("setNightlyConfig", () => {
it("sets the version, the nightly manifest and the MSI version, keeping the rest", () => {
const json = JSON.stringify(
{
version: "0.1.55",
bundle: { targets: "all", macOS: { minimumSystemVersion: "11.0" } },
plugins: { updater: { pubkey: "key", endpoints: ["https://example.com/latest.json"] } },
},
null,
2,
);
const config = JSON.parse(setNightlyConfig(json, "0.1.56-nightly.20261130", "0.1.55.42"));
expect(config.version).toBe("0.1.56-nightly.20261130");
expect(config.plugins.updater).toEqual({ pubkey: "key", endpoints: [NIGHTLY_ENDPOINT] });
expect(config.bundle).toEqual({
targets: "all",
macOS: { minimumSystemVersion: "11.0" },
windows: { wix: { version: "0.1.55.42" } },
});
});
it("refuses a config without the updater", () => {
expect(() =>
setNightlyConfig(JSON.stringify({ version: "0.1.55" }), "0.1.56-nightly.20261130", "0.1.55.1"),
).toThrow();
});
});