-
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (64 loc) · 2.35 KB
/
tests.yml
File metadata and controls
74 lines (64 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Run tests
on:
push:
branches:
- "main"
- "dev"
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
with:
# Initialize Ruff submodule
submodules: recursive
# First check Rust tests
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Run Rust tests
shell: bash
run: |
# Build cargo test command with -p flags for each package
# We do so because the ruff submodule also contains crates and those will
# run if we don't limit the tests to only our packages.
# And `cargo test` command doesn't allow to exclude crates based on patterns.
#
# 1. Get all directories in our `crates/` folder
packages=$(find crates -maxdepth 1 -mindepth 1 -type d | \
sed 's/crates\///' | \
tr '\n' ' ')
echo "Running tests for packages: $packages"
# 2. Format as `cargo test -p <package> -p <package> ...`
cargo test $(echo "$packages" | sed 's/\([^ ]*\)/-p \1/g')
# After Rust tests pass, run Python tests next
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install Python dependencies
run: |
# NOTE: maturin requires a virtual environment to be active
python -m venv .venv
${{ runner.os == 'Windows' && '.venv\Scripts\activate' || 'source .venv/bin/activate' }}
python -m pip install --upgrade pip
python -m pip install -r requirements-ci.txt
- name: Build Python package
run: |
${{ runner.os == 'Windows' && '.venv\Scripts\activate' || 'source .venv/bin/activate' }}
maturin develop
- name: Run Python tests
run: |
${{ runner.os == 'Windows' && '.venv\Scripts\activate' || 'source .venv/bin/activate' }}
pytest