-
Notifications
You must be signed in to change notification settings - Fork 6
201 lines (170 loc) · 5.89 KB
/
test.yaml
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: test
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
rust-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install latest stable Rust
uses: dtolnay/rust-toolchain@stable
id: install-rust
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
target
.cargo_home
.cargo
key: ${{ runner.os }}-no_pybindings-rust-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-no_pybindings-rust-${{ steps.install-rust.outputs.cachekey }}-
- name: Check rust formatting
run: cargo fmt -- --check
- name: Lint with clippy
env:
RUSTFLAGS: "-D warnings"
run: cargo clippy --all-targets --all-features
# The environment variable `RUSTFLAGS` doesn't actually seem to have any effect on rustdoc,
# but we set it here to the same value as in all other cargo runs as changing it would
# cause unnecessary recompilation of some dependencies.
- name: Check for broken doc links
env:
RUSTFLAGS: "-D warnings"
run: cargo rustdoc -- -D rustdoc::broken-intra-doc-links
- name: Test in development mode
env:
RUSTFLAGS: "-D warnings"
run: cargo test --all-targets
- name: Test in release mode
env:
RUSTFLAGS: "-D warnings"
run: cargo test --release --all-targets
miri-test:
name: no_std and miri
runs-on: ${{ matrix.os }}
needs: rust-test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Find out latest rust nightly version that has miri
id: rust-version
shell: bash
run: |
case ${{ matrix.os }} in
ubuntu-latest)
arch="x86_64-unknown-linux-gnu"
;;
macos-latest)
arch="x86_64-apple-darwin"
;;
windows-latest)
arch="x86_64-pc-windows-msvc"
;;
esac
version="nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/$arch/miri)"
echo "Found version: $version"
echo "rustc=$version" >> $GITHUB_OUTPUT
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
target
.cargo_home
.cargo
key: ${{ runner.os }}-no_pybindings-miri-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-no_pybindings-miri-${{ steps.install-rust.outputs.cachekey }}-
- name: Install rust ${{ steps.rust-version.outputs.rustc }}
uses: dtolnay/rust-toolchain@master
id: install-rust
with:
toolchain: ${{ steps.rust-version.outputs.rustc }}
components: miri, rust-src
- name: Test `no_std` compatibility
shell: bash
working-directory: ensure_no_std
run: cargo +${{ steps.rust-version.outputs.rustc }} build
- name: Run tests in miri
env:
RUSTFLAGS: "-Zrandomize-layout"
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation"
run: cargo +${{ steps.rust-version.outputs.rustc }} miri test --no-fail-fast --all-targets
python-test:
runs-on: ${{ matrix.os }}
needs: rust-test
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install --no-root
- name: Install latest stable Rust
uses: dtolnay/rust-toolchain@stable
id: install-rust
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
target
.cargo_home
.cargo
key: ${{ runner.os }}-pybindings-rust-${{ steps.install-rust.outputs.cachekey }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-pybindings-rust-${{ steps.install-rust.outputs.cachekey }}-
- name: Build Python package
run: poetry run maturin develop --release --features pybindings
- name: pytest
shell: bash
run: |
poetry run pytest tests/python | tee pytest.out
exit ${PIPESTATUS[0]}
- name: Verify that pytest used correct python version
shell: bash
run: |
USED_PYTHON_VERSION=$(grep -A1 -iE '^=+ test session starts =+$' pytest.out | perl -ne 'if ($_ =~ / -- Python (\d+\.\d+)\.\d+/i) { print "$1"; }')
echo "Expected python version: ${{ matrix.python-version }}"
echo "Found python version: $USED_PYTHON_VERSION"
if [ "x${{ matrix.python-version }}y" == "x${USED_PYTHON_VERSION}y" ]; then
echo "Versions match."
else
echo "ERROR: versions don't match."
exit 1
fi
testall:
runs-on: ubuntu-latest
name: Meta job for all tests
needs: [rust-test, miri-test, python-test]
steps:
- name: Done
run: echo "All tests successful."