Skip to content

Commit 1bdcaab

Browse files
authored
build: adjust platforms for release and CI, add Windows for CI (#950)
* build: adjust platforms for release and CI * fix: adjust workflow * fix: use `.` instead of `source` for windows compatibility * fix: another try to make test work on Windows * refactor: avoid duplicating workflow step * fix: explicitly shutdown process pool at exit * fix: register `atexit` for process pools later so it's executed earlier * fix: add `wait = True` on shutdown `ProcessPoolExecutor` * fix: avoid unncessary holding of `ProcessPoolExecutor` to allow its GC * debug: show more messages for debug * fix: register shutting down process pool for early execution * Revert "fix: register shutting down process pool for early execution" This reverts commit 4c716e5. * fix: explicitly shutdown in pytest fixture * fix: try to avoid wait on process pool shutdown * fix: ignore `SIGINT` during shutting down the pool * fix: directly exit with 0 after tests in Windows * debug: flush stdout errors, make test run faster * debug: switch shell in Windows to cmd * cleanup after pass
1 parent aa24f2c commit 1bdcaab

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

.github/workflows/_test.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,56 @@ jobs:
1010
build-test:
1111
strategy:
1212
matrix:
13-
python-version: [3.11, 3.13]
14-
platform: [ubuntu-latest, macos-latest]
15-
runs-on: ${{ matrix.platform }}
13+
python-version: [3.11]
14+
platform:
15+
- { runner: ubuntu-latest, python_exec: ".venv/bin/python" }
16+
- { runner: ubuntu-24.04-arm, python_exec: ".venv/bin/python" }
17+
- { runner: macos-latest, python_exec: ".venv/bin/python" }
18+
- { runner: macos-13, python_exec: ".venv/bin/python" }
19+
- { runner: windows-latest, python_exec: ".venv\\Scripts\\python" }
20+
runs-on: ${{ matrix.platform.runner }}
1621
steps:
1722
- uses: actions/checkout@v4
1823

24+
- uses: actions/setup-python@v5
25+
id: setup_python
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
cache: 'pip'
29+
1930
- run: rustup toolchain install stable --profile minimal
2031
- name: Rust Cache
2132
uses: Swatinem/rust-cache@v2
2233
with:
23-
key: ${{ runner.os }}-rust-${{ matrix.python-version }}
24-
- name: Rust build
25-
run: cargo build --verbose
34+
key: rust-${{ matrix.platform.runner }}-${{ matrix.python-version }}
2635
- name: Rust tests
2736
run: cargo test --verbose
2837

29-
- uses: actions/setup-python@v5
30-
id: setup_python
31-
with:
32-
python-version: ${{ matrix.python-version }}
33-
cache: 'pip'
3438
- uses: actions/cache@v4
3539
with:
3640
path: .venv
37-
key: ${{ runner.os }}-pyenv-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
41+
key: pyenv-${{ matrix.platform.runner }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
3842
restore-keys: |
39-
${{ runner.os }}-pyenv-${{ steps.setup_python.outputs.python-version }}-
43+
pyenv-${{ matrix.platform.runner }}-${{ steps.setup_python.outputs.python-version }}-
44+
4045
- name: Setup venv
4146
run: |
4247
python -m venv .venv
4348
- name: Install Python toolchains
4449
run: |
45-
source .venv/bin/activate
46-
pip install maturin mypy pytest pytest-asyncio
50+
${{ matrix.platform.python_exec }} -m pip install maturin mypy pytest pytest-asyncio
4751
- name: Python build
4852
run: |
49-
source .venv/bin/activate
50-
maturin develop -E all
53+
${{ matrix.platform.python_exec }} -m maturin develop -E all
5154
- name: Python type check (mypy)
5255
run: |
53-
source .venv/bin/activate
54-
mypy python
56+
${{ matrix.platform.python_exec }} -m mypy python
5557
- name: Python tests
58+
if: ${{ !startsWith(matrix.platform.runner, 'windows') }}
59+
run: |
60+
${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests
61+
- name: Python tests (Windows cmd)
62+
if: ${{ startsWith(matrix.platform.runner, 'windows') }}
63+
shell: cmd # Use `cmd` to run test for Windows, as PowerShell doesn't detect exit code by `os._exit(0)` correctly.
5664
run: |
57-
source .venv/bin/activate
58-
pytest python/cocoindex/tests
65+
${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030
strategy:
3131
matrix:
3232
platform:
33-
- { os: linux, runner: ubuntu-24.04, target: x86_64, container: "ghcr.io/rust-cross/manylinux_2_28-cross:x86_64" }
34-
- { os: linux, runner: ubuntu-24.04, target: aarch64, container: "ghcr.io/rust-cross/manylinux_2_28-cross:aarch64" }
35-
- { os: windows, runner: windows-latest, target: x64 }
33+
- { os: linux, runner: ubuntu-latest, target: x86_64, container: "ghcr.io/rust-cross/manylinux_2_28-cross:x86_64" }
34+
- { os: linux, runner: ubuntu-24.04-arm, target: aarch64, container: "ghcr.io/rust-cross/manylinux_2_28-cross:aarch64" }
35+
- { os: macos, runner: macos-latest, target: aarch64 }
3636
- { os: macos, runner: macos-13, target: x86_64 }
37-
- { os: macos, runner: macos-14, target: aarch64 }
37+
- { os: windows, runner: windows-latest, target: x64 }
3838
steps:
3939
- uses: actions/checkout@v4
4040
- uses: actions/download-artifact@v4
@@ -47,7 +47,7 @@ jobs:
4747
uses: PyO3/maturin-action@v1
4848
with:
4949
target: ${{ matrix.platform.target }}
50-
args: --release --out dist --find-interpreter
50+
args: --release --out dist
5151
sccache: 'true'
5252
manylinux: auto
5353
container: ${{ matrix.platform.container }}

0 commit comments

Comments
 (0)