Repository navigation
Studio: run the frontend unit tests on Windows in CI - #9099
Conversation
…at cannot pass there Frontend CI is ubuntu-only, so a test that is correct on POSIX and wrong on Windows stays green forever. Thirteen such failures accumulated across three files before anyone ran the suite on a Windows runner. Add a windows-latest job that does checkout, node, npm ci and npm test, and nothing else: typecheck, build and the browser smokes cannot fail there for a reason they would not also fail on ubuntu, and repeating them would roughly triple the workflow. background-load-notice's stall-window test cannot pass on a Windows timer, and was measuring nothing on Linux either. Replace the millisecond budget with a comparison against the same loop with no healthy read.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e54472574e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| - name: Unit tests | ||
| run: npm test |
There was a problem hiding this comment.
Fix the Windows path failures before enabling this job
On the reviewed parent tree, this command cannot pass on Windows: tests/desktop-stop-intent.test.ts line 128 stores child.pathname (for example, /C:/...) as a string and line 136 passes it to readFile, which is not a valid Windows filesystem path. The referenced fixes from #8980 are not present in this commit or its parent, so every frontend PR and push to main will receive a failing Windows job until those fixes land; include the fixes here or add the job only after they are merged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and it is the reason this is a second PR rather than a change folded into #8980. Confirmed on a real runner rather than reasoned: staged on current main, this job reports 3594 tests, 3581 passed, 13 failed, which is exactly #8980's diff. With #8980 applied the same job is 3598 passed, 0 failed.
The PR body now carries a Merge order section saying this needs #8980 first. Not folding the fixes in here on purpose: duplicating them across two open PRs means one of them has to be resolved by hand at merge, and #8980 is the one carrying the static rule that keeps the shape from returning.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e54472574e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # duplicating them here would spend a second runner to re-check bytes that | ||
| # cannot differ, and `--strict-allow-scripts` needs the npm 11.16 upgrade | ||
| # step besides. | ||
| - run: npm ci --no-fund --no-audit |
There was a problem hiding this comment.
Run the pre-install audit before Windows npm ci
When a dependency change introduces a blocked package or an unapproved lifecycle hook, this Windows job can execute it before either independent audit finishes: jobs and workflows run concurrently, npm 10 ignores this repository's npm-11-only allowScripts policy, and this command does not pass --ignore-scripts (which npm documents as the switch that prevents package scripts from running). Thus the Ubuntu job may eventually reject the same lockfile, but only after the Windows runner has already executed the payload; perform the structural audit before this install and use the hardened npm setup, or install with scripts disabled.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed, and the concurrency point is the part I had wrong: I treated the ubuntu job as a gate that protects this one, and jobs in a workflow do not order that way. Fixed in 3088c0d.
The Windows job now runs scripts/lockfile_supply_chain_audit.py before installing, exactly as the ubuntu job does and for the same reason, and installs with --ignore-scripts so no package script runs on this runner regardless. Not --strict-allow-scripts: that needs the npm 11.16 upgrade step, and running no install script at all is the stronger position for a job that is only a platform gate.
Checked that the suite still passes off an --ignore-scripts install: 3594 passed, 0 failed. Nothing here needs a native build step, since the tests are node:test over the TypeScript sources.
Review: jobs run concurrently, so the ubuntu job rejecting a lockfile does not help a Windows runner that has already installed it, and npm 10 ignores the npm-11-only allowScripts policy. Run the same pre-install structural scan here, and install with --ignore-scripts so no package script runs on this runner at all.
Frontend CI runs on
ubuntu-latestonly, so nothing in this org has ever executed the frontend unit suite on Windows. A test that is correct on POSIX and wrong on Windows therefore stays green here forever.What that has cost
Measured on a staging replica of this workflow, against
mainat 34c9d98:ubuntu-latestwindows-latestThe 13 are path and URL confusion in three test files and are fixed in #8980, which also adds a static rule so those two shapes fail on Linux. This PR is the other half: the shapes nobody has thought of yet.
The job
Deliberately not a matrix over the existing job. Per-step measurement on the staging replica:
npm cinpm run typechecknpm run buildnpm testThe tests themselves are not the expensive part, and typecheck, build, the Chromium install and the three browser smokes cannot fail on Windows for a reason they would not also fail on ubuntu. Repeating them would roughly triple the cost of this workflow to re-answer a question ubuntu already answered.
So the new job is checkout, node,
npm ci,npm test. Measured at 123s as a standalone Windows job, against 167s for the existing ubuntu one. It is a public repo, so the runner minutes are free; the real cost is one more concurrent job slot per frontend PR, which is what the scope above is minimising.npm cithere is the plain form, not the hardened install the ubuntu job runs. The lockfile audit, the allowScripts pins and--strict-allow-scriptsare supply-chain gates on the same lockfile, and this job is a platform gate, so duplicating them would spend a second runner re-checking bytes that cannot differ.Line endings
No special handling, and this is measured rather than assumed.
.gitattributespinsstudio/frontend/** text=auto eol=lf, so the tree checks out LF whatever the runner'score.autocrlfsays. A Windows job run with the runner's default git config, with no override, reported no CRLF in either a source file or a test file and passed the suite.That matters because many tests in this suite read their own sources with
readFileSyncand assert on exact substrings including indentation.Measured rather than reasoned: a
windows-latestjob with no git config step at all reportedso the runner does default to
autocrlf=trueand.gitattributesdoes override it for this tree.The one test that could not pass
background-load-notice.test.ts, "a healthy read resets the stall window", failed on one of two Windows runs of the same commit:It drove the poll loop with
pollMs: 1, stallMs: 30and assertedreads > 4. The default timer resolution on Windows is about 15.6 ms, so two polls consume the whole 30 ms window before the healthy read at poll 3 ever arrives.Both readings, since a Windows-only failure can be either side:
pollMs: 2000andstallMs: 3600000. A 15 ms timer skew is five orders of magnitude below the margin the product actually uses, so no user is affected. The test asserts a property of the algorithm using a stopwatch too coarse to read it.Date.now()plussetTimeoutgenuinely mis-sequences on Windows in a way a user meets. It does not: the loop is correct, and at the real cadences the granularity is irrelevant.The test is wrong, so it is fixed rather than skipped. And it was worth more than that:
The old assertion measured nothing. With
lastHealthy = Date.now()deleted fromsettleWhenLoadEnds, so that the stall window is never reset at all, the old test still passed on Linux 5 times out of 5. 30 ms of 1 ms polls clears 4 reads whether or not the window restarts.The replacement drops the millisecond budget and compares the loop against itself: run it with no healthy read at all, then run it again with one healthy read halfway through that count, and require the second run to survive at least 25 percent more polls. Whatever a poll costs on the platform, a window restarted halfway must carry the loop about half as far again, so the comparison divides the platform out.
Checked against a deliberately broken tree, the same one as above:
lastHealthyreset presentlastHealthyreset deletedIt costs about 1s, since it now runs the settle loop twice at a 400 ms stall window rather than once at 30 ms. The whole suite is about 10s.
Testing
Test and workflow only; no source changes and nothing a user can see changes.
npm test3594 passed 0 failed andnpm run typecheckclean locally.scripts/lint_workflow_triggers.py,tests/studio/test_playwright_suites_run_in_ci.py,tests/studio/test_main_runs_survive_merge_bursts.pyandtests/studio/test_smoke_workflows_share_one_script.pyall pass with the new job in place.Merge order
This needs #8980 first. The new job runs the suite as it is, so on
maintoday it reports the 13 path failures and Frontend CI goes red. Staged on currentmain, it does exactly that:which is the point of the job, and is #8980's diff. With #8980 applied the same job is 3598 passed, 0 failed. The stall-window fix in this PR is already accounted for in both numbers: it passed on
windows-latesthere.The job as shipped, on a real Windows runner
Not a lookalike: the
windowsjob was lifted verbatim out of this file onto a staging branch made ofmain+ #8980 + this PR, and run onwindows-latest.So the audit step, the
--ignore-scriptsinstall and the suite all pass on Windows in the configuration this PR ships, at 123s against the ubuntu job's 167s.