-
Notifications
You must be signed in to change notification settings - Fork 13
186 lines (156 loc) · 6.08 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
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:
tests:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / rust ${{ matrix.rust-version }} ${{ matrix.extra-name }}
container: ${{ matrix.container }}
defaults:
run:
working-directory: ${{ matrix.working-directory }}
strategy:
matrix:
include:
- os: ubuntu-22.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
build-type: debug
test-static-lib: true
extra-name: / static C library
working-directory: /home/runner/work/rascaline/rascaline/
- os: ubuntu-22.04
rust-version: stable
rust-target: x86_64-unknown-linux-gnu
build-type: release
cargo-build-flags: --release
do-valgrind: true
extra-name: / release valgrind
working-directory: /home/runner/work/rascaline/rascaline/
# check the build on a stock Ubuntu 20.04, including cmake 3.16
- os: ubuntu-22.04
rust-version: "1.74"
container: ubuntu:20.04
rust-target: x86_64-unknown-linux-gnu
build-type: debug
extra-name: / cmake 3.16
working-directory: /__w/rascaline/rascaline
- os: macos-14
rust-version: stable
rust-target: aarch64-apple-darwin
build-type: debug
working-directory: /Users/runner/work/rascaline/rascaline/
- os: windows-2019
rust-version: stable
rust-target: x86_64-pc-windows-msvc
build-type: debug
working-directory: C:\\rascaline
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 python3-pip python3-venv
ln -s /usr/bin/python3 /usr/bin/python
working-directory: /
- name: free disk space
if: matrix.os == 'ubuntu-22.04'
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android || true
- uses: actions/checkout@v4
- name: "copy the code to C: drive"
if: matrix.os == 'windows-2019'
run: cp -r ${{ github.workspace }} ${{ matrix.working-directory }}
working-directory: /
- name: setup Python
uses: actions/setup-python@v5
if: "!matrix.container"
with:
python-version: "3.12"
- 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.5.4"
- 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: unit tests
run: cargo test --lib --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
- name: documentation tests
run: cargo test --doc --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
- name: integration tests
env:
RASCALINE_TEST_WITH_STATIC_LIB: ${{ matrix.test-static-lib || 0 }}
run: |
cargo test --test "*" --package rascaline --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
cargo test --test "*" --package rascaline-c-api --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }}
# second set of jobs checking that (non-test) code still compiles/run as expected
prevent-bitrot:
runs-on: ubuntu-22.04
name: check examples / benchmarks
steps:
- uses: actions/checkout@v4
- name: setup rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Setup sccache
uses: mozilla-actions/[email protected]
with:
version: "v0.5.4"
- 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: check that examples compile & run
run: cargo run --release --example compute-soap -- rascaline/examples/data/water.xyz
- name: check that benchmarks compile and run once
run: cargo bench -- --test
# third set of jobs checking containing basic rust linting
lint-rust:
runs-on: ubuntu-22.04
name: Lint Rust code
strategy:
matrix:
include:
- rust-version: stable
rust-target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- name: setup rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
target: ${{ matrix.rust-target }}
- name: install dependencies
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