Skip to content

Commit e991881

Browse files
committed
refactor: avoid duplicating workflow step
1 parent 196d536 commit e991881

File tree

1 file changed

+15
-33
lines changed

1 file changed

+15
-33
lines changed

.github/workflows/_test.yml

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ jobs:
1111
strategy:
1212
matrix:
1313
python-version: [3.11]
14-
runner: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13, windows-latest]
15-
runs-on: ${{ matrix.runner }}
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

@@ -26,7 +31,7 @@ jobs:
2631
- name: Rust Cache
2732
uses: Swatinem/rust-cache@v2
2833
with:
29-
key: rust-${{ matrix.runner }}-${{ matrix.python-version }}
34+
key: rust-${{ matrix.platform.runner }}-${{ matrix.python-version }}
3035
- name: Rust build
3136
run: cargo build --verbose
3237
- name: Rust tests
@@ -35,45 +40,22 @@ jobs:
3540
- uses: actions/cache@v4
3641
with:
3742
path: .venv
38-
key: pyenv-${{ matrix.runner }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
43+
key: pyenv-${{ matrix.platform.runner }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
3944
restore-keys: |
40-
pyenv-${{ matrix.runner }}-${{ steps.setup_python.outputs.python-version }}-
45+
pyenv-${{ matrix.platform.runner }}-${{ steps.setup_python.outputs.python-version }}-
46+
4147
- name: Setup venv
4248
run: |
4349
python -m venv .venv
44-
4550
- name: Install Python toolchains
46-
if: runner.os != 'Windows'
47-
run: |
48-
.venv/bin/python -m pip install maturin mypy pytest pytest-asyncio
49-
- name: Install Python toolchains (Windows)
50-
if: runner.os == 'Windows'
5151
run: |
52-
.venv\Scripts\python -m pip install maturin mypy pytest pytest-asyncio
53-
52+
${{ matrix.platform.python_exec }} -m pip install maturin mypy pytest pytest-asyncio
5453
- name: Python build
55-
if: runner.os != 'Windows'
56-
run: |
57-
.venv/bin/python -m maturin develop -E all
58-
- name: Python build (Windows)
59-
if: runner.os == 'Windows'
6054
run: |
61-
.venv\Scripts\python -m maturin develop -E all
62-
55+
${{ matrix.platform.python_exec }} -m maturin develop -E all
6356
- name: Python type check (mypy)
64-
if: runner.os != 'Windows'
65-
run: |
66-
.venv/bin/python -m mypy python
67-
- name: Python type check (mypy) (Windows)
68-
if: runner.os == 'Windows'
6957
run: |
70-
.venv\Scripts\python -m mypy python
71-
58+
${{ matrix.platform.python_exec }} -m mypy python
7259
- name: Python tests
73-
if: runner.os != 'Windows'
74-
run: |
75-
.venv/bin/python -m pytest python/cocoindex/tests
76-
- name: Python tests (Windows)
77-
if: runner.os == 'Windows'
7860
run: |
79-
.venv\Scripts\python -m pytest python/cocoindex/tests
61+
${{ matrix.platform.python_exec }} -m pytest python/cocoindex/tests

0 commit comments

Comments
 (0)