Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

test(desktop): wait for complete Windows installation before startup checks (#776)

tianma-if3b791a050e16
diff --git a/.github/workflows/desktop-release-bridge.yml b/.github/workflows/desktop-release-bridge.yml
index c0ff9880..17ac97dc 100644
--- a/.github/workflows/desktop-release-bridge.yml
+++ b/.github/workflows/desktop-release-bridge.yml
@@ -3,6 +3,10 @@ name: Verify official old-to-new desktop updates
on:
workflow_dispatch:
inputs:
+ windows_only:
+ description: Rerun only the Windows published-release bridge
+ type: boolean
+ default: false
candidate_run:
description: Desktop build run containing the actual candidate installers
type: string
@@ -47,27 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- include:
- - platform: macOS
- runner: macos-15
- arch: arm64
- artifact: edgeever-desktop-macOS-arm64-staging
- pattern: EdgeEver-*-mac-arm64.zip
- - platform: macOS
- runner: macos-15-intel
- arch: x64
- artifact: edgeever-desktop-macOS-x64-staging
- pattern: EdgeEver-*-mac-x64.zip
- - platform: Windows
- runner: windows-latest
- arch: x64
- artifact: edgeever-desktop-Windows-x64-staging
- pattern: EdgeEver-*-windows-x64.exe
- - platform: Linux
- runner: ubuntu-22.04
- arch: x64
- artifact: edgeever-desktop-Linux-x64-staging
- pattern: EdgeEver-*-linux-x64.AppImage
+ include: ${{ fromJSON(inputs.windows_only && '[{"platform":"Windows","runner":"windows-latest","arch":"x64","artifact":"edgeever-desktop-Windows-x64-staging","pattern":"EdgeEver-*-windows-x64.exe"}]' || '[{"platform":"macOS","runner":"macos-15","arch":"arm64","artifact":"edgeever-desktop-macOS-arm64-staging","pattern":"EdgeEver-*-mac-arm64.zip"},{"platform":"macOS","runner":"macos-15-intel","arch":"x64","artifact":"edgeever-desktop-macOS-x64-staging","pattern":"EdgeEver-*-mac-x64.zip"},{"platform":"Windows","runner":"windows-latest","arch":"x64","artifact":"edgeever-desktop-Windows-x64-staging","pattern":"EdgeEver-*-windows-x64.exe"},{"platform":"Linux","runner":"ubuntu-22.04","arch":"x64","artifact":"edgeever-desktop-Linux-x64-staging","pattern":"EdgeEver-*-linux-x64.AppImage"}]') }}
env:
GH_TOKEN: ${{ github.token }}
CANDIDATE_RUN: ${{ inputs.candidate_run }}
diff --git a/scripts/native-update-windows.mjs b/scripts/native-update-windows.mjs
new file mode 100644
index 00000000..6859284a
--- /dev/null
+++ b/scripts/native-update-windows.mjs
@@ -0,0 +1,16 @@
+import { spawnSync } from "node:child_process";
+
+export const windowsUpdateInstallerRunning = (name) => {
+ const result = spawnSync("powershell", ["-NoProfile", "-Command", "@(Get-CimInstance Win32_Process | Where-Object { $_.Name -eq $env:UPDATE_INSTALLER_NAME }).Count"], {
+ env: { ...process.env, UPDATE_INSTALLER_NAME: name }, encoding: "utf8", timeout: 15_000, windowsHide: true,
+ });
+ if (result.status !== 0) throw new Error("Cannot inspect the isolated Windows installer process");
+ return Number(result.stdout.trim()) !== 0;
+};
+
+export const stopWindowsUpdateFixtures = () => {
+ // This name belongs only to the isolated CI fixture, never to EdgeEver.exe.
+ spawnSync("powershell", ["-NoProfile", "-Command", "Get-Process -Name EdgeEverUpdateVerifier -ErrorAction SilentlyContinue | ForEach-Object { taskkill /PID $_.Id /T /F | Out-Null }"], {
+ stdio: "ignore", timeout: 30_000, windowsHide: true,
+ });
+};
diff --git a/scripts/verify-native-desktop-update.mjs b/scripts/verify-native-desktop-update.mjs
index dc3ec782..2459f6d1 100644
--- a/scripts/verify-native-desktop-update.mjs
+++ b/scripts/verify-native-desktop-update.mjs
@@ -1,3 +1,4 @@
+import { windowsUpdateInstallerRunning, stopWindowsUpdateFixtures } from "./native-update-windows.mjs";
import { createServer } from "node:http";
import { createReadStream, existsSync, readFileSync, statSync, writeFileSync, mkdirSync, chmodSync, appendFileSync } from "node:fs";
import { cp, rm } from "node:fs/promises";
@@ -75,12 +76,19 @@ const installBaseline = async (directory) => {
return join(installed, "EdgeEver Update Verification.app/Contents/MacOS/EdgeEverUpdateVerifier");
}
if (process.platform === "win32") {
+ stopWindowsUpdateFixtures();
const installer = join(root, oldVersion, packageName(oldVersion));
- const result = spawnSync(installer, ["/S", `/D=${installed}`], {
+ let result;
+ for (let attempt = 0; attempt < 3; attempt++) {
+ result = spawnSync(installer, ["/S", `/D=${installed}`], {
stdio: "ignore", windowsHide: true, timeout: 120_000,
env: { ...process.env, EDGE_EVER_DISABLE_AUTO_UPDATE: "1" },
});
- if (result.status !== 0) throw new Error(`Baseline NSIS install failed: ${result.status} ${result.stderr}`);
+ if (result.status === 0) break;
+ stopWindowsUpdateFixtures();
+ await wait(2_000);
+ }
+ if (result.status !== 0) throw new Error(`Baseline NSIS install failed: ${result.status}`);
const executable = join(installed, "EdgeEverUpdateVerifier.exe");
spawnSync("powershell", ["-NoProfile", "-Command", `Get-CimInstance Win32_Process -Filter "Name='EdgeEverUpdateVerifier.exe'" | Where-Object { $_.ExecutablePath -eq $env:VERIFIER_INSTALLED_EXE } | ForEach-Object { taskkill /PID $_.ProcessId /T /F | Out-Null }`], {
stdio: "ignore", env: { ...process.env, VERIFIER_INSTALLED_EXE: executable }, timeout: 30_000,
@@ -171,6 +179,9 @@ try {
await until(() => {
try { return digest(installedPayload) === expectedDigest; } catch { return false; }
}, "native installation replaces the actual installed payload", 240_000);
+ if (process.platform === "win32") {
+ await until(() => !windowsUpdateInstallerRunning(packageName(latestVersion)), "Windows native installer completes");
+ }
await wait(1_000);
if (events().filter((entry) => entry.event === "boot").length !== 1) throw new Error("Normal quit relaunched the application");
// Confirm the installed executable itself now contains the new version.
@@ -179,6 +190,12 @@ try {
await command("install");
}
await until(() => events().some((entry) => entry.event === "boot" && entry.version === latestVersion), "latest installed application launches", 240_000);
+ await until(() => {
+ const entries = readEvents(join(profile, "logs/desktop.log"));
+ const lastSession = entries.findLastIndex((entry) => entry.event === "session.started");
+ const currentSession = entries.slice(lastSession);
+ return currentSession.some((entry) => entry.event === "renderer.bootstrap-ready") && currentSession.some((entry) => entry.event === "sidecar.ready");
+ }, "latest installed renderer and sidecar are ready");
const diagnostics = readEvents(join(profile, "logs/desktop.log"));
const installs = diagnostics.filter((entry) => entry.event === "update.install-confirmed");
const boots = events().filter((entry) => entry.event === "boot").map((entry) => entry.version);
@@ -193,6 +210,7 @@ try {
writeFileSync(join(directory, "result.json"), JSON.stringify(report.scenarios.at(-1), null, 2));
} finally {
await stopFixture(events());
+ if (process.platform === "win32") stopWindowsUpdateFixtures();
await wait(1_000);
}
}
diff --git a/scripts/verify-native-release-bridge.mjs b/scripts/verify-native-release-bridge.mjs
index 72c61afa..46ceb731 100644
--- a/scripts/verify-native-release-bridge.mjs
+++ b/scripts/verify-native-release-bridge.mjs
@@ -1,3 +1,4 @@
+import { windowsUpdateInstallerRunning } from "./native-update-windows.mjs";
import { createServer } from "node:http";
import { createServer as createTcpServer } from "node:net";
import { spawn, spawnSync } from "node:child_process";
@@ -145,6 +146,12 @@ try {
try { return digest(installedAsar) !== originalAsarDigest && (!expectedAsar || digest(installedAsar) === digest(expectedAsar)); } catch { return false; }
}, "official old release installs the real candidate payload");
await until(() => children[0].exitCode !== null, "old release exits");
+ if (process.platform === "win32") {
+ // NSIS copies app.asar before renderer resources. Wait for the installer,
+ // not just a changed ASAR, before launching the updated application.
+ await until(() => !windowsUpdateInstallerRunning(candidateName), "Windows installer completes all resource copies");
+ await wait(1_000);
+ }
if (existsSync(logPath)) renameSync(logPath, join(evidence, "old-desktop.log"));
await launch(false);
await until(() => {