Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

ci: add windows updater end-to-end jobs

ogsamratd95da81625d3
diff --git a/.github/workflows/build-electron-desktop.yml b/.github/workflows/build-electron-desktop.yml
index 0082ab04..5e68efdf 100644
--- a/.github/workflows/build-electron-desktop.yml
+++ b/.github/workflows/build-electron-desktop.yml
@@ -2,6 +2,15 @@ name: Build Electron Desktop
on:
workflow_dispatch:
+ inputs:
+ updater_e2e_only:
+ description: "Run only the Windows in-app updater end-to-end jobs"
+ type: boolean
+ default: false
+ next_version:
+ description: "Version the updater end-to-end build is stamped with (above every published release)"
+ type: string
+ default: "3.4.2"
push:
branches:
- electron-notary-test
@@ -19,6 +28,7 @@ permissions:
jobs:
build-electron:
+ if: ${{ !inputs.updater_e2e_only }}
strategy:
fail-fast: false
matrix:
@@ -78,6 +88,7 @@ jobs:
path: apps/desktop/dist-electron/**
windows-update-check:
+ if: ${{ !inputs.updater_e2e_only }}
name: Windows update in place
runs-on: windows-latest
@@ -121,7 +132,131 @@ jobs:
shell: pwsh
run: scripts/release/check-windows-update.ps1 -NewInstaller (Get-ChildItem apps/desktop/dist-electron/*.exe | Select-Object -First 1).FullName
+ # Published Windows releases update themselves with their own updater:
+ # each installs, opens with a DevTools port and goes through the same
+ # check, download and restart the required-update screen uses.
+ windows-updater-next:
+ name: Windows updater e2e build ${{ inputs.next_version }}
+ if: github.event_name == 'workflow_dispatch'
+ runs-on: windows-2022
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v4
+ with:
+ version: 11.4.0
+
+ - name: Setup Node
+ uses: actions/setup-node@v6
+ with:
+ node-version: 24
+
+ - name: Setup Bun
+ uses: oven-sh/setup-bun@v2
+ with:
+ bun-version: 1.3.10
+
+ - name: Set up Go (sandbox helpers)
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: apps/desktop/box/go/go.mod
+ cache: false
+
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile
+
+ # Built like Desktop Release builds it: stamped version, NSIS, manifest verified.
+ - name: Build the next release installer
+ shell: bash
+ env:
+ NEXT_VERSION: ${{ inputs.next_version }}
+ CSC_IDENTITY_AUTO_DISCOVERY: "false"
+ run: |
+ set -euo pipefail
+ node scripts/release/stamp-version.mjs --version "$NEXT_VERSION"
+ pnpm --filter @omnirush/desktop build:electron
+ pnpm --dir apps/desktop exec electron-builder --config electron-builder.yml --win --x64 --publish never
+ node apps/desktop/scripts/verify-update-manifest.mjs --manifest apps/desktop/dist-electron/latest.yml --version "$NEXT_VERSION"
+
+ - name: Upload the feed
+ uses: actions/upload-artifact@v4
+ with:
+ name: updater-e2e-feed
+ path: |
+ apps/desktop/dist-electron/latest.yml
+ apps/desktop/dist-electron/*.exe
+ apps/desktop/dist-electron/*.exe.blockmap
+
+ windows-updater-e2e:
+ name: Windows updater e2e ${{ matrix.from }} -> ${{ matrix.label }}
+ if: github.event_name == 'workflow_dispatch'
+ needs: windows-updater-next
+ runs-on: windows-2022
+ timeout-minutes: 30
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { from: "3.3.7", label: next, feed: local }
+ - { from: "3.3.8", label: next, feed: local }
+ - { from: "3.4.0", label: next, feed: local }
+ - { from: "3.4.1", label: next, feed: local }
+ # The public feed as it is now (whatever release is marked Latest).
+ - { from: "3.3.8", label: public-latest, feed: public }
+ # The dead end: 3.3.8's own manifest as the feed.
+ - { from: "3.3.8", label: same-version, feed: same }
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ sparse-checkout: scripts/release
+
+ - name: Setup Node
+ uses: actions/setup-node@v6
+ with:
+ node-version: 24
+
+ - name: Download the feed
+ if: matrix.feed == 'local'
+ uses: actions/download-artifact@v4
+ with:
+ name: updater-e2e-feed
+ path: feed
+
+ - name: Run the installed release's updater
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ FROM: ${{ matrix.from }}
+ FEED: ${{ matrix.feed }}
+ NEXT_VERSION: ${{ inputs.next_version }}
+ run: |
+ set -euo pipefail
+ case "$FEED" in
+ local) node scripts/release/windows-updater-e2e.mjs --from "$FROM" --expect "$NEXT_VERSION" --feed feed ;;
+ public)
+ latest="$(gh api repos/omnirush-ai/omnirush-gui/releases/latest --jq .tag_name)"
+ node scripts/release/windows-updater-e2e.mjs --from "$FROM" --expect "${latest#v}" ;;
+ same)
+ mkdir -p same
+ gh release download "v$FROM" --repo omnirush-ai/omnirush-gui --pattern latest.yml --dir same
+ node scripts/release/windows-updater-e2e.mjs --from "$FROM" --expect none --feed same ;;
+ esac
+
+ - name: Upload app logs
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: updater-e2e-logs-${{ matrix.from }}-${{ matrix.label }}
+ path: |
+ ${{ runner.temp }}/updater-e2e/*.log
+ ~/AppData/Roaming/ai.omnirush.desktop/logs/**
+ if-no-files-found: ignore
+
electron-macos-notarization-smoke:
+ if: ${{ !inputs.updater_e2e_only }}
name: Electron macOS notarization smoke
runs-on: macos-14
timeout-minutes: 300
diff --git a/scripts/release/windows-updater-e2e.mjs b/scripts/release/windows-updater-e2e.mjs
new file mode 100644
index 00000000..07e748b8
--- /dev/null
+++ b/scripts/release/windows-updater-e2e.mjs
@@ -0,0 +1,233 @@
+#!/usr/bin/env node
+/**
+ * Drives a published Windows release's own in-app updater, end to end, on a
+ * Windows machine (CI runner): installs v<from> with its NSIS installer, opens
+ * it with a DevTools port, and calls the same bridge the Updates page and the
+ * required-update screen call (check, download, installAndRestart). Then waits
+ * for the installed version to change and checks the app data is still there.
+ *
+ * node scripts/release/windows-updater-e2e.mjs --from 3.3.8 --expect 3.4.2 --feed <dir>
+ * node scripts/release/windows-updater-e2e.mjs --from 3.3.8 --expect 3.4.1 (the public Latest feed)
+ * node scripts/release/windows-updater-e2e.mjs --from 3.3.8 --expect none --feed <dir with 3.3.8's latest.yml>
+ *
+ * --feed serves a directory (latest.yml + installer) on a loopback port and
+ * points the app at it with OMNIRUSH_UPDATER_DEV_FEED_URL, which every
+ * release since the updater rewrite honors for loopback URLs only.
+ * --expect none: the check must report no update, and nothing may install.
+ */
+import { execFileSync, spawn } from "node:child_process";
+import { createReadStream, existsSync, mkdirSync, openSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
+import { createServer } from "node:http";
+import path from "node:path";
+
+const REPO = "omnirush-ai/omnirush-gui";
+const CDP_PORT = 9339;
+const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
+
+function argValue(name) {
+ const index = process.argv.indexOf(name);
+ return index >= 0 ? process.argv[index + 1] : undefined;
+}
+
+const from = argValue("--from");
+const expect = argValue("--expect");
+const feedDir = argValue("--feed");
+const workDir = path.resolve(argValue("--work") ?? path.join(process.env.RUNNER_TEMP ?? process.cwd(), "updater-e2e"));
+if (!from || !expect) {
+ console.error("Usage: windows-updater-e2e.mjs --from X.Y.Z --expect X.Y.Z|none [--feed dir] [--work dir]");
+ process.exit(2);
+}
+mkdirSync(workDir, { recursive: true });
+
+function log(message, data) {
+ console.log(`[e2e] ${message}${data === undefined ? "" : ` ${JSON.stringify(data)}`}`);
+}
+
+function installs() {
+ const script = "Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*' -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -match 'omnirush' } | Select-Object DisplayName,DisplayVersion,UninstallString | ConvertTo-Json -Compress";
+ const out = execFileSync("powershell", ["-NoProfile", "-Command", script], { encoding: "utf8" }).trim();
+ if (!out) return [];
+ const value = JSON.parse(out);
+ return Array.isArray(value) ? value : [value];
+}
+
+function installFolder(entry) {
+ const match = /^"([^"]+)"/.exec(entry.UninstallString ?? "");
+ return match ? path.dirname(match[1]) : null;
+}
+
+async function download(url, destination) {
+ const response = await fetch(url, { redirect: "follow" });
+ if (!response.ok) throw new Error(`GET ${url}: HTTP ${response.status}`);
+ writeFileSync(destination, Buffer.from(await response.arrayBuffer()));
+}
+
+function serveFeed(directory) {
+ return new Promise((resolve) => {
+ const server = createServer((request, response) => {
+ const name = decodeURIComponent(new URL(request.url, "http://127.0.0.1").pathname.slice(1));
+ const file = path.join(directory, name);
+ log(`feed ${request.method} /${name}`);
+ if (!name || name.includes("/") || name.includes("\\") || !existsSync(file)) {
+ response.writeHead(404).end();
+ return;
+ }
+ response.writeHead(200, { "content-length": statSync(file).size, "content-type": "application/octet-stream" });
+ if (request.method === "HEAD") return response.end();
+ createReadStream(file).pipe(response);
+ });
+ server.listen(0, "127.0.0.1", () => resolve({ server, url: `http://127.0.0.1:${server.address().port}` }));
+ });
+}
+
+async function cdpTargets() {
+ try {
+ const response = await fetch(`http://127.0.0.1:${CDP_PORT}/json/list`);
+ return response.ok ? await response.json() : [];
+ } catch {
+ return [];
+ }
+}
+
+function connect(wsUrl) {
+ return new Promise((resolve, reject) => {
+ const socket = new WebSocket(wsUrl);
+ let nextId = 0;
+ const pending = new Map();
+ socket.addEventListener("message", (event) => {
+ const message = JSON.parse(String(event.data));
+ const waiter = pending.get(message.id);
+ if (!waiter) return;
+ pending.delete(message.id);
+ waiter(message);
+ });
+ socket.addEventListener("close", () => {
+ for (const waiter of pending.values()) waiter({ error: { message: "socket closed" } });
+ pending.clear();
+ });
+ socket.addEventListener("error", () => reject(new Error(`cannot open ${wsUrl}`)));
+ socket.addEventListener("open", () => resolve({
+ socket,
+ async evaluate(expression, timeoutMs = 600_000) {
+ nextId += 1;
+ const id = nextId;
+ const answer = new Promise((done) => pending.set(id, done));
+ socket.send(JSON.stringify({ id, method: "Runtime.evaluate", params: { expression, awaitPromise: true, returnByValue: true } }));
+ const message = await Promise.race([answer, sleep(timeoutMs).then(() => ({ error: { message: "timed out" } }))]);
+ if (message.error) throw new Error(message.error.message);
+ if (message.result?.exceptionDetails) throw new Error(JSON.stringify(message.result.exceptionDetails));
+ return message.result?.result?.value;
+ },
+ }));
+ });
+}
+
+async function bridgePage(deadlineMs) {
+ const deadline = Date.now() + deadlineMs;
+ while (Date.now() < deadline) {
+ for (const target of (await cdpTargets()).filter((entry) => entry.type === "page" && entry.webSocketDebuggerUrl)) {
+ try {
+ const page = await connect(target.webSocketDebuggerUrl);
+ const ready = await page.evaluate("typeof window.__OMNIRUSH_ELECTRON__?.updater?.check === 'function'", 10_000);
+ if (ready) {
+ log(`bridge on ${target.url}`);
+ return page;
+ }
+ page.socket.close();
+ } catch {
+ // Not ready yet.
+ }
+ }
+ await sleep(2_000);
+ }
+ throw new Error("the app window never exposed the updater bridge");
+}
+
+function stopApp() {
+ try {
+ execFileSync("taskkill", ["/F", "/T", "/IM", "OmniRush.ai.exe"], { stdio: "ignore" });
+ } catch {
+ // Not running.
+ }
+}
+
+async function main() {
+ const installer = path.join(workDir, `omnirush-win-x64-${from}.exe`);
+ await download(`https://github.com/${REPO}/releases/download/v${from}/omnirush-win-x64-${from}.exe`, installer);
+ execFileSync(installer, ["/S"], { stdio: "inherit" });
+ const before = installs();
+ log("installed", before);
+ if (before.length !== 1 || before[0].DisplayVersion !== from) throw new Error(`expected one install of ${from}`);
+ const folder = installFolder(before[0]);
+ const exe = readdirSync(folder).find((name) => name.endsWith(".exe") && !/^Uninstall/i.test(name));
+ log("app", { folder, exe });
+
+ // Data the update must keep: a marker in userData (%APPDATA%\ai.omnirush.desktop).
+ const userData = path.join(process.env.APPDATA, "ai.omnirush.desktop");
+ mkdirSync(userData, { recursive: true });
+ writeFileSync(path.join(userData, "updater-e2e-marker.txt"), "kept");
+
+ const feed = feedDir ? await serveFeed(path.resolve(feedDir)) : null;
+ const env = {
+ ...process.env,
+ OMNIRUSH_ELECTRON_REMOTE_DEBUG_PORT: String(CDP_PORT),
+ ...(feed ? { OMNIRUSH_UPDATER_DEV_FEED_URL: feed.url } : {}),
+ };
+ const output = openSync(path.join(workDir, `app-${from}.log`), "a");
+ const child = spawn(path.join(folder, exe), [], { env, detached: true, stdio: ["ignore", output, output] });
+ child.unref();
+
+ const page = await bridgePage(240_000);
+ const run = (call) => page.evaluate(`window.__OMNIRUSH_ELECTRON__.updater.${call}`);
+ log("getChannel", await run("getChannel()"));
+ const checked = await run("check('stable')");
+ log("check", checked);
+
+ if (expect === "none") {
+ const downloaded = await run("download()");
+ log("download", downloaded);
+ stopApp();
+ feed?.server.close();
+ if (checked?.available !== false) throw new Error("the check offered an update");
+ if (downloaded?.ok !== false) throw new Error("a download started with no update available");
+ const after = installs();
+ if (after.length !== 1 || after[0].DisplayVersion !== from) throw new Error("the installed version changed");
+ log(`PASS: ${from} finds no update (feed offers ${checked.latestVersion}); download says: ${downloaded.reason}`);
+ return;
+ }
+
+ if (!checked?.available || checked.latestVersion !== expect) throw new Error(`the check did not offer ${expect}`);
+ const downloaded = await run("download()");
+ log("download", downloaded);
+ if (!downloaded?.ok) throw new Error(`download failed: ${downloaded?.reason}`);
+ // The app quits into the installer; the answer may never arrive.
+ void page.evaluate("window.__OMNIRUSH_ELECTRON__.updater.installAndRestart()", 180_000)
+ .then((result) => log("installAndRestart", result))
+ .catch((error) => log(`installAndRestart: ${error.message}`));
+
+ const deadline = Date.now() + 420_000;
+ let after = [];
+ while (Date.now() < deadline) {
+ after = installs();
+ if (after.length === 1 && after[0].DisplayVersion === expect) break;
+ await sleep(5_000);
+ }
+ log("after", after);
+ if (after.length !== 1 || after[0].DisplayVersion !== expect) throw new Error(`the install did not reach ${expect}`);
+ if (installFolder(after[0]) !== folder) throw new Error(`the update moved the app to ${installFolder(after[0])}`);
+ const version = execFileSync("powershell", ["-NoProfile", "-Command", `(Get-Item '${path.join(folder, exe)}').VersionInfo.ProductVersion`], { encoding: "utf8" }).trim();
+ log("executable version", version);
+ if (readFileSync(path.join(userData, "updater-e2e-marker.txt"), "utf8") !== "kept") throw new Error("app data was lost");
+ // The updated app relaunches by itself (quitAndInstall forceRunAfter).
+ const relaunched = await bridgePage(180_000).then(() => true).catch(() => false);
+ log("relaunched", relaunched);
+ stopApp();
+ feed?.server.close();
+ log(`PASS: ${from} updated itself to ${version} in ${folder}, data kept, relaunched=${relaunched}`);
+}
+
+main().then(() => process.exit(0), (error) => {
+ console.error(`[e2e] FAIL: ${error.message}`);
+ stopApp();
+ process.exit(1);
+});