Skip to content

ci: test on Windows in PR CI and the release platform matrix - #531

Merged
blalterman merged 8 commits into
masterfrom
ci/windows
Nov 5, 2026
Merged

blalterman merged 8 commits into
masterfrom
ci/windows

Conversation

@blalterman

@blalterman blalterman commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Adds Windows testing, per PyHC standard #4 (packages must strive to support all major operating systems).

Workflows

  • continuous-integration.yml: new test-windows job runs the test suite on windows-latest (Python 3.12) for every pull request, with a 30-minute timeout. The Linux validate job is unchanged, so lint, import layering, and the release build still run once, on Linux.
  • ci-summary now reports both jobs and exits 1 unless both succeed. Before this PR it printed "failed" but always exited 0, so it showed green while a job was red.
  • publish.yml: platform-matrix adds windows-latest, with run steps under shell: bash so the existing scripts work on the Windows runner. Its Windows cells run only on version tags, so they are first exercised at the next release.

Test portability fixes

The package needed no changes for Windows. These failures came from tests assuming Unix behavior:

  • test_declared_versions.py: read workflow files as UTF-8 (Windows defaults to cp1252, which cannot decode the emoji in them).
  • test_commit_message_hook.py: resolve bash with shutil.which; a bare bash on Windows runs the WSL launcher from System32.
  • solar_activity/test_cache.py: set USERPROFILE as well as HOME, since Path.home() reads USERPROFILE on Windows.
  • plotting/labels/test_elemental_abundance.py: compare Path objects instead of strings, so / and \ separators match.
  • fitfunctions/test_p0_contract.py: the python -O probe inherits the environment (overriding only PYTHONPATH) and reports the child's stderr on failure.

Package fix: DataLoader.age

DataLoader.age returned now() - ctime, and ctime read now() again after the cache lookup, so age fell short by the time between the two reads. This made test_age_is_the_time_since_the_cache_was_written fail by microseconds on Linux and Windows. age now returns the cached copy's age in one reading; with nothing cached it still returns the time since 1970. A new test fakes the clock to advance one minute per read, which makes the shortfall deterministic. It landed first as xfail(strict=True); the fix removes the marker.

Release matrix

  • platform-matrix uses setup-python's cache: pip, which finds pip's cache on every OS; the old ~/.cache/pip step did nothing on macOS and Windows.
  • It installs build, setuptools_scm and wheel, so tests/test_release_artifacts.py runs in the release gate instead of skipping. This matrix runs only on version tags, so these changes are first exercised at the next release.

🤖 Generated with Claude Code

Add a test-windows job to continuous-integration.yml that runs the test
suite on windows-latest (Python 3.12) for every pull request, and report
its result in ci-summary. Lint, import layering, and the release build
stay on the Linux validate job, which is unchanged.

Add windows-latest to publish.yml's platform-matrix and run its steps
under bash so the same scripts work on every runner.

PyHC standard #4 asks packages to support all major operating systems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @blalterman's task in 18s —— View job


Review of PR #531: Windows CI

The change is small and sound. I read the diff and the surrounding workflow files. I did not run the workflows, so none of this is checked on a Windows runner.

What's good

  • test-windows is a separate job, so the Linux validate job is untouched. Lint, import layering, and the release build still run once.
  • ci-summary now needs both jobs, and the pass condition requires both to be success. Because the job uses if: always(), a skipped or cancelled Windows job counts as a failure, which is the behavior you want.
  • defaults.run.shell: bash keeps the existing scripts working on Windows. This includes the multi-line python -c "..." in publish.yml.
  • cache: pip with cache-dependency-path: pyproject.toml in setup-python is more portable than the manual ~/.cache/pip cache in validate.

Suggestions (none blocking)

  1. Stale pip cache in publish.yml. The actions/cache step in platform-matrix still uses ~/.cache/pip. Pip's cache on Windows is in %LOCALAPPDATA%\pip\Cache, so that step does nothing useful there. It is harmless, but you could switch to cache: pip on setup-python as test-windows does. Alternatively, skip the manual cache step when runner.os == 'Windows'.
  2. Test cost versus signal. The new job runs the whole suite on every PR. If Windows runs are noticeably slower than Linux, consider adding timeout-minutes (Linux has a similar guard elsewhere in the repo) so a hung Windows job doesn't block the PR for the default 6 hours.
  3. Sanity check before relying on it. tests/test_release_artifacts.py builds with --no-isolation, and the CI test step runs the full tests/ directory. Path separators, file locking on temp dirs, and \r\n line endings are the usual failure sources on Windows. The first run of this PR will show whether these are real, so I'd treat that run as the real test of the change. If it fails on platform-specific tests, either fix them or mark them with a skip marker. Don't mark the Windows job non-required.
  4. Hardcoded Python version. test-windows uses PYTHON_VERSION (3.12), which matches validate. The release matrix covers 3.12 to 3.14 on Windows, so the PR gate stays cheap and the release gate stays thorough. This design is reasonable.
  5. Branch protection. If ci-summary is a required check, the new gating happens automatically. If the individual job names are required checks, add test-windows to the required list.

Security
No new secrets or permissions are involved. The actions are pinned to the same major versions already used in the repo.

Tests
This PR changes only workflow files, so there is no test code to change. CLAUDE.md's test-first rule doesn't apply here.

No blocking issues. It's fine to merge once the Windows job passes on this PR.

blalterman and others added 2 commits November 5, 2026 06:39
On Windows the default encoding is cp1252, so reading workflows that contain emoji raised UnicodeDecodeError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_commit_message_hook: resolve bash with shutil.which. A bare "bash"
  makes Windows search System32 before PATH and run the WSL launcher,
  which cannot open the Windows path to the message file.
- test_cache: also point USERPROFILE at the fake home. Path.home() on
  Windows reads USERPROFILE and ignores HOME.
- test_elemental_abundance: compare the path to Path("C/N-OV-H") rather
  than checking str(path) for a forward slash, which Windows renders as a
  backslash. The path is the same on every OS.
- test_p0_contract: keep SYSTEMROOT in the python -O probe's environment,
  which Windows processes need to start, and assert on the return code
  with the child's stderr as the message instead of hiding it behind
  check=True.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @blalterman's task in 22s —— View job


Review of PR #531: Windows CI

I read the full diff against origin/master. I did not run the workflows, so none of this has been checked on a Windows runner.

  • Read the workflow and test changes
  • Checked the PYTHON_VERSION env and the platform-matrix steps
  • Posted the review

What's good

  • test-windows is its own job, so Linux validate is untouched. Lint, import layering, and the release build still run once, on Linux.
  • ci-summary needs both jobs and requires both to be success. With if: always(), a skipped or cancelled Windows job counts as a failure.
  • PYTHON_VERSION is defined at workflow level, so ${{ env.PYTHON_VERSION }} resolves in the new job.
  • defaults.run.shell: bash keeps the existing scripts working on Windows. This includes the multi-line python -c in publish.yml.
  • The test fixes are targeted and correct:
    • USERPROFILE is set for Path.home().
    • shutil.which("bash") avoids the WSL launcher in System32.
    • SYSTEMROOT is passed through to the -O subprocess.
    • UTF-8 is explicit in read_text.
    • The Path("C/N-OV-H") comparison is stricter than the old substring check and is portable.
  • The -O test now asserts returncode == 0, out.stderr instead of using check=True. A failure now prints stderr.

Suggestions (none blocking)

  1. Ineffective pip cache on Windows (publish.yml). The actions/cache step in platform-matrix caches ~/.cache/pip. On Windows, pip's cache is %LOCALAPPDATA%\pip\Cache, so the step is a no-op there. It is harmless. You could use cache: pip on setup-python, as test-windows does, or add if: runner.os != 'Windows'.
  2. No timeout on the Windows job. Add timeout-minutes (for example 30) to test-windows. Otherwise a hung test holds the required check for the 6-hour default. Windows runners are often slower than Linux ones.
  3. Install parity. test-windows installs build setuptools_scm wheel because tests/test_release_artifacts.py builds with --no-isolation. The platform-matrix install step only runs pip install -e ".[dev]". If that test is not skipped on the other platforms, the release matrix on Windows could fail where the PR job passes. Compare the two install steps. If the test needs these packages, put them in the dev extra so every job gets them.
  4. First run is the real test. Common Windows failure sources are path separators, file locks on temp directories, and \r\n line endings. Treat the first green test-windows run as the acceptance check. If a test fails for a Windows-specific reason, fix or skip that test. Don't make the job non-required.
  5. Branch protection. If ci-summary is the required check, the new gating applies automatically. If individual job names are required, add test-windows.

Security
No new secrets or permissions. The actions use the same pinned major versions as the rest of the repo.

Tests
The test edits are portability fixes. They do not change what the tests check on Linux. They look like guards, so CLAUDE.md's xfail-first rule doesn't apply.

No blocking issues. It's fine to merge once test-windows is green on this PR.

The probe ran with a hand-built environment of PYTHONPATH and PATH (plus
SYSTEMROOT after the previous fix). On Windows, Path.home() needs
USERPROFILE, and astropy calls it on import, so the child failed with
"RuntimeError: Could not determine home directory." Inherit os.environ
and override only PYTHONPATH, so the probe still imports this checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @blalterman's task in 29s —— View job


Review of PR #531: Windows CI

I read the diff of the four commits (git diff HEAD~4 HEAD) and the surrounding workflow files. I did not run anything on a Windows runner, so the first test-windows run is the real check.

What's good

  • test-windows is its own job, so validate is unchanged. PYTHON_VERSION is defined at workflow level (continuous-integration.yml:16), so it resolves in the new job.
  • ci-summary needs both jobs and requires both to be success. Because it uses if: always(), a skipped or cancelled Windows job counts as a failure.
  • defaults.run.shell: bash keeps the existing scripts working on Windows, including the multi-line python -c in publish.yml.
  • The test fixes are targeted:
    • USERPROFILE is set for Path.home().
    • shutil.which("bash") avoids the WSL launcher in System32.
    • The -O subprocess inherits the environment, so SYSTEMROOT is available. The returncode == 0, out.stderr assert now shows the failure output.
    • read_text(encoding="utf-8") avoids the cp1252 default.
    • path == Path("C/N-OV-H") is stricter than the old substring check and works on every OS.
  • All of these are portability guards. They don't change what the tests check on Linux, so the xfail-first rule in CLAUDE.md doesn't apply.

Suggestions (none blocking)

  1. No-op pip cache in publish.yml. The actions/cache step still caches ~/.cache/pip. Pip's Windows cache is %LOCALAPPDATA%\pip\Cache, so on Windows the step saves nothing. It's harmless. You could use cache: pip on setup-python, as test-windows does, or add if: runner.os != 'Windows'.
  2. No timeout-minutes on test-windows. A hung test would hold the check for the 6-hour default. Something like 30 minutes would bound it. Windows runners are often slower than Linux.
  3. Install parity in the release matrix. platform-matrix installs only .[dev], not build setuptools_scm wheel. This is low risk: tests/test_release_artifacts.py calls pytest.importorskip for each of them, so it skips instead of failing. The Linux and macOS cells already behave this way. The release matrix just won't exercise that test on any OS. Add the extra install line if you want it to run there.
  4. Windows-specific failures. Path separators, file locks on temp directories, and \r\n line endings are the usual causes. The test_commit_message_hook.py test runs a bash script through Git Bash. If the checkout converts line endings to CRLF, the script could break. actions/checkout on Windows follows the runner's core.autocrlf, so a .gitattributes rule with *.sh text eol=lf would make that deterministic. This is a guess I haven't verified, so check the first run.
  5. Branch protection. If ci-summary is the required check, the new gating applies automatically. If the required checks are the individual job names, add test-windows.

Security
There are no new secrets or permissions, and the action versions match the rest of the repo.

No blocking issues. It's fine to merge once test-windows is green on this PR.

blalterman and others added 2 commits November 5, 2026 07:09
DataLoader.age computes now() - ctime, and ctime reads now() again after
looking up the cache, so age falls short by the time between the two reads.
This is why test_age_is_the_time_since_the_cache_was_written failed by
microseconds on Linux (7.5 us) and Windows (0.3 us). The new test fakes the
clock to advance one minute per read, which makes the shortfall
deterministic.

Marked xfail(strict=True, raises=AgeShortError) until the fix lands.
Verified: xfails as committed; with the fix applied transiently it fails as
XPASS(strict); with an unrelated assert False injected it is reported
FAILED, not xfailed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
age returned now() - ctime, and ctime looked up the cache and read now()
again, so age fell short by the time between the two reads. age now
returns the cached copy's age directly (cache.cached_age), and the time
since 1970 when nothing is cached, as before.

Before: test_age_does_not_depend_on_when_the_clock_is_read xfailed
(AgeShortError: age one minute short under a clock advancing a minute per
read). After: it passes, the xfail marker is removed, and the
solar_activity tests pass (322 passed, 8 skipped).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @blalterman's task in 22s —— View job


Review of PR #531: Windows CI

I read the diff of the six commits (git diff HEAD~6 HEAD) and the cache code that age now calls. I did not run anything on a Windows runner, so the first test-windows run is the real check.

What's good

  • test-windows is its own job, so validate is unchanged. ci-summary needs both jobs and requires both to be success. With if: always(), a skipped or cancelled Windows job counts as a failure.
  • defaults.run.shell: bash keeps the existing scripts working on Windows.
  • The test portability fixes are targeted and don't change what the tests check on Linux.

The DataLoader.age change (src/solarwindpy/solar_activity/base.py:191)

  • age now reads cache.cached_age(self.url) once, instead of now() - ctime. ctime was itself now() - cached_age, so the old form was short by the time between the two clock reads. The new form removes that, and the no-cache branch (now() - pd.to_datetime(0)) matches the old result.
  • The new test follows the repo pattern: it fakes only the clock boundary and has a clear failure message.
  • The workflow was not meant to touch library code, so this belongs in the PR description. It was a source change to fix a Windows-visible flake, and it is a fix to a computed value, not a rename or a change to physics. If you consider it a physical-result change, split it into its own PR.
  • The test's own comment says it asserts a lower bound only. That's enough to catch the regression, but the existing test already bounds the upper side.

Suggestions (none blocking)

  1. No-op pip cache in publish.yml. The actions/cache step still caches ~/.cache/pip, which is not pip's cache path on Windows (%LOCALAPPDATA%\pip\Cache). It's harmless. Use cache: pip on setup-python, or add if: runner.os != 'Windows'.
  2. No timeout-minutes on test-windows. A hung test would hold the required check for the 6-hour default. About 30 minutes would bound it.
  3. Install parity. The release matrix installs only .[dev]. tests/test_release_artifacts.py uses pytest.importorskip, so it skips there rather than failing. The release matrix just won't run that test on any OS. If you want it to run, add build setuptools_scm wheel to the dev extra so every job gets them.
  4. Line endings. test_commit_message_hook.py runs a bash script. If Windows checkout converts it to CRLF, it could break. A .gitattributes rule such as *.sh text eol=lf would make that deterministic. I haven't verified this, so check the first run.
  5. Branch protection. If ci-summary is the required check, the gating applies automatically. If individual job names are required, add test-windows.

Security
No new secrets or permissions, and the action versions match the rest of the repo.

No blocking issues. It's fine to merge once test-windows is green on this PR.

ci-summary printed "validation failed" but always exited 0, so it showed
green while validate or test-windows were red. It now exits 1 on failure.
test-windows gets timeout-minutes: 30 (the suite takes about 2 minutes),
so a hung test fails fast instead of running for GitHub's 6-hour default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @blalterman's task in 19s —— View job


Review of PR #531: Windows CI

I read the workflow diff for all 7 commits. I did not run anything on a Windows runner, so the first green test-windows run is still the real check.

Addressed since the last review

  • test-windows now has timeout-minutes: 30.
  • ci-summary now runs exit 1 on failure, so a failed Windows job turns the summary red.
  • test-windows installs build setuptools_scm wheel explicitly, so tests/test_release_artifacts.py runs there.

Still open (none blocking)

  1. Pip cache in publish.yml. The platform-matrix cache step still points at ~/.cache/pip, which is not pip's cache on Windows (%LOCALAPPDATA%\pip\Cache). It does nothing there but does no harm. Either use cache: pip on setup-python, as test-windows does, or add if: runner.os != 'Windows'.
  2. Release matrix skips test_release_artifacts.py. platform-matrix installs only .[dev]. The test uses pytest.importorskip, so it skips on every OS rather than failing. This is the same on Linux and macOS today. If you want it to run in the release gate, put build, setuptools_scm and wheel in the dev extra, or add the install line.
  3. Line endings. tests/test_commit_message_hook.py runs a bash script. If the Windows checkout converts it to CRLF, it could fail. A .gitattributes rule such as *.sh text eol=lf would make this deterministic. I have not verified this, so watch the first run.
  4. Branch protection. If ci-summary is the required check, the new gating applies automatically. If individual job names are required, add test-windows.

DataLoader.age change (src/solarwindpy/solar_activity/base.py)

  • It reads cache.cached_age once, which removes the clock skew between two reads. It fixes a computed value and is not a rename or a physics change.
  • The PR description says the PR only touches workflows, so add a line about this source change and the test portability fixes.

Security
There are no new secrets or permissions, and the action versions match the rest of the repo.

Verdict
No blocking issues. It's fine to merge once test-windows is green.

The platform-matrix cached ~/.cache/pip, which is pip's cache only on
Linux, so the cache did nothing on macOS and Windows. Use setup-python's
cache: pip, which finds the right directory on each OS. Install build,
setuptools_scm and wheel so tests/test_release_artifacts.py runs in the
release gate instead of skipping on every OS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @blalterman's task in 26s —— View job


Review of PR #531: Windows CI

I read the diff of all 8 commits against the merge base and the cached_age and ctime code. I did not run anything on a Windows runner, so the first green test-windows run is still the real check.

Addressed since the last review

  • platform-matrix now uses cache: pip on setup-python and drops the manual ~/.cache/pip cache. The pip-cache note from earlier reviews is resolved.
  • platform-matrix now installs build setuptools_scm wheel, so test_release_artifacts.py runs in the release gate.

DataLoader.age (src/solarwindpy/solar_activity/base.py:191)

  • age reads cache.cached_age(self.url) once. This matches ctime's computation, so the two cannot drift apart. The no-cache branch gives the same value as before (now() - 1970).
  • ctime and age now each call cached_age. That is two reads of the same lookup, not a duplicated block of logic, so it is not a violation of the second-copy rule.

Still open (none blocking)

  1. Line endings. tests/test_commit_message_hook.py runs a bash script. If the Windows checkout converts it to CRLF, it could fail. A .gitattributes rule such as *.sh text eol=lf would make this deterministic. I have not verified this, so watch the first run.
  2. Branch protection. If ci-summary is the required check, the new gating applies automatically. If individual job names are required, add test-windows.
  3. Release matrix is untested. platform-matrix runs only on version tags, so its Windows cells, including the new pip install build setuptools_scm wheel step and the cache: pip change, first run at the next release. A workflow_dispatch trial run, if the workflow allows it, would exercise them before then. The PR description is accurate about this.
  4. PR description. It mentions the pip cache path as "not covered", but the latest commit fixed that, and the release-artifacts test now runs in the matrix. Update the "Not covered" section to match.

Security
No new secrets or permissions. The action versions match the rest of the repo.

Tests
The new age test fakes the clock and landed first as xfail(strict=True), as CLAUDE.md requires. The portability edits are guards.

Verdict
No blocking issues. It's fine to merge once test-windows is green.

@blalterman
blalterman merged commit 4c1de30 into master Nov 5, 2026
20 of 21 checks passed
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