From d532818e075b387207ff1b51437934c318d951e1 Mon Sep 17 00:00:00 2001 From: nomyfan Date: Sat, 23 May 2026 11:35:57 +0800 Subject: [PATCH] ci: add macOS and Windows to test matrix Expand CI to run tests on ubuntu, macos, and windows. Fix hardcoded Unix paths in tests to work cross-platform. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/test.yml | 3 ++- tests/test_core.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d8d1b12..a68ed84 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,9 +8,10 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: diff --git a/tests/test_core.py b/tests/test_core.py index e78b061..2a2acb0 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,3 +1,4 @@ +import os import subprocess from pathlib import Path, PurePosixPath from unittest.mock import patch @@ -10,6 +11,7 @@ commit_changes, find_site_packages, restore_clean_package, + venv_python, ) @@ -215,7 +217,10 @@ def _setup_target_env( self, tmp_path: Path, package_name: str, version: str ) -> Path: target_env = tmp_path / ".venv" - site_packages = target_env / "lib" / "python3.9" / "site-packages" + if os.name == "nt": + site_packages = target_env / "Lib" / "site-packages" + else: + site_packages = target_env / "lib" / "python3.9" / "site-packages" site_packages.mkdir(parents=True) dist_info = ( site_packages / f"{package_name.replace('-', '_')}-{version}.dist-info" @@ -298,7 +303,7 @@ def test_commit_restores_target_package_before_apply( "--no-deps", "mypackage==1.0.0", "--python", - str(target_env / "bin/python"), + str(venv_python(target_env)), ] def test_commit_can_skip_restore(self, tmp_path: Path, monkeypatch): @@ -338,6 +343,6 @@ def test_restore_clean_package_uses_target_env_python(self, tmp_path: Path): "--no-deps", "mypackage==1.0.0", "--python", - str(target_env / "bin/python"), + str(venv_python(target_env)), ] )