-
Notifications
You must be signed in to change notification settings - Fork 19
180 lines (151 loc) · 5.91 KB
/
rust-test.yml
File metadata and controls
180 lines (151 loc) · 5.91 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Rust Backend Tests
on:
push:
branches: [main]
paths:
- 'rust/**'
- 'diff_diff/**'
- 'tests/**'
- 'pyproject.toml'
- '.github/workflows/rust-test.yml'
pull_request:
branches: [main]
paths:
- 'rust/**'
- 'diff_diff/**'
- 'tests/**'
- 'pyproject.toml'
- '.github/workflows/rust-test.yml'
env:
CARGO_TERM_COLOR: always
jobs:
# Run Rust unit tests on all platforms
rust-tests:
name: Rust Unit Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install OpenBLAS (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libopenblas-dev
- name: Run Rust tests
working-directory: rust
run: |
if [ "${{ runner.os }}" == "macOS" ]; then
cargo test --verbose --features accelerate
elif [ "${{ runner.os }}" == "Linux" ]; then
cargo test --verbose --features openblas
else
cargo test --verbose
fi
shell: bash
# Build and test with Python on multiple platforms
python-tests:
name: Python Tests (${{ matrix.os }}, py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm]
python-version: ['3.11', '3.13']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install test dependencies
# Keep in sync with pyproject.toml [project.dependencies] and [project.optional-dependencies.dev]
run: pip install pytest pytest-xdist numpy pandas scipy
- name: Install OpenBLAS (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libopenblas-dev
- name: Build and install with maturin
run: |
pip install maturin
if [ "${{ runner.os }}" == "macOS" ]; then
maturin build --release -o dist --features extension-module,accelerate
elif [ "${{ runner.os }}" == "Linux" ]; then
maturin build --release -o dist --features extension-module,openblas
else
maturin build --release -o dist
fi
echo "=== Built wheels ==="
ls -la dist/ || dir dist
shell: bash
- name: Install wheel (Unix)
if: runner.os != 'Windows'
run: pip install --no-index --find-links=dist diff-diff
- name: Install wheel (Windows)
if: runner.os == 'Windows'
run: |
$wheel = Get-ChildItem dist/*.whl | Select-Object -First 1
pip install $wheel.FullName
shell: pwsh
- name: Verify Rust backend is available (Unix)
if: runner.os != 'Windows'
working-directory: /tmp
run: |
python -c "import diff_diff; print('Location:', diff_diff.__file__)"
python -c "from diff_diff import HAS_RUST_BACKEND; print('HAS_RUST_BACKEND:', HAS_RUST_BACKEND); assert HAS_RUST_BACKEND, 'Rust backend not available'"
- name: Verify Rust backend is available (Windows)
if: runner.os == 'Windows'
working-directory: ${{ runner.temp }}
run: |
python -c "import diff_diff; print('Location:', diff_diff.__file__)"
python -c "from diff_diff import HAS_RUST_BACKEND; print('HAS_RUST_BACKEND:', HAS_RUST_BACKEND); assert HAS_RUST_BACKEND, 'Rust backend not available'"
- name: Copy tests to isolated location (Unix)
if: runner.os != 'Windows'
run: cp -r tests /tmp/tests
- name: Copy tests to isolated location (Windows)
if: runner.os == 'Windows'
run: Copy-Item -Recurse tests $env:RUNNER_TEMP\tests
shell: pwsh
- name: Run Rust backend tests (Unix)
if: runner.os != 'Windows'
working-directory: /tmp
run: pytest tests/test_rust_backend.py -v -m ''
- name: Run Rust backend tests (Windows)
if: runner.os == 'Windows'
working-directory: ${{ runner.temp }}
run: pytest tests/test_rust_backend.py -v -m ''
- name: Run tests with Rust backend (Unix)
if: runner.os != 'Windows'
working-directory: /tmp
run: DIFF_DIFF_BACKEND=rust pytest tests/ -q -n auto --dist worksteal -m ''
- name: Run tests with Rust backend (Windows)
if: runner.os == 'Windows'
working-directory: ${{ runner.temp }}
run: |
$env:DIFF_DIFF_BACKEND="rust"
pytest tests/ -q -n auto --dist worksteal -m ''
shell: pwsh
# Test pure Python fallback (without Rust extension)
python-fallback:
name: Pure Python Fallback
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
# Keep in sync with pyproject.toml [project.dependencies] and [project.optional-dependencies.dev]
run: pip install numpy pandas scipy pytest pytest-xdist
- name: Verify pure Python mode
run: |
# Use PYTHONPATH to import directly (skips maturin build)
PYTHONPATH=. python -c "from diff_diff import HAS_RUST_BACKEND; print(f'HAS_RUST_BACKEND: {HAS_RUST_BACKEND}'); assert not HAS_RUST_BACKEND"
- name: Run tests in pure Python mode
run: PYTHONPATH=. DIFF_DIFF_BACKEND=python pytest tests/ -q --ignore=tests/test_rust_backend.py -n auto --dist worksteal