-
Notifications
You must be signed in to change notification settings - Fork 12
302 lines (261 loc) · 8.72 KB
/
main.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: bridgestan tests
on:
push:
branches:
- "main"
pull_request:
workflow_dispatch: {}
env:
CACHE_VERSION: 1
# only run one copy per PR
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
- name: Stan build caching
uses: actions/cache@v4
id: stan-cache
with:
path: ./stan/
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }}
- name: Set up PATH for C example
if: matrix.os == 'windows-latest'
run: |
Add-Content $env:GITHUB_PATH "$(pwd)/stan/lib/stan_math/lib/tbb"
Add-Content $env:GITHUB_PATH "$(pwd)/test_models/full"
- name: Build C example (Windows)
if: matrix.os == 'windows-latest'
run: |
cd c-example/
make -j4 example.exe example_runtime.exe
rm ../src/bridgestan.o
echo "Dynamically linked example"
./example.exe
echo "Runtime loading example"
./example_runtime.exe ../test_models/full/full_model.so
- name: Build C example (Unix)
if: matrix.os != 'windows-latest'
run: |
cd c-example/
make -j4 example example_static example_runtime
rm ../src/bridgestan.o ../test_models/full/*.a
echo "Dynamically linked example"
./example
echo "Statically linked example"
./example_static
echo "Runtime loading example"
./example_runtime ../test_models/full/full_model.so
shell: bash
# we use the cache here to build the Stan models once for multiple interfaces
- name: Set up test model cache
uses: actions/cache@v4
id: test-models
with:
path: ./test_models/
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }}
- name: Build test models
if: steps.test-models.outputs.cache-hit != 'true'
run: |
make STAN_THREADS=true O=0 test_models -j4
python:
needs: [build]
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.12"]
fail-fast: false
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Restore Stan
uses: actions/cache@v4
id: stan-cache
with:
path: ./stan/
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }}
- name: Restore built models
uses: actions/cache@v4
id: test-models
with:
path: ./test_models/
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }}
- name: Install package
run: |
cd python/
pip install pytest
pip install .
- name: Test import
run: |
python -c "import bridgestan"
- name: Run tests
run: |
pytest -v python/
cd python/
python example.py
env:
BRIDGESTAN: ${{ github.workspace }}
- name: Run tests (Unix-specific)
if: matrix.os != 'windows-latest'
run: |
pytest -v python/ --run-type=ad_hessian
env:
BRIDGESTAN: ${{ github.workspace }}
julia:
needs: [build]
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
julia-version: ["1"]
include:
- julia-version: "1.6"
os: ubuntu-latest
fail-fast: false
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Julia
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: Restore Stan
uses: actions/cache@v4
id: stan-cache
with:
path: ./stan/
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }}
- name: Restore built models
uses: actions/cache@v4
id: test-models
with:
path: ./test_models/
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }}
- name: Check import
run: |
cd julia/
julia --project=. -e "using Pkg; Pkg.instantiate()"
julia --project=. -e "using BridgeStan"
- name: Run tests
run: |
cd julia/
julia --project=. -t 2 -e "using Pkg; Pkg.test()"
julia --project=. example.jl
env:
BRIDGESTAN: ${{ github.workspace }}
Rlang:
needs: [build]
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install R
uses: r-lib/actions/setup-r@v2.10.1
- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2.10.1
with:
packages: |
any::R6
any::testthat
any::devtools
- name: Restore Stan
uses: actions/cache@v4
with:
path: ./stan/
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }}
- name: Restore built models
uses: actions/cache@v4
id: test-models
with:
path: ./test_models/
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }}
- name: Run tests
if: matrix.os != 'windows-latest'
run: |
cd R/tests/testthat
gcc -fpic -shared -o test_collisions.so test_collisions.c
cd ../..
Rscript -e "devtools::test(reporter = c(\"summary\", \"fail\"))"
Rscript -e "install.packages(getwd(), repos=NULL, type=\"source\")"
Rscript example.R
env:
BRIDGESTAN: ${{ github.workspace }}
- name: Run tests (windows)
if: matrix.os == 'windows-latest'
run: |
cd R/tests/testthat
gcc -fpic -shared -o test_collisions.dll test_collisions.c
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE}
cd ../..
Rscript -e 'devtools::test(reporter = c("summary", "fail"))'
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE}
Rscript -e 'install.packages(getwd(), repos=NULL, type="source")'
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE}
Rscript example.R
if (!$LASTEXITCODE.Equals(0)) {exit $LASTEXITCODE}
env:
BRIDGESTAN: ${{ github.workspace }}
rust:
needs: [build]
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore Stan
uses: actions/cache@v4
with:
path: ./stan/
key: ${{ runner.os }}-stan-${{ hashFiles('stan/src/stan/version.hpp') }}-v${{ env.CACHE_VERSION }}
- name: Restore built models
uses: actions/cache@v4
id: test-models
with:
path: ./test_models/
key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }}
- name: Set up TBB
if: matrix.os == 'windows-latest'
run: |
Add-Content $env:GITHUB_PATH "$(pwd)/stan/lib/stan_math/lib/tbb"
- name: Run rust tests
working-directory: ./rust
timeout-minutes: 60
run: |
cargo clippy
cargo fmt --check
cargo run --example=example
# run all tests with feature download-bridgestan-src
cargo test --verbose --all-features
cargo test --verbose model_compiling -- --ignored