forked from metatensor/metatensor
-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (190 loc) · 7.19 KB
/
Copy pathrust-tests.yml
File metadata and controls
223 lines (190 loc) · 7.19 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Rust tests
on:
push:
branches: [main]
pull_request:
# Check all PR
concurrency:
group: rust-tests-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
rust-tests:
name: ${{ matrix.os }} / Rust ${{ matrix.rust-version }}${{ matrix.extra-name }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
defaults:
run:
shell: "bash"
env:
CMAKE_CXX_COMPILER: ${{ matrix.cxx }}
CMAKE_C_COMPILER: ${{ matrix.cc }}
CMAKE_GENERATOR: ${{ matrix.cmake-generator }}
strategy:
matrix:
include:
# test without any feature (i.e shared build)
- os: ubuntu-24.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
extra-name: ", no features"
cxx: g++
cc: gcc
cmake-generator: Unix Makefiles
# test with all features (i.e static build + rayon + bench)
- os: ubuntu-24.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
cargo-build-flags: --release --all-features
do-valgrind: true
extra-name: ", all features, release"
cxx: g++
cc: gcc
cmake-generator: Unix Makefiles
# check the build on a stock Ubuntu 22.04, which uses cmake 3.22, and
# with our minimal supported rust version
- os: ubuntu-24.04
rust-version: 1.74
container: ubuntu:22.04
rust-target: x86_64-unknown-linux-gnu
cargo-build-flags: --features=rayon
extra-name: ", cmake 3.22"
cxx: g++
cc: gcc
cmake-generator: Unix Makefiles
- os: macos-15
rust-version: stable
rust-target: aarch64-apple-darwin
cargo-build-flags: --features=rayon
extra-name: ""
cxx: clang++
cc: clang
cmake-generator: Unix Makefiles
- os: windows-2022
rust-version: stable
rust-target: x86_64-pc-windows-msvc
cargo-build-flags: --features=rayon
extra-name: " / MSVC"
cxx: cl.exe
cc: cl.exe
cmake-generator: Visual Studio 17 2022
- os: windows-2022
rust-version: stable
rust-target: x86_64-pc-windows-gnu
cargo-build-flags: --features=rayon
extra-name: " / MinGW"
cxx: g++.exe
cc: gcc.exe
cmake-generator: MinGW Makefiles
steps:
- name: install dependencies in container
if: matrix.container == 'ubuntu:22.04'
run: |
apt update
apt install -y software-properties-common
apt install -y cmake make gcc g++ git curl
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure git safe directory
if: matrix.container == 'ubuntu:22.04'
run: git config --global --add safe.directory /__w/metatensor/metatensor
- name: setup rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
target: ${{ matrix.rust-target }}
- name: Cache Rust dependencies
uses: Leafwing-Studios/cargo-cache@v2.6.1
with:
sweep-cache: true
- name: install valgrind
if: matrix.do-valgrind
run: |
sudo apt-get install -y valgrind
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
with:
version: "v0.10.0"
- name: Setup sccache environnement variables
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
- name: run tests
run: |
cargo test --package metatensor --package metatensor-core --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
- name: check the code can be compiled as a standalone crate
if: matrix.os != 'windows-2022'
run: |
./scripts/package-core.sh rust/metatensor-sys/
cd rust/metatensor-sys
cargo package --target ${{ matrix.rust-target }} --allow-dirty
# check that the C API declarations are correctly used by Rust and Python
prevent-bitrot:
runs-on: ubuntu-24.04
name: check C API declarations
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"
enable-cache: true
activate-environment: true
- name: setup rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
components: rustfmt
- name: Cache Rust dependencies
uses: Leafwing-Studios/cargo-cache@v2.6.1
with:
sweep-cache: true
- name: install python dependencies
run: |
uv pip install pycparser
- name: install bindgen conditionally
run: |
if ! cargo install --list | grep "bindgen-cli v0.72.1"; then
echo "Installing bindgen-cli v0.72.1 from git to use Cargo.lock"
git clone --depth 1 --branch v0.72.1 https://github.com/rust-lang/rust-bindgen
# Install from the local git clone using its Cargo.lock file
# This pins an older 'toml' version compatible with Rust 1.74.1
cargo install --path rust-bindgen/bindgen-cli --locked --force
rm -rf rust-bindgen
fi
- name: check that Rust/Python/Julia C API declarations are up to date
run: |
./scripts/update-declarations.sh
git diff --exit-code
- name: check that C API functions are all documented
run: |
python scripts/check-c-api-docs.py
# make sure no debug print stays in the code
check-debug-prints:
runs-on: ubuntu-24.04
name: check leftover debug print
steps:
- uses: actions/checkout@v6
- name: install ripgrep
run: |
wget https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz
tar xf ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz
echo "$(pwd)/ripgrep-13.0.0-x86_64-unknown-linux-musl" >> $GITHUB_PATH
- name: check for leftover dbg!
run: |
# use ripgrep (rg) to check for instances of `dbg!` in rust files.
# rg will return 1 if it fails to find a match, so we invert it again
# with the `!` builtin to get the error/success in CI
! rg "dbg!" --type=rust --quiet
- name: check for leftover \#include <iostream>
run: |
! rg "<iostream>" --iglob "\!metatensor-core/tests/cpp/external/catch/catch.hpp" --quiet
- name: check for leftover std::cout
run: |
! rg "cout" --iglob "\!metatensor-core/tests/cpp/external/catch/catch.hpp" --quiet
- name: check for leftover std::cerr
run: |
! rg "cerr" --iglob "\!metatensor-core/tests/cpp/external/catch/catch.hpp" --quiet