Skip to content

Build and test on Windows in CI - #119

Merged
fylorn merged 1 commit into
mainfrom
feat/windows-ci
Sep 23, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/windows-ci

Conversation

@fylorn

@fylorn fylorn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Stacked on #118 — it needs that PR's loopback transport to compile at all. Review #118 first; this one is what actually proves it.

Core has a platform half for the things Windows does differently — a loopback port where unix has a socket, a handle wait where unix has a signal — and until now none of it had ever been compiled. A #[cfg(windows)] module that "passes" looks exactly like one nobody has ever looked at.

What the job does

clippy, tests and a release build of twcore on windows-latest. cargo fmt is not repeated — formatting does not depend on the platform, and running it twice only takes twice as long.

The macOS smoke script does not run here (stat -f, curl --unix-socket, BSD spellings throughout) and porting it is its own piece of work. What this does instead is prove the two things that are genuinely different on this platform:

  • the binary starts
  • the control plane answers on a loopback port, refusing a request without the token and serving one with it

Without that, the Windows failure mode is a fully green CI and an interface that sits on the connection screen forever.

The wait is on the port file, because core writes it only after the bind succeeds — its existence is exactly "it is listening". If core exits first, the step prints its stderr rather than waiting out the timeout.

Two things to decide

1. This job is not a required check. Branch protection requires the context check, so windows will show up in the PR checks list but will not block a merge. Converting check into a matrix would rename the context and break the existing requirement, so that is not a silent change to make. To make it required:

gh api -X PATCH repos/ThinkWatchProject/ThinkWatch-Core/branches/main/protection/required_status_checks \
  -f 'contexts[]=check' -f 'contexts[]=windows'

That is a repository setting, so it is yours to run rather than mine.

2. x64 only for now. arm64 Windows would need the windows-11-arm runner; adding it is worth doing before release artifacts exist, not before this job has ever run once. Release targets for both are a separate piece.

🤖 Generated with Claude Code

@fylorn
fylorn force-pushed the feat/windows-ci branch 5 times, most recently from 54d34a6 to 75db2bd Compare September 23, 2026 05:52
fylorn added a commit that referenced this pull request Sep 23, 2026
…ling

`std::fs::rename` refuses when the destination exists on Windows. Every
call to `write_atomic` has an existing destination -- it rewrites the
client configuration the user already has -- so adoption did not merely
degrade on that platform, it failed at the first step, reporting "the file
exists" about a file whose existence is the entire point.

`MoveFileExW` with `MOVEFILE_REPLACE_EXISTING` is the same-volume atomic
replace that `rename(2)` already is on unix.

Not "delete the destination, then move". That leaves a window in which the
user's configuration file does not exist, and a process that dies inside
it takes the original with it -- before we have told them where the backup
went.

`MOVEFILE_WRITE_THROUGH` so the move is on disk before the call returns.
This writes other people's configuration files, and "we said it was saved
and it was not there after a power cut" is far harder to track down than a
write that failed outright.

The new test reads as a no-op on unix, where rename has always overwritten.
It is a stake driven in for the other platform.

Found by the Windows CI job in #119, which is stacked on this and is what
confirms the fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 23, 2026
…ling (#122)

`std::fs::rename` refuses when the destination exists on Windows. Every
call to `write_atomic` has an existing destination -- it rewrites the
client configuration the user already has -- so adoption did not merely
degrade on that platform, it failed at the first step, reporting "the file
exists" about a file whose existence is the entire point.

`MoveFileExW` with `MOVEFILE_REPLACE_EXISTING` is the same-volume atomic
replace that `rename(2)` already is on unix.

Not "delete the destination, then move". That leaves a window in which the
user's configuration file does not exist, and a process that dies inside
it takes the original with it -- before we have told them where the backup
went.

`MOVEFILE_WRITE_THROUGH` so the move is on disk before the call returns.
This writes other people's configuration files, and "we said it was saved
and it was not there after a power cut" is far harder to track down than a
write that failed outright.

The new test reads as a no-op on unix, where rename has always overwritten.
It is a stake driven in for the other platform.

Found by the Windows CI job in #119, which is stacked on this and is what
confirms the fix.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 23, 2026
The source path is squashed into one file name so a backup says whose it
is. It only replaced `/`. On Windows the separator is `\`, so the name
kept its backslashes -- and `Path::join` given an absolute path discards
the base entirely. The "file inside the backup directory" quietly became
the user's own configuration file.

What happened next was `create_new`, reporting that the file already
exists. That complaint is the thing that saved us: without it the backup
step would have written backup text over the user's configuration, and not
damaging other people's files is the entire reason this module exists.

The colon goes too. The one in `C:` is not legal in a Windows file name.

The test runs on macOS and fails against the old implementation, which is
the part worth keeping: a `\` separator survives string replacement of `/`
on any platform, so this never needed a Windows machine to be caught. It
was caught by one only because nothing had asked.

Found by the Windows CI job in #119.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 23, 2026
The source path is squashed into one file name so a backup says whose it
is. It only replaced `/`. On Windows the separator is `\`, so the name
kept its backslashes -- and `Path::join` given an absolute path discards
the base entirely. The "file inside the backup directory" quietly became
the user's own configuration file.

What happened next was `create_new`, reporting that the file already
exists. That complaint is the thing that saved us: without it the backup
step would have written backup text over the user's configuration, and not
damaging other people's files is the entire reason this module exists.

The colon goes too. The one in `C:` is not legal in a Windows file name.

The test runs on macOS and fails against the old implementation, which is
the part worth keeping: a `\` separator survives string replacement of `/`
on any platform, so this never needed a Windows machine to be caught. It
was caught by one only because nothing had asked.

Found by the Windows CI job in #119.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn force-pushed the feat/windows-ci branch 6 times, most recently from 7679937 to 7f5c539 Compare September 23, 2026 07:28
Core has a platform half for the things Windows does differently -- a
loopback port where unix has a socket, a handle wait where unix has a
signal -- and until now none of it had ever been compiled. A
`#[cfg(windows)]` module that "passes" looks exactly like one nobody has
ever looked at.

`cargo fmt` is not repeated: formatting does not depend on the platform,
and running it twice only takes twice as long.

The macOS smoke script does not run here -- `stat -f`, `curl
--unix-socket`, BSD spellings throughout -- and porting it is its own
piece of work. What this does instead is prove the two things that are
genuinely different on this platform: that the binary starts, and that
the control plane answers on a loopback port, refusing a request without
the token and serving one with it. Without that, the Windows failure mode
is a fully green CI and an interface that sits on the connection screen
forever.

The port file is what the wait is on, because core writes it only after
the bind succeeds -- its existence is exactly "it is listening".

The job found something on its first run, which is the point of it: a cast
to the type the value already had. `IF_OPER_STATUS` is an `i32`, and
`-D warnings` is not relaxed here for the same reason it is not relaxed
anywhere else. The cross-check that should have caught it ran `cargo
check` rather than clippy -- a lint is not a compile error, and the method
now runs clippy with the flags CI uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit ff35817 into main Sep 23, 2026
2 checks passed
@fylorn
fylorn deleted the feat/windows-ci branch September 23, 2026 07:59
@fylorn fylorn mentioned this pull request Sep 23, 2026
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