Skip to content

Studio: run the frontend unit tests on Windows in CI - #9099

Merged
danielhanchen merged 3 commits into
mainfrom
fix-windows-frontend-ci
Aug 17, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix-windows-frontend-ci

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Frontend CI runs on ubuntu-latest only, 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 main at 34c9d98:

runner tests pass fail
ubuntu-latest 3594 3594 0
windows-latest 3594 3581 13

The 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:

step ubuntu windows
checkout + setup-node 6s 17s
npm ci 20s 44s
npm run typecheck 54s 48s
npm run build 35s 33s
npm test 47s 49s
whole job 167s 198s

The 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 ci there is the plain form, not the hardened install the ubuntu job runs. The lockfile audit, the allowScripts pins and --strict-allow-scripts are 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. .gitattributes pins studio/frontend/** text=auto eol=lf, so the tree checks out LF whatever the runner's core.autocrlf says. 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 readFileSync and assert on exact substrings including indentation.

Measured rather than reasoned: a windows-latest job with no git config step at all reported

core.autocrlf: true   (file:C:/Program Files/Git/etc/gitconfig)
CRLF in app.tsx: false
CRLF in a test:  false

so the runner does default to autocrlf=true and .gitattributes does 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:

expected the window to restart, got 2 reads

It drove the poll loop with pollMs: 1, stallMs: 30 and asserted reads > 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:

  • The test is wrong. In production the same values are pollMs: 2000 and stallMs: 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.
  • The source is wrong. It would have to be that Date.now() plus setTimeout genuinely 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 from settleWhenLoadEnds, 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:

tree old assertion new assertion
lastHealthy reset present pass 5/5 pass 5/5
lastHealthy reset deleted pass 5/5 fail 5/5

It 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 test 3594 passed 0 failed and npm run typecheck clean locally. scripts/lint_workflow_triggers.py, tests/studio/test_playwright_suites_run_in_ci.py, tests/studio/test_main_runs_survive_merge_bursts.py and tests/studio/test_smoke_workflows_share_one_script.py all pass with the new job in place.

Merge order

This needs #8980 first. The new job runs the suite as it is, so on main today it reports the 13 path failures and Frontend CI goes red. Staged on current main, it does exactly that:

# tests 3594
# pass 3581
# fail 13

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-latest here.

The job as shipped, on a real Windows runner

Not a lookalike: the windows job was lifted verbatim out of this file onto a staging branch made of main + #8980 + this PR, and run on windows-latest.

Frontend unit tests (Windows)  success  123s
  checkout                                        11s
  setup-node                                       5s
  setup-python                                     0s
  Lockfile supply-chain audit (pre-install scan)   2s
  npm ci --ignore-scripts --no-fund --no-audit    44s
  Unit tests                                      56s

# tests 3598
# pass 3598
# fail 0

So the audit step, the --ignore-scripts install and the suite all pass on Windows in the configuration this PR ships, at 123s against the ubuntu job's 167s.

…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.
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +287 to +288
- name: Unit tests
run: npm test

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@danielhanchen
danielhanchen merged commit 5a1655c into main Aug 17, 2026
32 of 34 checks passed
@danielhanchen
danielhanchen deleted the fix-windows-frontend-ci branch August 17, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant