From 27636cf422d8a6de78f6b7cc14106aafea7645fe Mon Sep 17 00:00:00 2001 From: ethernet Date: Tue, 11 Aug 2026 13:44:12 -0400 Subject: [PATCH] ci(windows-e2e): slot the GUI flow in as the windows-desktop route - generic OLD -> HEAD Restructure tek's two-job desktop-windows-e2e.yml into the shape the linux axis already has: install-e2e.yml keeps its update/installer routes untouched and windows-desktop returns as a route in the same family, calling a reusable install-e2e-windows-run.yml. Behind that route is now ONLY the real user flow - the headless contract job (install.ps1 at HEAD~1, desktop-update.ps1 -NoUi, BASE/CURRENT/NEXT ref dance) is gone, along with its driver. Every leg goes through a surface a user touches: website Hermes-Setup.exe headed with AutoHotkey clicking Install -> Launch, then the installed Hermes.exe under Playwright's Electron driver clicking Settings -> About -> 'Update now', through the detached hand-off to a relaunched window asserted on HEAD. The driver drops the synthetic-NEXT staging with the contract job: serve.git just serves HEAD as main and OLD is the release pin baked into the website exe - the literal starting point of every real GUI user, same philosophy as the linux axis's release-tag matrix. The -Route parameter (desktop today) declares the future update mechanisms as arms: 'update' (hermes update from the installed venv) and 'installer' (re-run the bootstrap exe) raise until implemented, so the workflow surface is stable when they land. --- .github/workflows/desktop-windows-e2e.yml | 177 --------- .github/workflows/install-e2e-windows-run.yml | 115 ++++++ .github/workflows/install-e2e.yml | 32 +- tests/install/windows-desktop-e2e.ps1 | 339 ------------------ tests/install/windows-desktop-gui-e2e.ps1 | 236 +++++++----- 5 files changed, 289 insertions(+), 610 deletions(-) delete mode 100644 .github/workflows/desktop-windows-e2e.yml create mode 100644 .github/workflows/install-e2e-windows-run.yml delete mode 100644 tests/install/windows-desktop-e2e.ps1 diff --git a/.github/workflows/desktop-windows-e2e.yml b/.github/workflows/desktop-windows-e2e.yml deleted file mode 100644 index b4ae727035..0000000000 --- a/.github/workflows/desktop-windows-e2e.yml +++ /dev/null @@ -1,177 +0,0 @@ -name: Desktop Windows Install/Update E2E - -# Can a real Windows user (a) install the commit BEFORE this one from -# scratch, (b) update that install TO this commit through the Desktop GUI -# update path, and (c) update FROM this commit to a future main? -# -# The driver (tests/install/windows-desktop-e2e.ps1) stages a local bare -# repo serving BASE (HEAD~1) -> CURRENT (HEAD) -> NEXT (synthetic same-tree -# child of HEAD) and redirects the canonical GitHub URLs at it via git -# insteadOf env config. The install runs BASE's own scripts/install.ps1 -# with -IncludeDesktop (real uv/Python/Node/venv/Electron build); each -# update leg runs the installed checkout's scripts/desktop-update.ps1 -- -# the exact hand-off the Desktop Update button spawns -- headless (-NoUi), -# including the desktop-exit and venv-lock fail-closed gates, the real -# `hermes update`, marker lifecycle, and the result JSON the relaunched -# Desktop surfaces. -# -# before -> current proves this commit can be updated TO. -# current -> next proves this commit can update FROM (its updater code is -# the one that runs when the NEXT commit ships). -# -# Triggers: every push to main (concurrency-coalesced), release tags, -# nightly, and manual dispatch. Deliberately NOT on pull_request: a leg -# does ~30-60 minutes of real toolchain + Electron work on a 2x-cost -# Windows runner; breakage on main pages within one commit either way. - -on: - workflow_dispatch: - schedule: - # Nightly, off the hour to dodge the top-of-hour runner crunch. - - cron: '40 6 * * *' - # TEMP (revert before merge): validate on this branch from the fork, where - # workflow_dispatch is unavailable until the file lands on the default - # branch. Same pattern tek used pre-merge on the upstream PR. - push: - branches: [main, ethie/desktop-update-tests] - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+.[0-9]+' - -permissions: - contents: read - -concurrency: - group: desktop-windows-e2e-${{ github.ref }} - cancel-in-progress: true - -jobs: - e2e: - name: install BASE, update to CURRENT, update to NEXT - runs-on: windows-latest - timeout-minutes: 180 - - env: - # Sibling of the checkout (D:\a\hermes-agent\hermes-desktop-e2e): outside - # the repo so the staged bare clone and the install never collide with - # the checkout itself. NOTE: ${{ runner.temp }} is NOT available in - # job-level env (only github/inputs/matrix/needs/secrets/strategy/vars); - # that exact mistake made the whole workflow file invalid on first push. - HERMES_E2E_WORKROOT: ${{ github.workspace }}\..\hermes-desktop-e2e - - steps: - # Full history: the driver resolves HEAD~1 and bare-clones this - # checkout as the repo the installer/updater talk to. A shallow - # checkout cannot be served as a clone source. - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - - - name: Stage serve repo (BASE / CURRENT / NEXT) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-e2e.ps1 -Phase stage - - - name: Install BASE from scratch (real install.ps1, with Desktop) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-e2e.ps1 -Phase install - - - name: Update BASE -> CURRENT (Desktop GUI update path) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-e2e.ps1 -Phase update-to-current - - - name: Update CURRENT -> NEXT (Desktop GUI update path) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-e2e.ps1 -Phase update-to-next - - - name: Collect logs - if: always() - shell: powershell - run: | - $out = "e2e-logs" - New-Item -ItemType Directory -Path $out -Force | Out-Null - $home_ = Join-Path $env:HERMES_E2E_WORKROOT "hermes-home" - foreach ($p in @("logs", ".hermes-update-result.json")) { - $src = Join-Path $home_ $p - if (Test-Path $src) { Copy-Item $src (Join-Path $out $p) -Recurse -Force } - } - $shas = Join-Path $env:HERMES_E2E_WORKROOT "shas.json" - if (Test-Path $shas) { Copy-Item $shas $out -Force } - - - name: Upload logs - if: always() - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: desktop-windows-e2e-logs-${{ github.sha }} - path: e2e-logs - retention-days: 7 - if-no-files-found: ignore - - # ── The REAL user flow ────────────────────────────────────────────────── - # Same staging, but every leg is the surface a user touches: the website's - # Hermes-Setup.exe run HEADED with AutoHotkey clicking Install/Launch, then - # the installed Electron app driven by Playwright clicking Settings → - # About → "Update now" twice (→ CURRENT, → synthetic NEXT), asserting the - # detached updater chain end-to-end (result JSON, marker, sha, relaunch). - # Proof artifacts: per-step renderer screenshots, full-desktop frames every - # 3s, ahk.log, bootstrap-installer.log, desktop-update-handoff.log. - # - # GitHub's windows-latest runners have an interactive desktop session, so - # headed GUI automation works without RDP tricks (same substrate the prior - # AutoHotkey attempt in #68183 targeted). - gui-e2e: - name: "REAL flow: website setup.exe → GUI update → GUI update" - runs-on: windows-latest - timeout-minutes: 240 - # Deliberately NOT `needs: e2e` — the jobs run independently, so each - # provides rollback coverage for the other and a GUI-layer flake cannot - # mask a machinery regression. - - env: - HERMES_E2E_WORKROOT: ${{ github.workspace }}\..\hermes-desktop-gui-e2e - - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - - - name: Stage serve repo (BASE / CURRENT / NEXT) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase stage - - - name: Install via website Hermes-Setup.exe (headed, AHK-clicked) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase install-gui - - - name: GUI update to CURRENT (real Update-now click) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase update-gui-to-current - - - name: GUI update to NEXT (real Update-now click) - shell: powershell - run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase update-gui-to-next - - - name: Collect proof + logs - if: always() - shell: powershell - run: | - $out = "gui-e2e-proof" - New-Item -ItemType Directory -Path $out -Force | Out-Null - $work = $env:HERMES_E2E_WORKROOT - $home_ = Join-Path $work "hermes-home" - foreach ($pair in @( - @{ src = (Join-Path $work "proof"); dst = "proof" }, - @{ src = (Join-Path $work "shas.json"); dst = "shas.json" }, - @{ src = (Join-Path $home_ "logs"); dst = "logs" }, - @{ src = (Join-Path $home_ ".hermes-update-result.json"); dst = ".hermes-update-result.json" } - )) { - if (Test-Path $pair.src) { Copy-Item $pair.src (Join-Path $out $pair.dst) -Recurse -Force } - } - - - name: Upload proof + logs - if: always() - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: desktop-windows-gui-e2e-proof-${{ github.sha }} - path: gui-e2e-proof - retention-days: 14 - if-no-files-found: ignore diff --git a/.github/workflows/install-e2e-windows-run.yml b/.github/workflows/install-e2e-windows-run.yml new file mode 100644 index 0000000000..bd492d454b --- /dev/null +++ b/.github/workflows/install-e2e-windows-run.yml @@ -0,0 +1,115 @@ +name: Install & Update E2E — Windows desktop (reusable) + +# Runs the REAL Windows desktop user flow against ONE update route: +# install OLD via the website's Hermes-Setup.exe (headed, AutoHotkey clicks +# Install -> Launch, the real Electron window must appear), then update +# OLD -> HEAD through the route a user would take. +# +# The Windows sibling of install-e2e-run.yml. No bubblewrap here — the +# driver (tests/install/windows-desktop-gui-e2e.ps1) fakes GitHub with +# git's own transport rewrite: a driver-owned GIT_CONFIG_GLOBAL carrying +# url..insteadOf for both canonical repo URLs, so the +# installer and updater run byte-for-byte against their real URLs and land +# on a local bare repo serving HEAD as `main`. OLD is not staged: it is +# the release pin baked into the website exe — the literal starting point +# of every real GUI user. +# +# Routes (the update mechanism under test): +# desktop the app's own Update button: the installed Hermes.exe runs +# under Playwright's Electron driver, which clicks Settings -> +# About -> "Update now"; the production hand-off chain runs +# untouched (marker, app quit, detached updater, hermes +# update, desktop rebuild, relaunch). +# update TODO: `hermes update` from the installed venv. +# installer TODO: re-run the bootstrap exe over the existing install. +# +# Call it: +# +# jobs: +# windows-desktop: +# uses: ./.github/workflows/install-e2e-windows-run.yml +# with: +# route: desktop + +on: + workflow_call: + inputs: + route: + description: 'Update mechanism to exercise: desktop (Update button; implemented), update (hermes update; TODO), installer (re-run bootstrap exe; TODO).' + required: false + type: string + default: desktop + setup-exe-url: + description: 'Bootstrap installer to install OLD with. Default: the latest published one — what a user downloads today.' + required: false + type: string + default: https://hermes-assets.nousresearch.com/Hermes-Setup.exe + timeout-minutes: + description: 'Job timeout. The install leg does real toolchain work and the update leg a full Electron rebuild.' + required: false + type: number + default: 240 + +permissions: + contents: read + +jobs: + e2e: + name: "${{ inputs.route }} route from website installer" + runs-on: windows-latest + timeout-minutes: ${{ inputs.timeout-minutes }} + + env: + # Sibling of the checkout (D:\a\hermes-agent\hermes-desktop-gui-e2e): + # outside the repo so the staged bare clone and the install never + # collide with the checkout itself. NOTE: ${{ runner.temp }} is NOT + # available in job-level env (only github/inputs/matrix/needs/ + # secrets/strategy/vars). + HERMES_E2E_WORKROOT: ${{ github.workspace }}\..\hermes-desktop-gui-e2e + + steps: + # Full history: the driver bare-clones this checkout as the repo the + # installer/updater talk to, and the installer's baked release pin + # must be reachable in that clone. A shallow checkout cannot serve + # either need. + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - name: Stage serve repo (main -> HEAD) + shell: powershell + run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase stage -Route ${{ inputs.route }} -SetupExeUrl ${{ inputs.setup-exe-url }} + + - name: Install OLD via website Hermes-Setup.exe (headed, AHK-clicked) + shell: powershell + run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase install-gui -Route ${{ inputs.route }} -SetupExeUrl ${{ inputs.setup-exe-url }} + + - name: Update OLD -> HEAD (${{ inputs.route }} route) + shell: powershell + run: powershell -NoProfile -ExecutionPolicy Bypass -File tests\install\windows-desktop-gui-e2e.ps1 -Phase update-gui -Route ${{ inputs.route }} -SetupExeUrl ${{ inputs.setup-exe-url }} + + - name: Collect proof + logs + if: always() + shell: powershell + run: | + $out = "gui-e2e-proof" + New-Item -ItemType Directory -Path $out -Force | Out-Null + $work = $env:HERMES_E2E_WORKROOT + $home_ = Join-Path $work "hermes-home" + foreach ($pair in @( + @{ src = (Join-Path $work "proof"); dst = "proof" }, + @{ src = (Join-Path $work "shas.json"); dst = "shas.json" }, + @{ src = (Join-Path $home_ "logs"); dst = "logs" }, + @{ src = (Join-Path $home_ ".hermes-update-result.json"); dst = ".hermes-update-result.json" } + )) { + if (Test-Path $pair.src) { Copy-Item $pair.src (Join-Path $out $pair.dst) -Recurse -Force } + } + + - name: Upload proof + logs + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: install-e2e-windows-${{ inputs.route }}-${{ github.sha }} + path: gui-e2e-proof + retention-days: 14 + if-no-files-found: ignore diff --git a/.github/workflows/install-e2e.yml b/.github/workflows/install-e2e.yml index ecce5c5171..08d46582d0 100644 --- a/.github/workflows/install-e2e.yml +++ b/.github/workflows/install-e2e.yml @@ -12,11 +12,12 @@ name: Install & Update E2E # A hardcoded list would stop covering the newest release the day after it # ships, and would pin an "oldest" that nobody still runs. # -# A separate Windows workflow (desktop-windows-e2e.yml) covers the Windows -# desktop surfaces: a headless desktop-update.ps1 contract job and a real -# user-flow GUI job (website installer, clicked Install/Launch/Update now). -# No tag matrix there — the published exe's own build pin is the starting -# point users actually have. +# A separate Windows axis (install-e2e-windows-run.yml) covers the desktop +# user flow: install OLD with the website's published bootstrap installer +# (headed, AutoHotkey-clicked), then update to HEAD through a real update +# surface — the app's own Update button clicked by Playwright. No tag +# matrix there: the published exe's own build pin is the starting point +# users actually have. # # Triggers: # * every 12 hours, so upstream drift (a new uv, a Node bump, a PyPI change) @@ -33,11 +34,11 @@ on: workflow_dispatch: inputs: route: - description: 'Which update route to exercise.' + description: 'Which update route to exercise. all/both include the Windows desktop leg.' required: false type: choice default: all - options: [all, both, update, installer] + options: [all, both, update, installer, windows-desktop] tag-count: description: 'How many release tags to sample (newest, oldest, and a spread between).' required: false @@ -115,9 +116,14 @@ jobs: route: installer install-ref: ${{ matrix.install-ref }} - # Windows desktop coverage moved to desktop-windows-e2e.yml: two jobs — - # a headless desktop-update.ps1 contract job (BASE -> CURRENT -> NEXT) - # and a REAL user-flow GUI job (website Hermes-Setup.exe, AutoHotkey - # Install/Launch clicks, Playwright-driven Settings -> About -> Update - # now, relaunched-window assert). Triggered on push-to-main + nightly + - # release tags + dispatch there, so no leg here. + # Windows desktop: install OLD with the website's published bootstrap + # installer (the exact bits a user downloads today, AutoHotkey-clicked), + # then update to HEAD by clicking the app's own Update button under + # Playwright. The reusable workflow's route input selects the update + # mechanism; `hermes update` and installer-rerun arms are declared TODOs + # there. + windows-desktop: + if: github.event_name != 'workflow_dispatch' || contains(fromJSON('["all", "windows-desktop"]'), inputs.route) + uses: ./.github/workflows/install-e2e-windows-run.yml + with: + route: desktop diff --git a/tests/install/windows-desktop-e2e.ps1 b/tests/install/windows-desktop-e2e.ps1 deleted file mode 100644 index 959576bb25..0000000000 --- a/tests/install/windows-desktop-e2e.ps1 +++ /dev/null @@ -1,339 +0,0 @@ -# ============================================================================ -# Windows Desktop install + update E2E driver -# ============================================================================ -# Proves, on a real Windows machine, that: -# -# 1. INSTALL - the commit-prior-to-HEAD ("BASE") installs from scratch -# through the real scripts/install.ps1 (uv, managed Python, -# Node, venv, packaged Desktop Hermes.exe). -# 2. UPDATE 1 - that BASE install updates to HEAD ("CURRENT") through the -# real Desktop GUI update path: scripts/desktop-update.ps1, -# the exact hand-off script the Update button spawns -# (see apps/desktop/electron/main.ts applyUpdates()). -# 3. UPDATE 2 - the now-CURRENT install updates once more to a synthetic -# "NEXT" commit staged on top of HEAD, proving the *outgoing* -# update path of the commit under test is not broken either. -# (before -> current proves we can be updated TO; -# current -> next proves we can update FROM.) -# -# HOW THE STAGING WORKS (no MITM proxy, no network fakery): -# We bare-clone the checkout into \serve.git and point every git -# process at it with url..insteadOf rewrites for the two -# canonical repo URLs, injected via GIT_CONFIG_{COUNT,KEY_n,VALUE_n} -# environment variables. install.ps1's `git clone` and `hermes update`'s -# `git fetch origin` therefore transparently hit OUR bare repo, whose -# `main` ref we advance between legs: BASE -> CURRENT -> NEXT. The -# installer and updater code paths run unmodified, byte-for-byte as in -# production. Everything else (uv, PyPI, npm, PortableGit download) uses -# the real network, same as a user install. -# -# NEXT is a same-tree child of CURRENT (git commit-tree), so it exists -# only in serve.git and can never leak a content change; leg 3 verifies -# by commit SHA. -# -# WHY NOT AutoHotkey / pixel-driving the installer window (the prior -# attempt, PR #68183): image-search button clicking is resolution- and -# theme-fragile and never stabilized. The GUI Update button's entire effect -# is spawning desktop-update.ps1 with documented flags (its "CONTRACT" -# header); driving that contract directly tests the same production code -# deterministically. -NoUi and the DesktopPid wait gate exist in that script -# precisely for tests. -# -# USAGE (local Windows box or CI): -# powershell -File tests\install\windows-desktop-e2e.ps1 # all -# powershell -File tests\install\windows-desktop-e2e.ps1 -Phase stage -# ... -Phase install / update-to-current / update-to-next -# Phases share state via \shas.json, so CI can run them as -# separate steps for readable logs. -# -# The workroot defaults to $env:HERMES_E2E_WORKROOT or %TEMP%. Pass -Keep -# to leave everything on disk for inspection. -# ============================================================================ - -param( - [ValidateSet("stage", "install", "update-to-current", "update-to-next", "all")] - [string]$Phase = "all", - - # Repo checkout whose HEAD is the commit under test. - [string]$RepoRoot = "", - - # Where the bare serve repo + isolated HERMES_HOME live. - [string]$WorkRoot = $(if ($env:HERMES_E2E_WORKROOT) { $env:HERMES_E2E_WORKROOT } else { Join-Path $env:TEMP "hermes-desktop-e2e" }), - - # Keep the workroot after a successful `-Phase all` run. - [switch]$Keep -) - -$ErrorActionPreference = "Stop" -$ProgressPreference = "SilentlyContinue" - -if (-not $RepoRoot) { - $RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path -} - -$ServeRepo = Join-Path $WorkRoot "serve.git" -$HermesHome = Join-Path $WorkRoot "hermes-home" -$InstallDir = Join-Path $HermesHome "hermes-agent" -$StatePath = Join-Path $WorkRoot "shas.json" - -# The two URL spellings install.ps1 clones from and `hermes update` fetches -# from. insteadOf is prefix-based; we register the exact full forms only, so -# nothing else can accidentally rewrite to a path + ".git" suffix. -$RepoUrlHttps = "https://github.com/NousResearch/hermes-agent.git" -$RepoUrlSsh = "git@github.com:NousResearch/hermes-agent.git" - -function Write-Step([string]$Message) { - Write-Host "" - Write-Host ("=" * 74) - Write-Host "== $Message" - Write-Host ("=" * 74) -} - -function Assert-True([bool]$Condition, [string]$Message) { - if (-not $Condition) { - throw "E2E ASSERTION FAILED: $Message" - } - Write-Host " [ok] $Message" -} - -function Invoke-Git([string[]]$GitArgs, [string]$WorkDir = $null) { - $prev = if ($WorkDir) { Get-Location } else { $null } - # PS 5.1 trap: under $ErrorActionPreference = "Stop", a native command - # that writes ANYTHING to stderr while merged via 2>&1 throws a - # NativeCommandError even when it exits 0 (git loves stderr for - # progress/notices). Relax EAP around the native call only; exit-code - # checking below is the real error gate. - $prevEap = $ErrorActionPreference - $ErrorActionPreference = "Continue" - try { - if ($WorkDir) { Set-Location $WorkDir } - $output = & git @GitArgs 2>&1 - if ($LASTEXITCODE -ne 0) { - throw "git $($GitArgs -join ' ') failed (exit $LASTEXITCODE): $output" - } - return ($output | Out-String).Trim() - } finally { - $ErrorActionPreference = $prevEap - if ($prev) { Set-Location $prev } - } -} - -function Set-GitRedirect { - # Route the canonical repo URLs to the local bare repo for THIS process - # and every child (install.ps1's git, hermes update's git). - # - # MECHANISM: a driver-owned global gitconfig selected via - # GIT_CONFIG_GLOBAL. Do NOT use GIT_CONFIG_COUNT/KEY_n/VALUE_n env - # config here -- install.ps1 SETS those itself (GIT_CONFIG_COUNT=1, - # windows.appendAtomically), silently clobbering any redirect we put - # there. That exact clobber made the first CI run clone real GitHub - # main instead of the staged BASE (caught by the HEAD-at-BASE assert). - # install.ps1's own `git config --global` writes simply land in our - # file, so its compat settings still apply. Nothing leaks onto the - # machine: the file lives in the workroot and dies with it. - $fileUrl = "file:///" + ($ServeRepo -replace "\\", "/") - $gitCfg = Join-Path $WorkRoot "e2e-gitconfig" - if (-not (Test-Path -LiteralPath $WorkRoot)) { - New-Item -ItemType Directory -Path $WorkRoot -Force | Out-Null - } - @" -[url "$fileUrl"] - insteadOf = $RepoUrlHttps - insteadOf = $RepoUrlSsh -"@ | Set-Content -LiteralPath $gitCfg -Encoding ASCII - $env:GIT_CONFIG_GLOBAL = $gitCfg - Write-Host " git URL redirect via GIT_CONFIG_GLOBAL=$gitCfg" - Write-Host " $RepoUrlHttps -> $fileUrl" -} - -function Read-State { - if (-not (Test-Path -LiteralPath $StatePath)) { - throw "State file not found: $StatePath -- run '-Phase stage' first." - } - return Get-Content -LiteralPath $StatePath -Raw | ConvertFrom-Json -} - -function Get-InstalledHead { - return Invoke-Git @("-C", $InstallDir, "rev-parse", "HEAD") -} - -function Get-DesktopExe { - $candidates = @( - (Join-Path $InstallDir "apps\desktop\release\win-unpacked\Hermes.exe"), - (Join-Path $InstallDir "apps\desktop\release\win-arm64-unpacked\Hermes.exe") - ) - foreach ($c in $candidates) { - if (Test-Path -LiteralPath $c) { return $c } - } - return $null -} - -function Test-HermesRuns([string]$Label) { - $hermesExe = Join-Path $InstallDir "venv\Scripts\hermes.exe" - Assert-True (Test-Path -LiteralPath $hermesExe) "$Label -- venv\Scripts\hermes.exe exists" - & $hermesExe --version 2>&1 | ForEach-Object { Write-Host " hermes --version| $_" } - Assert-True ($LASTEXITCODE -eq 0) "$Label -- hermes --version exits 0" -} - -# ---------------------------------------------------------------------------- -# Phase: stage -# ---------------------------------------------------------------------------- -function Invoke-PhaseStage { - Write-Step "STAGE: bare serve repo + BASE/CURRENT/NEXT refs" - - if (Test-Path -LiteralPath $WorkRoot) { - Remove-Item -LiteralPath $WorkRoot -Recurse -Force - } - New-Item -ItemType Directory -Path $WorkRoot -Force | Out-Null - # The purge above deleted the redirect gitconfig; re-arm it so the - # bare-clone below (and everything after) sees the redirect file. - Set-GitRedirect - - $current = Invoke-Git @("-C", $RepoRoot, "rev-parse", "HEAD") - $base = Invoke-Git @("-C", $RepoRoot, "rev-parse", "HEAD~1") - Write-Host " CURRENT (commit under test): $current" - Write-Host " BASE (its parent): $base" - - # Bare-clone the checkout: this is the repo the installer and updater - # will actually talk to. Local-path clone hardlinks objects, so it's - # fast even for full history. - Invoke-Git @("clone", "--bare", "--quiet", $RepoRoot, $ServeRepo) | Out-Null - - # Synthesize NEXT inside the bare repo: a same-tree child of CURRENT. - # It exists nowhere else, which is the point -- leg 3 proves the commit - # under test can update to a future main it has never seen. - $env:GIT_AUTHOR_NAME = "Hermes E2E"; $env:GIT_AUTHOR_EMAIL = "e2e@nousresearch.com" - $env:GIT_COMMITTER_NAME = "Hermes E2E"; $env:GIT_COMMITTER_EMAIL = "e2e@nousresearch.com" - $next = Invoke-Git @("-C", $ServeRepo, "commit-tree", "$current^{tree}", "-p", $current, "-m", "e2e: synthetic next commit (same tree as CURRENT)") - Write-Host " NEXT (synthetic): $next" - - # Serve BASE as `main` first; update legs advance this ref. - Invoke-Git @("-C", $ServeRepo, "update-ref", "refs/heads/main", $base) | Out-Null - Invoke-Git @("-C", $ServeRepo, "symbolic-ref", "HEAD", "refs/heads/main") | Out-Null - - @{ base = $base; current = $current; next = $next } | - ConvertTo-Json | Set-Content -LiteralPath $StatePath -Encoding UTF8 - Write-Host " state written: $StatePath" -} - -# ---------------------------------------------------------------------------- -# Phase: install (BASE, via BASE's own install.ps1) -# ---------------------------------------------------------------------------- -function Invoke-PhaseInstall { - $state = Read-State - Write-Step "INSTALL: BASE ($($state.base)) via its own install.ps1 -IncludeDesktop" - - # The honest test runs the installer *as it existed at BASE* -- a user - # installing yesterday used yesterday's script. - $baseInstaller = Join-Path $WorkRoot "install-base.ps1" - & git -C $ServeRepo show "$($state.base):scripts/install.ps1" | - Set-Content -LiteralPath $baseInstaller -Encoding UTF8 - if ($LASTEXITCODE -ne 0) { throw "could not extract scripts/install.ps1 at BASE" } - - $env:HERMES_HOME = $HermesHome - New-Item -ItemType Directory -Path $HermesHome -Force | Out-Null - - # Windows PowerShell 5.1 on purpose: it is what the production - # `irm | iex` one-liner and the desktop bootstrap both run under. - & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $baseInstaller ` - -NonInteractive -SkipSetup -IncludeDesktop ` - -HermesHome $HermesHome -InstallDir $InstallDir - Assert-True ($LASTEXITCODE -eq 0) "install.ps1 (BASE) exited 0" - - Assert-True ((Get-InstalledHead) -eq $state.base) "installed checkout is at BASE" - Test-HermesRuns "post-install" - $desktopExe = Get-DesktopExe - Assert-True ($null -ne $desktopExe) "packaged Desktop Hermes.exe exists ($desktopExe)" -} - -# ---------------------------------------------------------------------------- -# Update legs (shared): the real Desktop GUI update path -# ---------------------------------------------------------------------------- -function Invoke-DesktopUpdateLeg([string]$TargetSha, [string]$LegName) { - Write-Step "UPDATE ($LegName): advance served main -> $TargetSha, run desktop-update.ps1" - - $env:HERMES_HOME = $HermesHome - Invoke-Git @("-C", $ServeRepo, "update-ref", "refs/heads/main", $TargetSha) | Out-Null - - # The hand-off script from the INSTALLED checkout drives the update -- - # exactly the production contract: each `hermes update` refreshes the - # script that drives the NEXT update. - $handoff = Join-Path $InstallDir "scripts\desktop-update.ps1" - Assert-True (Test-Path -LiteralPath $handoff) "installed checkout ships scripts/desktop-update.ps1" - - # Stand in for the exiting Electron main process: desktop-update.ps1 - # FAIL-CLOSED waits for this pid to exit before touching the install. - # A short-lived real process exercises that gate. - $dummy = Start-Process -FilePath "powershell.exe" ` - -ArgumentList "-NoProfile", "-Command", "Start-Sleep -Seconds 3" ` - -WindowStyle Hidden -PassThru - - $resultPath = Join-Path $HermesHome ".hermes-update-result.json" - $markerPath = Join-Path $HermesHome ".hermes-update-in-progress" - Remove-Item -LiteralPath $resultPath -Force -ErrorAction SilentlyContinue - - # -NoUi: headless (no WinForms in CI). No -RelaunchExe: contract says - # omit = no relaunch, so no orphaned Electron process on the runner. - & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $handoff ` - -InstallRoot $InstallDir -Branch main -DesktopPid $dummy.Id -NoUi - $handoffExit = $LASTEXITCODE - - # Surface the hand-off log before asserting, so failures are debuggable - # straight from the CI step output. - $logPath = Join-Path $HermesHome "logs\desktop-update-handoff.log" - if (Test-Path -LiteralPath $logPath) { - Write-Host " --- desktop-update-handoff.log (tail) ---" - Get-Content -LiteralPath $logPath -Tail 40 | ForEach-Object { Write-Host " | $_" } - } - - Assert-True ($handoffExit -eq 0) "$LegName -- desktop-update.ps1 exited 0" - - Assert-True (Test-Path -LiteralPath $resultPath) "$LegName -- update result JSON written" - $result = Get-Content -LiteralPath $resultPath -Raw | ConvertFrom-Json - Assert-True ([bool]$result.ok) "$LegName -- result JSON reports ok=true ('$($result.message)')" - - Assert-True (-not (Test-Path -LiteralPath $markerPath)) "$LegName -- update marker cleaned up" - Assert-True ((Get-InstalledHead) -eq $TargetSha) "$LegName -- checkout landed on target commit" - Test-HermesRuns $LegName - Assert-True ($null -ne (Get-DesktopExe)) "$LegName -- Desktop Hermes.exe still present after update" -} - -function Invoke-PhaseUpdateToCurrent { - $state = Read-State - Invoke-DesktopUpdateLeg $state.current "BASE -> CURRENT" -} - -function Invoke-PhaseUpdateToNext { - $state = Read-State - Invoke-DesktopUpdateLeg $state.next "CURRENT -> NEXT" -} - -# ---------------------------------------------------------------------------- -# Dispatch -# ---------------------------------------------------------------------------- -Write-Host "Windows Desktop E2E driver" -Write-Host " phase: $Phase" -Write-Host " repo: $RepoRoot" -Write-Host " workroot: $WorkRoot" - -Set-GitRedirect - -switch ($Phase) { - "stage" { Invoke-PhaseStage } - "install" { Invoke-PhaseInstall } - "update-to-current" { Invoke-PhaseUpdateToCurrent } - "update-to-next" { Invoke-PhaseUpdateToNext } - "all" { - Invoke-PhaseStage - Invoke-PhaseInstall - Invoke-PhaseUpdateToCurrent - Invoke-PhaseUpdateToNext - if (-not $Keep) { - Write-Step "CLEANUP" - Remove-Item -LiteralPath $WorkRoot -Recurse -Force -ErrorAction SilentlyContinue - } - } -} - -Write-Host "" -Write-Host "Phase '$Phase' completed successfully." diff --git a/tests/install/windows-desktop-gui-e2e.ps1 b/tests/install/windows-desktop-gui-e2e.ps1 index 799ba5ea55..ed4103162f 100644 --- a/tests/install/windows-desktop-gui-e2e.ps1 +++ b/tests/install/windows-desktop-gui-e2e.ps1 @@ -1,27 +1,44 @@ # ============================================================================ # Windows Desktop GUI install + update E2E driver (the REAL user flow) # ============================================================================ -# Same before -> current -> next staging as windows-desktop-e2e.ps1, but every -# leg goes through the surfaces a real user touches: +# Proves, on a real Windows machine, that a user who installs Hermes the way +# the website tells them to can then update to the commit under test through +# a real update surface -- with every leg driven through the GUI a user +# actually touches: # # INSTALL - downloads the production Hermes-Setup.exe from the website, # launches it HEADED, and AutoHotkey clicks Install, waits, # then clicks Launch. The real Electron Hermes.exe must appear. # The exe runs EXACTLY as shipped: it downloads its own pinned # install.ps1 from GitHub raw and installs its baked -# BUILD_PIN_COMMIT -- so the "before" version in this harness is -# the website release pin, the literal starting point of every -# real GUI user. (The strict HEAD~1 -> HEAD guarantee is the -# contract harness's job; this one covers the production pin.) -# UPDATE x2 - launches the installed Hermes.exe under Playwright's Electron -# driver and CLICKS Settings -> About -> "Update now". That -# spawns the production hand-off (desktop-update.ps1 via -# cmd start, or the staged hermes-setup.exe on old checkouts), -# the app quits, the detached updater runs `hermes update`, -# rebuilds the desktop, and RELAUNCHES Hermes.exe. We assert -# the whole chain: target sha, marker cleanup, working hermes, -# and the relaunched app window. Leg 1 lands on CURRENT, leg 2 -# on the synthetic NEXT. +# BUILD_PIN_COMMIT -- so OLD is the website release pin, the +# literal starting point of every real GUI user. +# UPDATE - OLD -> HEAD through the route selected by -Route: +# desktop (implemented) launch the installed Hermes.exe +# under Playwright's Electron driver and CLICK +# Settings -> About -> "Update now". The +# production hand-off chain runs untouched: +# marker, app quit, detached updater, `hermes +# update`, desktop rebuild, RELAUNCH. Asserts +# target sha, marker cleanup, result JSON (when +# the script path wrote one), working hermes, +# and the relaunched app window. +# update TODO: run `hermes update` from the installed +# venv (the CLI route a GUI user might take). +# installer TODO: re-run the bootstrap installer over the +# existing install (its --update flow). +# +# HOW THE STAGING WORKS (no MITM proxy, no network fakery): +# We bare-clone the checkout into \serve.git and point every git +# process at it with url..insteadOf rewrites for the two +# canonical repo URLs, via a driver-owned gitconfig selected with +# GIT_CONFIG_GLOBAL. (NOT GIT_CONFIG_COUNT/KEY_n/VALUE_n env config -- +# install.ps1 sets those itself and silently clobbers them.) The +# installer's `git clone` and `hermes update`'s `git fetch origin` +# transparently hit OUR bare repo, whose `main` ref serves HEAD -- the +# update target. Installer and updater run byte-for-byte as shipped; +# everything else (uv, PyPI, npm, the installer's raw.githubusercontent +# install.ps1 download) uses the real network, same as a user install. # # PROOF: screenshots at every renderer step (Playwright), full-desktop # screenshots around the installer/AHK phases, a rolling desktop capture @@ -29,27 +46,41 @@ # as CI artifacts. # # DEVIATIONS FROM PRODUCTION (each one deliberate and small): -# * git URL redirect (GIT_CONFIG_GLOBAL) routes the canonical repo URLs -# to the staged serve.git -- the staging requirement itself. The -# installer's raw.githubusercontent install.ps1 download and the pinned -# ZIP fallback are NOT redirected (real network, as shipped). +# * the git URL redirect itself -- the staging requirement. # * serve.git gets uploadpack.allowAnySHA1InWant=true so the installer's # baked -Commit pin can be fetched from the redirected clone the same # way GitHub's upload-pack allows it. -# * A dummy provider key is seeded after install so the update legs see +# * A dummy provider key is seeded after install so the update leg sees # the ready app shell instead of the onboarding overlay (a real # updating user has a configured provider). +# * .skip_upstream_prompt is set: serve.git's file:// origin looks like a +# fork to `hermes update`, whose fork-only upstream prompt is a bare +# input() that hangs forever under the desktop's detached console. +# Real GUI users are on the official origin and never see it. # -# Usage mirrors windows-desktop-e2e.ps1: +# USAGE (local Windows box or CI): # powershell -File tests\install\windows-desktop-gui-e2e.ps1 -Phase all -# ... -Phase stage / install-gui / update-gui-to-current / update-gui-to-next +# ... -Phase stage / install-gui / update-gui +# Phases share state via \shas.json, so CI can run them as +# separate steps for readable logs. # ============================================================================ param( - [ValidateSet("stage", "install-gui", "update-gui-to-current", "update-gui-to-next", "all")] + [ValidateSet("stage", "install-gui", "update-gui", "all")] [string]$Phase = "all", + + # Update route to exercise in the update-gui phase. Only "desktop" (the + # app's own Update button) is implemented; "update" (CLI `hermes + # update`) and "installer" (re-run the bootstrap exe) are declared arms + # so the workflow surface is stable when they land. + [ValidateSet("desktop", "update", "installer")] + [string]$Route = "desktop", + + # Repo checkout whose HEAD is the update target. [string]$RepoRoot = "", + [string]$WorkRoot = $(if ($env:HERMES_E2E_WORKROOT) { $env:HERMES_E2E_WORKROOT } else { Join-Path $env:TEMP "hermes-desktop-gui-e2e" }), + [string]$SetupExeUrl = "https://hermes-assets.nousresearch.com/Hermes-Setup.exe" ) @@ -86,6 +117,11 @@ function Assert-True([bool]$Condition, [string]$Message) { } function Invoke-Git([string[]]$GitArgs) { + # PS 5.1 trap: under $ErrorActionPreference = "Stop", a native command + # that writes ANYTHING to stderr while merged via 2>&1 throws a + # NativeCommandError even when it exits 0 (git loves stderr for + # progress/notices). Relax EAP around the native call only; exit-code + # checking below is the real error gate. $prevEap = $ErrorActionPreference $ErrorActionPreference = "Continue" try { @@ -100,8 +136,16 @@ function Invoke-Git([string[]]$GitArgs) { } function Set-GitRedirect { - # Same mechanism (and same install.ps1-clobber rationale) as - # windows-desktop-e2e.ps1: a driver-owned gitconfig via GIT_CONFIG_GLOBAL. + # Route the canonical repo URLs to the local bare repo for THIS process + # and every child (the installer's git, hermes update's git). + # + # MECHANISM: a driver-owned global gitconfig selected via + # GIT_CONFIG_GLOBAL. Do NOT use GIT_CONFIG_COUNT/KEY_n/VALUE_n env + # config here -- install.ps1 SETS those itself (GIT_CONFIG_COUNT=1, + # windows.appendAtomically), silently clobbering any redirect we put + # there. install.ps1's own `git config --global` writes simply land in + # our file, so its compat settings still apply. Nothing leaks onto the + # machine: the file lives in the workroot and dies with it. $fileUrl = "file:///" + ($ServeRepo -replace "\\", "/") $gitCfg = Join-Path $WorkRoot "e2e-gitconfig" if (-not (Test-Path -LiteralPath $WorkRoot)) { @@ -114,6 +158,7 @@ function Set-GitRedirect { "@ | Set-Content -LiteralPath $gitCfg -Encoding ASCII $env:GIT_CONFIG_GLOBAL = $gitCfg Write-Host " git URL redirect via GIT_CONFIG_GLOBAL=$gitCfg" + Write-Host " $RepoUrlHttps -> $fileUrl" } function Read-State { @@ -145,7 +190,7 @@ function Test-HermesRuns([string]$Label) { } function Save-DesktopScreenshot([string]$OutFile) { - # Single full-desktop screenshot (all monitors' primary screen). + # Single full-desktop screenshot (primary screen). try { Add-Type -AssemblyName System.Windows.Forms, System.Drawing $bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds @@ -197,7 +242,7 @@ function Stop-DesktopRecorder($proc, [string]$OutDir) { } function Stop-HermesAppProcesses([string]$Label) { - # Close the desktop app the blunt way between legs (a user quitting). + # Close the desktop app the blunt way between phases (a user quitting). # Only Hermes.exe (Electron) -- never hermes.exe (the venv CLI shim). $procs = @(Get-Process -Name "Hermes" -ErrorAction SilentlyContinue) foreach ($p in $procs) { @@ -226,20 +271,40 @@ function Get-ManagedNode { } # ---------------------------------------------------------------------------- -# Phase: stage -- reuse the contract driver's stage (identical staging) +# Phase: stage -- serve.git with `main` at HEAD (the update target) # ---------------------------------------------------------------------------- function Invoke-PhaseStage { - Write-Step "STAGE (gui): delegating to windows-desktop-e2e.ps1 -Phase stage" - & powershell.exe -NoProfile -ExecutionPolicy Bypass ` - -File (Join-Path $PSScriptRoot "windows-desktop-e2e.ps1") ` - -Phase stage -RepoRoot $RepoRoot -WorkRoot $WorkRoot - if ($LASTEXITCODE -ne 0) { throw "stage phase failed" } + Write-Step "STAGE: bare serve repo, main -> HEAD (update target)" + + if (Test-Path -LiteralPath $WorkRoot) { + Remove-Item -LiteralPath $WorkRoot -Recurse -Force + } + New-Item -ItemType Directory -Path $WorkRoot -Force | Out-Null + # The purge above deleted the redirect gitconfig; re-arm it so the + # bare-clone below (and everything after) sees the redirect file. + Set-GitRedirect + + $current = Invoke-Git @("-C", $RepoRoot, "rev-parse", "HEAD") + Write-Host " HEAD (update target): $current" + + # Bare-clone the checkout: this is the repo the installer and updater + # actually talk to. Local-path clone hardlinks objects, so it's fast + # even for full history. OLD is not staged by us -- it is whatever + # release pin the website installer carries (recorded in install-gui). + Invoke-Git @("clone", "--bare", "--quiet", $RepoRoot, $ServeRepo) | Out-Null + Invoke-Git @("-C", $ServeRepo, "update-ref", "refs/heads/main", $current) | Out-Null + Invoke-Git @("-C", $ServeRepo, "symbolic-ref", "HEAD", "refs/heads/main") | Out-Null + # The website installer pins a specific release commit (-Commit ). # That sha is in serve.git's history but not at a ref tip, so the # redirected fetch needs any-SHA1 upload-pack permission (GitHub grants - # the equivalent for archive/fetch of reachable commits). + # the equivalent for fetch of reachable commits). Invoke-Git @("-C", $ServeRepo, "config", "uploadpack.allowAnySHA1InWant", "true") | Out-Null Write-Host " serve.git: uploadpack.allowAnySHA1InWant=true (installer commit pin)" + + @{ current = $current } | + ConvertTo-Json | Set-Content -LiteralPath $StatePath -Encoding UTF8 + Write-Host " state written: $StatePath" New-Item -ItemType Directory -Path $ProofRoot -Force | Out-Null } @@ -334,39 +399,39 @@ function Invoke-PhaseInstallGui { # Close the freshly launched app (user quits after first look). Stop-HermesAppProcesses "post-install" - # The website exe installs its baked release pin -- record it as the - # "before" version. It must differ from CURRENT (an update is genuinely - # available). We do NOT require it to be an ancestor of CURRENT: on a - # real `push: main` run CURRENT is main's tip and the release pin is - # behind it (ancestor), but on a feature branch CURRENT has diverged - # from main, so the release pin legitimately isn't in its ancestry. The - # update leg resets the checkout to serve.git's main ref regardless, and - # asserts it lands on CURRENT -- that is the real forward-update proof. + # The website exe installs its baked release pin -- that IS the OLD + # version. It must differ from HEAD (an update is genuinely available). + # We do NOT require it to be an ancestor of HEAD: on a real `push: main` + # run HEAD is main's tip and the release pin is behind it (ancestor), + # but on a feature branch HEAD has diverged from main, so the release + # pin legitimately isn't in its ancestry. The update leg resets the + # checkout to serve.git's main ref regardless, and asserts it lands on + # HEAD -- that is the real forward-update proof. $installedSha = Get-InstalledHead - Write-Host " installer landed on: $installedSha (website release pin)" - Assert-True ($installedSha -ne $state.current) "installed pin differs from CURRENT (an update is genuinely available)" + Write-Host " installer landed on: $installedSha (website release pin = OLD)" + Assert-True ($installedSha -ne $state.current) "installed pin differs from HEAD (an update is genuinely available)" $prevEap = $ErrorActionPreference; $ErrorActionPreference = "Continue" & git -C $InstallDir merge-base --is-ancestor $installedSha $state.current 2>&1 | Out-Null $isAncestor = ($LASTEXITCODE -eq 0) $ErrorActionPreference = $prevEap if ($isAncestor) { - Write-Host " [ok] installed pin is an ancestor of CURRENT (linear before -> current)" + Write-Host " [ok] installed pin is an ancestor of HEAD (linear old -> new)" } else { - Write-Host " [note] installed pin is NOT an ancestor of CURRENT -- expected on a diverged feature branch; the update leg still resets to CURRENT" + Write-Host " [note] installed pin is NOT an ancestor of HEAD -- expected on a diverged feature branch; the update leg still resets to HEAD" } Test-HermesRuns "post-install-gui" Assert-True ($null -ne (Get-DesktopExe)) "packaged Desktop Hermes.exe exists" - # Seed a provider so the update legs meet the ready app shell, not the + # Seed a provider so the update leg meets the ready app shell, not the # onboarding overlay (an updating user has a configured provider). $envFile = Join-Path $HermesHome ".env" if (-not (Test-Path -LiteralPath $envFile) -or -not ((Get-Content $envFile -Raw -ErrorAction SilentlyContinue) -match "OPENROUTER_API_KEY")) { - Add-Content -LiteralPath $envFile -Value "OPENROUTER_API_KEY=sk-or-e2e-placeholder-not-a-real-key" + Add-Content -LiteralPath $envFile -Value "OPENROUTER_API_KEY=sk-or-...-key" } - Write-Host " seeded placeholder provider key for update legs" + Write-Host " seeded placeholder provider key for the update leg" # Suppress the interactive "add upstream remote?" prompt during the GUI - # update legs. Our serve.git origin (file://) looks like a fork to + # update leg. Our serve.git origin (file://) looks like a fork to # `hermes update`, so `_sync_with_upstream_if_needed` would call bare # input() -- which HANGS FOREVER when the Desktop spawns the hand-off via # `cmd start /min` (a real but empty console; input() blocks waiting for a @@ -380,18 +445,17 @@ function Invoke-PhaseInstallGui { } # ---------------------------------------------------------------------------- -# Update legs: real app, real clicks (Playwright Electron driver) +# Phase: update-gui -- OLD -> HEAD through the selected route # ---------------------------------------------------------------------------- -function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegSlug) { - Write-Step "UPDATE GUI ($LegName): advance served main -> $TargetSha, click Update now" - $proof = Join-Path $ProofRoot $LegSlug +function Invoke-GuiUpdateDesktopRoute([string]$TargetSha) { + Write-Step "UPDATE (GUI, route=desktop): click Update now, land on $TargetSha" + $proof = Join-Path $ProofRoot "update-gui" New-Item -ItemType Directory -Path $proof -Force | Out-Null $env:HERMES_HOME = $HermesHome - Invoke-Git @("-C", $ServeRepo, "update-ref", "refs/heads/main", $TargetSha) | Out-Null $desktopExe = Get-DesktopExe - Assert-True ($null -ne $desktopExe) "$LegName -- packaged Hermes.exe present before update" + Assert-True ($null -ne $desktopExe) "packaged Hermes.exe present before update" $resultPath = Join-Path $HermesHome ".hermes-update-result.json" $markerPath = Join-Path $HermesHome ".hermes-update-in-progress" @@ -407,7 +471,7 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS & $node -e "require.resolve('@playwright/test', { paths: [process.argv[1]] })" $appsDesktop 2>&1 | Out-Null $pwResolved = ($LASTEXITCODE -eq 0) $ErrorActionPreference = $prevEap - Assert-True $pwResolved "$LegName -- @playwright/test resolvable from installed apps/desktop" + Assert-True $pwResolved "@playwright/test resolvable from installed apps/desktop" $recorder = Start-DesktopRecorder (Join-Path $proof "desktop-frames") try { @@ -428,7 +492,7 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS Pop-Location Remove-Item -LiteralPath $driver -Force -ErrorAction SilentlyContinue } - Assert-True ($driveExit -eq 0) "$LegName -- GUI driver clicked Update now and the app quit for hand-off" + Assert-True ($driveExit -eq 0) "GUI driver clicked Update now and the app quit for hand-off" # The detached updater (spawned by the app, NOT by us) now runs # `hermes update` + desktop rebuild + relaunch. Which updater depends @@ -443,12 +507,12 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS # only when the script path produced it. # # This can take a LONG time: the website release we installed is weeks - # of main behind CURRENT, so the update pulls a large diff AND does a + # of main behind HEAD, so the update pulls a large diff AND does a # full Electron desktop rebuild (vite + electron-builder) plus a uv # sync. The desktop-build output goes to logs/update.log (not the # streamed handoff log), so we tail update.log here to show progress # instead of going silent for tens of minutes. - Write-Host " waiting for the detached updater to finish (up to 90 min; large release->CURRENT rebuild) ..." + Write-Host " waiting for the detached updater to finish (up to 90 min; large old->new rebuild) ..." $updateLog = Join-Path $HermesHome "logs\update.log" $updateLogPos = 0 $deadline = (Get-Date).AddMinutes(90) @@ -473,7 +537,7 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS if (Test-Path -LiteralPath $resultPath) { $result = Get-Content -LiteralPath $resultPath -Raw | ConvertFrom-Json Write-Host " updater result: ok=$($result.ok) code=$($result.exit_code) msg=$($result.message)" - Assert-True ([bool]$result.ok) "$LegName -- updater result ok=true" + Assert-True ([bool]$result.ok) "updater result ok=true" } else { Write-Host " (no result JSON -- staged-binary updater path; relying on sha/marker/relaunch asserts)" } @@ -481,11 +545,11 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS # Marker may briefly outlive the result write; allow it a moment. $mDeadline = (Get-Date).AddMinutes(2) while ((Get-Date) -lt $mDeadline -and (Test-Path -LiteralPath $markerPath)) { Start-Sleep -Seconds 5 } - Assert-True (-not (Test-Path -LiteralPath $markerPath)) "$LegName -- update marker cleaned up" + Assert-True (-not (Test-Path -LiteralPath $markerPath)) "update marker cleaned up" - Assert-True ((Get-InstalledHead) -eq $TargetSha) "$LegName -- checkout landed on target commit" - Test-HermesRuns $LegName - Assert-True ($null -ne (Get-DesktopExe)) "$LegName -- Hermes.exe still present after update" + Assert-True ((Get-InstalledHead) -eq $TargetSha) "checkout landed on target commit" + Test-HermesRuns "post-update" + Assert-True ($null -ne (Get-DesktopExe)) "Hermes.exe still present after update" # The production hand-off relaunches the desktop (RelaunchExe). # A relaunched window is the user-visible proof the update loop closed. @@ -497,7 +561,7 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS if ($relaunched) { break } Start-Sleep -Seconds 5 } - Assert-True ($null -ne $relaunched) "$LegName -- updater relaunched the desktop app" + Assert-True ($null -ne $relaunched) "updater relaunched the desktop app" Start-Sleep -Seconds 12 # let the window paint for the screenshot # Foreground the relaunched Hermes window so the proof screenshot # captures IT, not whatever else is on top (the full-desktop grab is @@ -525,19 +589,30 @@ function Invoke-GuiUpdateLeg([string]$TargetSha, [string]$LegName, [string]$LegS Get-Content -LiteralPath $handoffLog -Tail 60 | ForEach-Object { Write-Host " | $_" } Copy-Item $handoffLog (Join-Path $proof "desktop-update-handoff.log") -Force -ErrorAction SilentlyContinue } - # Quit the relaunched app so the next leg (or job teardown) is clean. - Stop-HermesAppProcesses $LegName + # Quit the relaunched app so job teardown is clean. + Stop-HermesAppProcesses "post-update" } } -function Invoke-PhaseUpdateGuiToCurrent { +function Invoke-PhaseUpdateGui { $state = Read-State - Invoke-GuiUpdateLeg $state.current "BASE -> CURRENT (GUI)" "update-gui-to-current" -} - -function Invoke-PhaseUpdateGuiToNext { - $state = Read-State - Invoke-GuiUpdateLeg $state.next "CURRENT -> NEXT (GUI)" "update-gui-to-next" + switch ($Route) { + "desktop" { + Invoke-GuiUpdateDesktopRoute $state.current + } + "update" { + # TODO: run `hermes update` from the installed venv -- the CLI + # route. Needs the same completion/sha/relaunch asserts minus + # the app-quit dance. + throw "route 'update' (CLI hermes update) is not implemented yet" + } + "installer" { + # TODO: re-run the bootstrap Hermes-Setup.exe over the existing + # install (its --update flow jumps straight to progress and + # runs unattended). + throw "route 'installer' (re-run bootstrap exe) is not implemented yet" + } + } } # ---------------------------------------------------------------------------- @@ -545,21 +620,20 @@ function Invoke-PhaseUpdateGuiToNext { # ---------------------------------------------------------------------------- Write-Host "Windows Desktop GUI E2E driver (real user flow)" Write-Host " phase: $Phase" +Write-Host " route: $Route" Write-Host " repo: $RepoRoot" Write-Host " workroot: $WorkRoot" Set-GitRedirect switch ($Phase) { - "stage" { Invoke-PhaseStage } - "install-gui" { Invoke-PhaseInstallGui } - "update-gui-to-current" { Invoke-PhaseUpdateGuiToCurrent } - "update-gui-to-next" { Invoke-PhaseUpdateGuiToNext } + "stage" { Invoke-PhaseStage } + "install-gui" { Invoke-PhaseInstallGui } + "update-gui" { Invoke-PhaseUpdateGui } "all" { Invoke-PhaseStage Invoke-PhaseInstallGui - Invoke-PhaseUpdateGuiToCurrent - Invoke-PhaseUpdateGuiToNext + Invoke-PhaseUpdateGui } }