Skip to content

Commit dc190d5

Browse files
authored
build(workflow): add tests to CI workflow (#401)
* build(workflow): add tests to CI workflow * fix: the way to call sub workflow * fix: switch to `maturin develop` * fix: use venv as required by `maturin` * chore: update cache key for venv * fix: install python dependencies in venv * style: simplify command to run pytest
1 parent 18c8bae commit dc190d5

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ on:
1212
- src/**
1313
- python/**
1414
- "*.toml"
15-
- ".github/workflows/CI.yml"
15+
- ".github/workflows/*.yml"
1616
push:
1717
branches: [main]
1818
paths:
1919
- src/**
2020
- python/**
2121
- "*.toml"
22-
- ".github/workflows/CI.yml"
22+
- ".github/workflows/*.yml"
2323
workflow_dispatch:
2424

2525
permissions:
@@ -46,3 +46,6 @@ jobs:
4646
sccache: 'true'
4747
manylinux: auto
4848
container: ${{ matrix.platform.container }}
49+
test:
50+
name: Run test
51+
uses: ./.github/workflows/_test.yml

.github/workflows/_test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
rust:
11+
strategy:
12+
matrix:
13+
python-version: [3.11, 3.13]
14+
platform: [ubuntu-latest, macos-latest]
15+
runs-on: ${{ matrix.platform }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- run: rustup toolchain install stable --profile minimal
20+
- name: Rust Cache
21+
uses: Swatinem/[email protected]
22+
- name: Rust build
23+
run: cargo build --verbose
24+
- name: Rust tests
25+
run: cargo test --verbose
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
cache: 'pip'
31+
- uses: actions/cache@v4
32+
with:
33+
path: .venv
34+
key: ${{ runner.os }}-pythonenv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
35+
restore-keys: |
36+
${{ runner.os }}-pythonenv-${{ matrix.python-version }}-
37+
- name: Python build & test
38+
run: |
39+
python -m venv .venv
40+
source .venv/bin/activate
41+
pip install maturin pytest
42+
maturin develop
43+
pytest python/cocoindex/tests

0 commit comments

Comments
 (0)