# Windows installer CI (GitHub Actions) - traps and recipes SesVer's `windows-installer.yml` builds the Inno Setup `.exe` and runs smoke / full-launch / UI tests on `windows-latest`. Only CI can run these; a green Mac suite proves nothing about them. ## Inno Setup `[Code]` static checks (require a test whenever `[Code]` changes) - No line whose first non-blank char is `[`: ISCC reads it as a section header ("Invalid section tag") and the whole build aborts. Move an array's `[` to the end of the previous line or build it in a variable. - No line starting with `#` that is not an ISPP directive (`#13#10` at line start fails the same way). - Balanced `begin`/`try`/`case` vs `end`. ## CI jobs that build their own Python env - Use the launcher's exact install order and pip flags, or better reuse the real install path (`WINDOWS_BASLAT.bat /yalniz-kurulum`) / the build job's env. Under `--require-hashes` the launcher installs `kilit/torch-*.txt` and `voxcpm.txt` with `--no-deps`; dropping that flag makes pip pull an unpinned transitive dependency (filelock) and abort before the test runs. Have the coder add a test comparing the job's pip lines with `WINDOWS_BASLAT.bat`. - Every step that runs Python sets `PYTHONIOENCODING=utf-8` (or prints safely): the console is cp1252, a Turkish character raises `UnicodeEncodeError`, the script exits with the wrong code and the real failure reads as a different one. - Tests that wait for the app/window fail early (a few minutes) with a message naming what was not found, not burn the whole timeout. ## WebView2 UI tests on the runner (CDP, fake media) - GitHub's Windows runner processes are elevated. An elevated WebView2 ignores `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS` and other `WEBVIEW2_*` env vars and reads only the policy key (MicrosoftEdge/WebView2Feedback#5640). Symptom: the app window loads fine (screenshot shows it) but `--remote-debugging-port` never opens. - Working route: the CI step writes `HKLM\SOFTWARE\Policies\Microsoft\Edge\WebView2\AdditionalBrowserArguments` with the value name = the app's exe (`pythonw.exe`), value = the flags. Keep it CI-only: the installer, the app code and the DMG must never write it; require a test that greps the installer/app/release script for the key and flags, and ask the security reviewer to confirm. - Have the test write a diagnostics file (elevation level, WebView2 runtime version, whether the port opened) as an artifact; when it is red, read that file before any new theory. ## "Cancel install" (process tree kill) - intermittent red is a real bug until proven otherwise - An intermittently red step in a long-standing test that mimics a user action (cancel in the wizard) is not "flaky" by default: a leftover process after cancel can lock the half-installed runtime and corrupt the next install. Have the coder separate a real race from test timing with evidence before touching the test, and never loosen the assertion. - Mechanism seen: `taskkill /T` snapshots the tree; a launcher that spawns short-lived pip/python processes in sequence gets a new child born during the kill, which is orphaned and keeps running (`ERROR: ... could not be terminated` / `operation attempted is not supported` lines in the log). - Robust kill shape (implementation is the coder's, these are the acceptance points): 1. Verify the root PID is really the install process (image name + command line) before killing anything; otherwise exit with a distinct code and touch nothing (PID reuse). 2. Kill the root first so it cannot spawn more, then re-scan and kill descendants until N consecutive empty passes, with a time cap. 3. When walking parents, require the parent's start time to precede the child's (a dead PID reused by an unrelated process must not adopt its children). 4. If the root is already gone, still sweep processes from the app's runtime folder that started after the install began (marker file written first thing by the launcher; use its write time, not creation time, which Windows can carry over for a quickly re-created file), and never touch an instance that was running before the install. 5. Keep the old kill path as a fallback if the new script cannot run. - CI proof: cancel at several distinct moments per build, assert zero leftover processes, add a negative scenario (foreign root PID, pre-existing app python untouched, orphan killed), and run the build at least 3 times after the fix. Say plainly if the original race did not reproduce in those runs: the result proves no regression, not the race fix itself. - A new negative scenario that goes red: before reading it as a product bug, check the fixture was alive. PowerShell `Start-Process -ArgumentList` joins an array with spaces and does not quote, so `'-c','import time;time.sleep(120)'` reaches Python as `-c import` and dies instantly; the kill script then "leaves" or "kills" nothing and both verdicts are meaningless. Use spaceless code (`__import__('time').sleep(120)`), assert every fixture process is alive (and born at the right moment) BEFORE calling the product, fail as "fixture could not be set up" otherwise, and prove a kill from the product's own log line for that PID, not from the process merely being gone. - `rustc.exe` inside the install process tree is not a source build: pip's `user_agent()` runs `rustc --version` (0.5 s cap) whenever rustc is on PATH, and the GitHub Windows runner has Rust. Confirm real source builds from the install log (`Building wheel`, cargo/maturin/setuptools-rust) instead. - Running a new PowerShell script from `[Code]`: call `powershell.exe` by absolute system path, `-ExecutionPolicy Bypass` per call only, quote arguments, integer PIDs only; installer stays `PrivilegesRequired=lowest`. Send this delta to the security reviewer.