forked from metatensor/metatensor
-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (174 loc) · 6.45 KB
/
rust-tests.yml
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
name: Rust tests
on:
push:
branches: [master]
pull_request:
# Check all PR
concurrency:
group: rust-tests-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
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-20.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 + ndarray)
- os: ubuntu-20.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
cargo-test-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 20.04, which uses cmake 3.16, and
# with our minimal supported rust version
- os: ubuntu-20.04
rust-version: 1.65
container: ubuntu:20.04
rust-target: x86_64-unknown-linux-gnu
cargo-build-flags: --features=rayon
extra-name: ", cmake 3.16"
cxx: g++
cc: gcc
cmake-generator: Unix Makefiles
- os: macos-14
rust-version: stable
rust-target: aarch64-apple-darwin
cargo-test-flags: --features=rayon
extra-name: ""
cxx: clang++
cc: clang
cmake-generator: Unix Makefiles
- os: windows-2019
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 16 2019
- os: windows-2019
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:20.04'
run: |
apt update
apt install -y software-properties-common
apt install -y cmake make gcc g++ git curl
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git safe directory
if: matrix.container == 'ubuntu:20.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: install valgrind
if: matrix.do-valgrind
run: |
sudo apt-get update
sudo apt-get install -y valgrind
- name: Setup sccache
uses: mozilla-actions/[email protected]
with:
version: "v0.8.1"
- 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-2019'
run: |
./scripts/package-core.sh rust/metatensor-sys/
cd rust/metatensor-sys
cargo package --allow-dirty
# check that the C API declarations are correctly used by Rust and Python
prevent-bitrot:
runs-on: ubuntu-20.04
name: check C API declarations
steps:
- uses: actions/checkout@v4
- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: setup rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
- name: install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pycparser
- name: install bindgen
run: |
cargo install bindgen-cli --version ^0.69
- 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-20.04
name: check leftover debug print
steps:
- uses: actions/checkout@v4
- 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