mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-21 00:03:52 +00:00
ci: build nightly versions twice a day (#2136)
Adds a nightly channel. Twice a day nightly.yml builds the newest main commit that passed CI and publishes it as a prerelease (OpenIDEA Nightly, ai.l0ng.openidea.nightly, own data and update manifest), or stops when nothing is newer than the last nightly. Platform builds move from release.yml into the reusable release-build.yml so both channels build the same way. Versions are one patch above main with a timestamp suffix; each build gets its own v…-nightly.… tag (remote development downloads the server by version) and the last 14 are kept; a rolling nightly release holds latest.json. No MSI or RPM for nightlies. Nightly builds skip the CNB mirror manifest, and their automatic update prompts (startup and periodic) appear at most once a day; a manual check always answers. Workflow permissions default to contents: read with write granted per job, Apple signing secrets reach only macOS builds, stable release.yml rejects nightly tags, tag pruning only matches -nightly. tags, and nightly runs share one concurrency group.
This commit is contained in:
@@ -403,6 +403,68 @@ describe("Check for Updates", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("automatic nightly update prompts", () => {
|
||||
const DAY = 24 * 60 * 60 * 1000;
|
||||
const update = (currentVersion: string): UpdateInfo => ({
|
||||
version: "0.1.41",
|
||||
currentVersion,
|
||||
notes: null,
|
||||
date: null,
|
||||
});
|
||||
const startupCheck = async (currentVersion: string) => {
|
||||
notes = [];
|
||||
await notifyUpdate(update(currentVersion));
|
||||
return notes.length;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
vi.useFakeTimers({ toFake: ["Date"], now: 10 * DAY });
|
||||
});
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
it("leaves stable prompts to the backend announcement policy", async () => {
|
||||
expect(await startupCheck("0.1.40")).toBe(1);
|
||||
expect(await startupCheck("0.1.40")).toBe(1);
|
||||
});
|
||||
|
||||
it("asks a nightly build at most once a day", async () => {
|
||||
const nightly = "0.1.41-nightly.202611081417";
|
||||
expect(await startupCheck(nightly)).toBe(1);
|
||||
vi.setSystemTime(11 * DAY - 1);
|
||||
expect(await startupCheck(nightly)).toBe(0);
|
||||
vi.setSystemTime(11 * DAY);
|
||||
expect(await startupCheck(nightly)).toBe(1);
|
||||
});
|
||||
|
||||
it("does not prompt twice a day for periodic nightly checks, but always answers a manual check", async () => {
|
||||
const nightly = "0.1.41-nightly.202611081417";
|
||||
const dispose = installUpdateChecks();
|
||||
await tick();
|
||||
try {
|
||||
const available = updateListeners.get("updateAvailable")!;
|
||||
available({ update: update(nightly) });
|
||||
await tick();
|
||||
expect(notes).toHaveLength(1);
|
||||
vi.setSystemTime(10 * DAY + 4 * 60 * 60 * 1000);
|
||||
available({ update: { ...update(nightly), version: "0.1.42-nightly.202611090200" } });
|
||||
await tick();
|
||||
expect(notes).toHaveLength(1);
|
||||
const done = checkForUpdates();
|
||||
check.resolve(ok({ enabled: true, update: update(nightly) }));
|
||||
await done;
|
||||
expect(notes.at(-1)).toMatchObject({ title: "OpenIDEA 0.1.41 is available", userInitiated: true });
|
||||
notes = [];
|
||||
vi.setSystemTime(11 * DAY);
|
||||
available({ update: { ...update(nightly), version: "0.1.42-nightly.202611091400" } });
|
||||
await tick();
|
||||
expect(notes).toHaveLength(1);
|
||||
} finally {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateSource", () => {
|
||||
const withSettings = (updateSource: string | undefined, locale: string | undefined) =>
|
||||
useProject.setState({ settings: { general: { updateSource }, appearance: { locale } } as unknown as Settings });
|
||||
|
||||
@@ -127,6 +127,17 @@ async function runCheck() {
|
||||
}
|
||||
}
|
||||
|
||||
const NIGHTLY_PROMPT_KEY = "openidea.update.nightlyPromptedAt";
|
||||
const NIGHTLY_PROMPT_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
/** Nightly builds come out more often than anyone wants to be asked: at most one prompt a day. */
|
||||
function nightlyPromptDue(now = Date.now()): boolean {
|
||||
const last = Number(localStorage.getItem(NIGHTLY_PROMPT_KEY));
|
||||
if (now - last < NIGHTLY_PROMPT_INTERVAL_MS) return false;
|
||||
localStorage.setItem(NIGHTLY_PROMPT_KEY, String(now));
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Start one backend schedule after this window can receive its notifications. */
|
||||
export function installUpdateChecks(): () => void {
|
||||
let disposed = false;
|
||||
@@ -154,6 +165,7 @@ export async function notifyUpdate(update: UpdateInfo, userInitiated = false): P
|
||||
);
|
||||
if (!claimed) return;
|
||||
}
|
||||
if (!userInitiated && update.currentVersion.includes("-nightly.") && !nightlyPromptDue()) return;
|
||||
notifications().notify({
|
||||
level: "info",
|
||||
title: t("app.update.available", { version: update.version }),
|
||||
|
||||
Reference in New Issue
Block a user