-
-
Notifications
You must be signed in to change notification settings - Fork 11
212 lines (206 loc) · 7.05 KB
/
rust.yml
File metadata and controls
212 lines (206 loc) · 7.05 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
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
CARGO_HOME: ${{ github.workspace }}/.cargo
RUSTFLAGS: -D warnings -A unused-imports
RUSTDOCFLAGS: -D warnings
RUST_BACKTRACE: full
LLVM_VERSION: "17"
jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable --no-self-update
- run: rustc -Vv
- run: cargo fmt --all -- --check
unit-tests:
name: ${{ matrix.basename }} - ${{ matrix.os }} - ${{ matrix.toolchain }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
book:
- false
coverage:
- false
experimental:
- false
clippy:
- false
rustdoc:
- false
tests:
- true
toolchain:
- stable
basename:
- Tests
os:
- ubuntu-latest
- macos-latest
- macos-15-intel
- windows-latest
include:
- toolchain: stable
os: ubuntu-latest
tests: false
clippy: false
experimental: true
basename: Coverage
coverage: true
book: false
- toolchain: stable
os: ubuntu-latest
tests: false
clippy: false
experimental: false
basename: Book
coverage: false
book: true
- toolchain: beta
os: ubuntu-latest
experimental: true
tests: true
basename: Tests
coverage: false
book: false
- toolchain: nightly
os: ubuntu-latest
tests: true
experimental: true
basename: Tests
coverage: false
book: false
- toolchain: stable
os: ubuntu-latest
tests: false
clippy: true
experimental: true
basename: Clippy
coverage: false
book: false
- toolchain: nightly
os: ubuntu-latest
tests: false
rustdoc: true
experimental: true
basename: Rustdoc
coverage: false
book: false
steps:
- uses: actions/checkout@v4
- name: Extract README code example
run: python3 ./.github/workflows/extract_readme_code.py
- uses: actions/cache@v4
with:
path: |
${{ env.CARGO_HOME }}
target
key: diffsol-${{ runner.os }}-${{ matrix.toolchain}}-coverage${{ matrix.coverage }}-book${{ matrix.book }}-llvm17
- name: Set up Rust
run: rustup default ${{ matrix.toolchain }} && rustup update ${{ matrix.toolchain }} --no-self-update && rustup component add clippy
- name: Rust version
run: rustc -Vv
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
if : (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.book == false
with:
version: ${{ env.LLVM_VERSION }}
- name: Install LLVM for macOS Intel (Homebrew)
if: matrix.os == 'macos-15-intel' && matrix.book == false
run: |
brew install llvm@${{ env.LLVM_VERSION }}
echo /usr/local/opt/llvm@${{ env.LLVM_VERSION }}/bin >> $GITHUB_PATH
- name: Set features variable and install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest' && matrix.book == false
run: |
echo "ADDITIONAL_FEATURES_FLAGS=--features diffsl-llvm17 --features diffsl-cranelift --features suitesparse" >> $GITHUB_ENV
sudo apt-get update
sudo apt-get install -y libsuitesparse-dev
- name: Install Trunk
uses: jetli/trunk-action@v0.4.0
if: matrix.book == true
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v2
if: matrix.book == true
with:
mdbook-version: 'latest'
- name: Install tarpaulin
if: matrix.coverage == true
run: cargo install cargo-tarpaulin
- name: Set features variable and install dependencies (macOS)
if: matrix.os == 'macos-15-intel' || matrix.os == 'macos-latest'
run: |
echo "ADDITIONAL_FEATURES_FLAGS=--features diffsl-llvm17 --features diffsl-cranelift" >> $GITHUB_ENV
- name: Set features variable and install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "ADDITIONAL_FEATURES_FLAGS=--features diffsl-cranelift" >> $GITHUB_ENV
- name: Free Disk Space (Ubuntu)
if: matrix.os == 'ubuntu-latest'
uses: jlumbroso/free-disk-space@main
with:
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
- name: Run tests - default features
if: matrix.tests == true
run: cargo test --verbose
- name: Run tests - all features (macOS Intel)
if: matrix.tests == true && matrix.os == 'macos-15-intel'
run: cargo test --verbose ${{ env.ADDITIONAL_FEATURES_FLAGS || '' }} --workspace --exclude neural-ode-weather-prediction
- name: Run tests - all features
if: matrix.tests == true && matrix.os != 'macos-15-intel'
run: cargo test --verbose ${{ env.ADDITIONAL_FEATURES_FLAGS || '' }} --workspace
- name: Clippy - all features
if: matrix.clippy == true
run: cargo clippy --verbose ${{ env.ADDITIONAL_FEATURES_FLAGS || ''}} --workspace
- name: Docs - all features
if: matrix.rustdoc == true
run: cargo rustdoc -p diffsol ${{ env.ADDITIONAL_FEATURES_FLAGS || ''}}
- name: Build book and wasm examples
if: matrix.book == true
run: |
mdbook build book
rustup target add wasm32-unknown-unknown
cd examples/population-dynamics-wasm-yew
mkdir -p ${{ github.workspace }}/book/book/examples/population-dynamics-wasm-yew
trunk build --release --public-url /diffsol/examples/population-dynamics-wasm-yew/ --dist ${{ github.workspace }}/book/book/examples/population-dynamics-wasm-yew
- name: Generate coverage report
if: matrix.coverage == true
run: cargo tarpaulin --out Xml --packages diffsol ${{ env.ADDITIONAL_FEATURES_FLAGS || '' }}
- name: Upload coverage
uses: codecov/codecov-action@v5
if: matrix.coverage == true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cobertura.xml
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
if: matrix.book == true
with:
path: "book/book/"
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4