Skip to content

The agent that grows with you

test(desktop-e2e): run the core Desktop E2E on the PM toolchain

ethernet890e9b73d47a
diff --git a/.github/workflows/e2e-desktop-core.yml b/.github/workflows/e2e-desktop-core.yml
index c0bc74ca8e0..0e288aca842 100644
--- a/.github/workflows/e2e-desktop-core.yml
+++ b/.github/workflows/e2e-desktop-core.yml
@@ -37,13 +37,13 @@ jobs:
libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 \
xdg-utils libatspi2.0-0 libdrm2 libgbm1 libasound2t64
- - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ - name: Prepare locked Desktop build and test toolchain
+ id: pm
+ uses: ./.github/actions/setup-pm
with:
- node-version: 26
- cache: npm
-
- - name: grab npm 12
- run: npm i -g npm@12
+ toolchain: all
+ extras: '[]'
+ test-environment: 'true'
# Full npm ci (not --ignore-scripts): electron's postinstall downloads
# the binary we launch.
@@ -51,29 +51,10 @@ jobs:
with:
command: npm ci
- - name: Install uv
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # 8.2.0
- with:
- version: '0.9.28'
- enable-cache: true
- cache-dependency-glob: |
- pyproject.toml
- uv.lock
-
- - name: Set up Python 3.14
- uses: ./.github/actions/retry
- with:
- command: uv python install 3.14
-
- - name: Install Python dependencies
- uses: ./.github/actions/retry
- with:
- command: uv sync --locked --python 3.14 --extra all --group dev
-
- name: Build the desktop app
working-directory: apps/desktop
# The generator uses the runtime's Pillow + resvg-py, not a build-only venv.
- run: HERMES_PYTHON="$GITHUB_WORKSPACE/.venv/bin/python" npm run build
+ run: npm run build
# Package the Linux app the way users get it (electron-builder --dir; no
# installer formats, no publish). Reuses the npm-installed Electron dist,
@@ -90,6 +71,7 @@ jobs:
npx playwright test -c e2e/core/playwright.config.ts
env:
CI: 'true'
+ HERMES_E2E_PYTHON: ${{ steps.pm.outputs.python-path }}
# The pack step above ran: a missing release/linux-unpacked is a failure, not a skip.
HERMES_E2E_REQUIRE_PACKAGED: '1'
OPENROUTER_API_KEY: ''
diff --git a/apps/desktop/e2e/core/harness.ts b/apps/desktop/e2e/core/harness.ts
index 1288681d8de..85f2c1df0f1 100644
--- a/apps/desktop/e2e/core/harness.ts
+++ b/apps/desktop/e2e/core/harness.ts
@@ -144,6 +144,9 @@ export function coreAppEnv(sandbox: CoreSandbox, extra: Record<string, string> =
HERMES_DESKTOP_USER_DATA_DIR: sandbox.userDataDir,
HERMES_DESKTOP_IGNORE_EXISTING: '1',
HERMES_DESKTOP_HERMES_ROOT: REPO_ROOT,
+ // setup-pm exports an install-scoped interpreter, not a checkout .venv.
+ // The Desktop override must be explicit because the sandbox strips HERMES_*.
+ ...(process.env.HERMES_E2E_PYTHON ? { HERMES_DESKTOP_PYTHON: process.env.HERMES_E2E_PYTHON } : {}),
HERMES_DESKTOP_APP_NAME: `HermesCoreE2E-${path.basename(sandbox.root)}`,
HERMES_DESKTOP_SKIP_QUIT_CONFIRM: '1',
HERMES_DESKTOP_CDP_PORT: 'off',
diff --git a/apps/desktop/e2e/core/packaged-smoke.spec.ts b/apps/desktop/e2e/core/packaged-smoke.spec.ts
index de7cc4c4ae4..53aa40f88ee 100644
--- a/apps/desktop/e2e/core/packaged-smoke.spec.ts
+++ b/apps/desktop/e2e/core/packaged-smoke.spec.ts
@@ -7,7 +7,7 @@
* was never generated — #121097) ships green. This spec reads the Linux
* `electron-builder --dir` output in release/ and asserts:
*
- * 1. asarUnpack contract, derived from apps/desktop/package.json at test time
+ * 1. asar.unpack contract, derived from electron-builder.config.cjs at test time
* (never a file-list snapshot): for every declared glob, matched with the
* packager's own matcher semantics (minimatch, dot: true), every archive
* entry it matches is flagged unpacked AND present on disk under
@@ -22,7 +22,7 @@
* the LLM faked (scripted loopback provider) completes a first turn: the
* reply is rendered, persisted (state.db + REST), and passes the core
* transcript oracle. The packaged app is pointed at THIS checkout's
- * Python backend (HERMES_DESKTOP_HERMES_ROOT = repo root, its .venv), so
+ * Python backend (HERMES_DESKTOP_HERMES_ROOT = repo root, selected PM interpreter), so
* this proves the packaged Electron shell + renderer, not a bundled
* backend/runtime install.
*
@@ -32,6 +32,7 @@
* by the sabotage proofs on a copied release).
*/
+import { execFileSync } from 'node:child_process'
import * as fs from 'node:fs'
import { createRequire } from 'node:module'
import * as path from 'node:path'
@@ -66,20 +67,19 @@ const A = (n: number) => `A${n}-${nonce}`
// ─── Locating the packaged build ────────────────────────────────────────
interface BuildConfig {
- productName?: string
executableName?: string
- asarUnpack?: string | string[]
+ asar?: { unpack?: string | string[] }
directories?: { output?: string }
- linux?: { executableName?: string; asarUnpack?: string | string[] }
+ linux?: { executableName?: string }
}
-interface DesktopPackageJson {
- name: string
- main: string
- build: BuildConfig
-}
-
-const PKG = JSON.parse(fs.readFileSync(path.join(DESKTOP_ROOT, 'package.json'), 'utf8')) as DesktopPackageJson
+const builderRequire = createRequire(path.join(DESKTOP_ROOT, 'package.json'))
+// Playwright's TS loader intercepts CJS require() of the config's ESM hooks.
+// Load it in plain Node, exactly as electron-builder does.
+const BUILD = JSON.parse(
+ execFileSync(process.execPath, ['-e', 'process.stdout.write(JSON.stringify(require(process.argv[1])))',
+ path.join(DESKTOP_ROOT, 'electron-builder.config.cjs')], { encoding: 'utf8' })
+) as BuildConfig
/** electron-builder's Linux `--dir` output: `linux-unpacked` for x64, `linux-<arch>-unpacked` otherwise. */
function unpackedDir(): string {
@@ -87,7 +87,7 @@ function unpackedDir(): string {
return path.resolve(process.env.HERMES_E2E_PACKAGED_DIR)
}
- const out = path.resolve(DESKTOP_ROOT, PKG.build.directories?.output ?? 'dist')
+ const out = path.resolve(DESKTOP_ROOT, BUILD.directories?.output ?? 'dist')
const arch = process.arch === 'x64' ? '' : `-${process.arch}`
return path.join(out, `linux${arch}-unpacked`)
@@ -95,7 +95,7 @@ function unpackedDir(): string {
/** electron-builder's Linux executable name: linux.executableName > executableName > lowercased package name. */
function executableName(): string {
- return PKG.build.linux?.executableName ?? PKG.build.executableName ?? PKG.name.toLowerCase()
+ return BUILD.linux?.executableName ?? BUILD.executableName ?? 'hermes'
}
function asArray(value: string | string[] | undefined): string[] {
@@ -254,9 +254,8 @@ type Matcher = (rel: string) => boolean
* that a literal, extension-less pattern also covers `<pattern>/**\/*`.
*/
function packagerMatcher(pattern: string): Matcher {
- const desktopRequire = createRequire(path.join(DESKTOP_ROOT, 'package.json'))
- const builderRequire = createRequire(desktopRequire.resolve('app-builder-lib/package.json'))
- const { Minimatch } = builderRequire('minimatch') as { Minimatch: new (p: string, o: object) => any }
+ const packagerRequire = createRequire(builderRequire.resolve('app-builder-lib'))
+ const { Minimatch } = packagerRequire('minimatch') as { Minimatch: new (p: string, o: object) => any }
const normalized = path.posix.normalize(pattern.replace(/\\/g, '/').replace(/^\.\//, ''))
const matchers = [new Minimatch(normalized, { dot: true })]
@@ -290,14 +289,13 @@ function otherPlatformsOnly(match: Matcher, archive: AsarArchive): null | string
}
}
- const desktopRequire = createRequire(path.join(DESKTOP_ROOT, 'package.json'))
const hits: string[] = []
for (const name of staged) {
let root: string
try {
- root = path.dirname(desktopRequire.resolve(`${name}/package.json`))
+ root = path.dirname(builderRequire.resolve(`${name}/package.json`))
} catch {
continue
}
@@ -332,14 +330,14 @@ interface GlobReport {
}
function asarUnpackViolations(build: PackagedBuild): { problems: string[]; reports: GlobReport[] } {
- const globs = [...asArray(PKG.build.asarUnpack), ...asArray(PKG.build.linux?.asarUnpack)]
+ const globs = asArray(BUILD.asar?.unpack)
const archive = readAsar(build.asarPath)
const disk = walkFiles(build.unpackedRoot)
const problems: string[] = []
const reports: GlobReport[] = []
if (globs.length === 0) {
- problems.push('package.json build.asarUnpack declares no patterns (nothing to verify; did the config move?)')
+ problems.push('electron-builder.config.cjs asar.unpack declares no patterns (nothing to verify)')
}
for (const glob of globs) {
@@ -468,17 +466,6 @@ async function launchPackaged(
return { app, page, logs }
}
-function assertPythonRuntime(): void {
- const candidates = ['.venv/bin/python', 'venv/bin/python'].map(rel => path.join(REPO_ROOT, rel))
-
- if (!candidates.some(file => fs.existsSync(file))) {
- throw new Error(
- `no Hermes Python venv at ${candidates.join(' or ')}: run 'uv sync' at the repo root ` +
- '(the packaged app runs the backend from HERMES_DESKTOP_HERMES_ROOT)'
- )
- }
-}
-
// ─── Specs ──────────────────────────────────────────────────────────────
test('packaged build honours every declared asarUnpack pattern and ships its main entry', async () => {
@@ -498,7 +485,6 @@ test('packaged build honours every declared asarUnpack pattern and ships its mai
test('packaged binary boots against a scripted provider and completes a first chat', async () => {
const build = packagedBuildOrSkip()
- assertPythonRuntime()
const provider = await startScriptedProvider()
const sandbox = createCoreSandbox('packaged')
writeProviderHome(sandbox.hermesHome, provider.url)
diff --git a/apps/desktop/e2e/core/remote-helpers.ts b/apps/desktop/e2e/core/remote-helpers.ts
index 1d4abba57c4..b0ae1efe20a 100644
--- a/apps/desktop/e2e/core/remote-helpers.ts
+++ b/apps/desktop/e2e/core/remote-helpers.ts
@@ -32,6 +32,16 @@ export interface RemoteBackend {
}
function python(): string {
+ const selected = process.env.HERMES_E2E_PYTHON
+
+ if (selected) {
+ if (!fs.existsSync(selected)) {
+ throw new Error(`selected E2E Python does not exist: ${selected}`)
+ }
+
+ return selected
+ }
+
for (const venv of ['.venv', 'venv']) {
const candidate = path.join(REPO_ROOT, venv, 'bin', 'python')
@@ -40,7 +50,7 @@ function python(): string {
}
}
- throw new Error(`no Python venv under ${REPO_ROOT} (run uv sync)`)
+ throw new Error(`no selected E2E Python or checkout venv under ${REPO_ROOT} (source ./activate in an isolated HERMES_HOME)`)
}
function freePort(): Promise<number> {