-
Notifications
You must be signed in to change notification settings - Fork 17
404 lines (356 loc) · 13.6 KB
/
build.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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
name: Build and test
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
build:
strategy:
matrix:
name: [ubuntu-gcc-11-20.04,
ubuntu-gcc-11-22.04,
ubuntu-gcc-11,
ubuntu-gcc-12-debugoptimized,
ubuntu-gcc-13-DEBUG_MACHINE,
ubuntu-gcc-14-sanitize,
ubuntu-gcc-14,
ubuntu-clang-17,
macos-xcode-15-intel,
macos-xcode-16-arm,
windows
]
include:
- name: ubuntu-gcc-11-20.04
os: ubuntu-20.04
compiler: gcc
version: "11"
buildtype: "release"
arch: "linux64"
- name: ubuntu-gcc-11-22.04
os: ubuntu-22.04
compiler: gcc
version: "11"
buildtype: "release"
arch: "linux64"
- name: ubuntu-gcc-11
os: ubuntu-24.04
compiler: gcc
version: "11"
buildtype: "debugoptimized" # test WITH assertions
cxxflags: "-DNDEBUG_DP" # but WITHOUT realignment checking code
arch: "linux64"
- name: ubuntu-gcc-12-debugoptimized
os: ubuntu-24.04
compiler: gcc
version: "12"
buildtype: "debugoptimized"
arch: "linux64"
- name: ubuntu-gcc-13-DEBUG_MACHINE
os: ubuntu-24.04
compiler: gcc
version: "13"
buildtype: "debugoptimized"
cxxflags: "-DDEBUG_MACHINE=1"
arch: "linux64"
- name: ubuntu-gcc-14
os: ubuntu-24.04
compiler: gcc
version: "14"
buildtype: "release"
arch: "linux64"
- name: ubuntu-gcc-14-sanitize
os: ubuntu-24.04
compiler: gcc
version: "14"
buildtype: "release"
sanitize: "address"
arch: "linux64"
- name: ubuntu-clang-17
os: ubuntu-24.04
compiler: clang
version: "17"
buildtype: "release"
arch: "linux64"
- name: macos-xcode-15-intel
os: macos-13
compiler: xcode
version: "15"
buildtype: "release"
arch: "mac-intel64"
- name: macos-xcode-16-arm
os: macos-14
compiler: xcode
version: "16"
buildtype: "debugoptimized"
arch: "mac-arm64"
- name: windows
os: ubuntu-24.04
compiler: mingw
version: "N/A"
buildtype: "release"
arch: "win64"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
# Caches for different branches are isolated, so we don't need to put the branch name into the key.
# The total size for all caches in a repository is 5Gb.
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.name }}
restore-keys: |
${{ matrix.name }}
- name: Install (Linux)
if: runner.os == 'Linux' && matrix.name != 'windows'
run: |
sudo apt-get update
sudo apt-get install -y pandoc ccache
sudo apt-get install -y librange-v3-dev libeigen3-dev libcairo2-dev
sudo apt-get install -y r-base gnuplot
if [ "${{ matrix.compiler }}" = "gcc" ] ; then
echo "Installing g++-${{ matrix.version }}"
if [ ${{ matrix.os }} = ubuntu-20.04 ] ; then
# For newer GCCs:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
fi
echo sudo apt-get install -y g++-${{ matrix.version }}
sudo apt-get install -y g++-${{ matrix.version }}
g++-${{ matrix.version }} --version
echo "CC=ccache gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=ccache g++-${{ matrix.version }}" >> $GITHUB_ENV
else
echo "Installing clang-${{ matrix.version }}"
sudo apt-get install -y clang-${{ matrix.version }}
echo "CC=ccache clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=ccache clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi
sudo rm -rf /usr/local/share/boost
if [ ${{ matrix.os }} = ubuntu-24.04 ] ; then
# 24.04 has boost.json
sudo apt-get install -y libboost-all-dev
else
# 22.04 and earlier do not have boost.json
( cd
curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.tar.gz
tar -xzf boost_1_85_0.tar.gz
cd boost_1_85_0
./bootstrap.sh --with-libraries=atomic,chrono,filesystem,system,regex,thread,date_time,program_options,math,serialization,random,json --prefix=../installed-boost-1.85.0
./b2 install
echo -e "\n BOOST root is at $(cd ../installed-boost-1.85.0; pwd)\n"
echo BOOST_ROOT=$(cd ../installed-boost-1.85.0; pwd) >> $GITHUB_ENV
)
fi
- name: Install (Linux -> Windows [cross])
if: matrix.name == 'windows'
run: |
# For mingw/gcc-12.
cat /etc/apt/sources.list
sudo sed -i 's/jammy/lunar/g' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y pandoc ccache
sudo apt-get install -y dos2unix g++-mingw-w64 wine64 zstd
- name: Select XCode version (macOS)
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.version }}
- name: Install (macOS)
if: runner.os == 'macOS'
run: |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 # Don't try and install python3.12
brew install pandoc ccache coreutils
brew install eigen range-v3 cairo fmt
brew install gnuplot r
echo "CC=ccache clang" >> $GITHUB_ENV
echo "CXX=ccache clang++" >> $GITHUB_ENV
# brew install boost
# if [[ $(uname -m) == 'arm64' ]] ; then echo "BOOST_ROOT=/opt/homebrew" >> $GITHUB_ENV ; fi
# BOOST 1.86 is broken in homebrew
( cd
curl -O -L https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.tar.gz
tar -xzf boost_1_85_0.tar.gz
cd boost_1_85_0
./bootstrap.sh --with-libraries=atomic,chrono,filesystem,system,regex,thread,date_time,program_options,math,serialization,random,json --prefix=../installed-boost-1.85.0
./b2 install
echo -e "\n BOOST root is at $(cd ../installed-boost-1.85.0; pwd)\n"
echo BOOST_ROOT=$(cd ../installed-boost-1.85.0; pwd) >> $GITHUB_ENV
)
- name: Install meson
run: |
python3 -mpip install meson ninja
- name: Make windows sysroot and generate cross file
if: matrix.name == 'windows'
# This command also generates the cross file
run: |
${GITHUB_WORKSPACE}/scripts/make_winroot.sh
- name: Configure
env:
OSX_VERSION_MIN: "11.0"
run: |
if [ ${{ runner.os }} = "macOS" ] && [ -n "${OSX_VERSION_MIN}" ]; then
MIN="-mmacosx-version-min=${OSX_VERSION_MIN}"
export CFLAGS="$CFLAGS $MIN"
export CXXFLAGS="$CXXFLAGS $MIN"
export LDFLAGS="$LDFLAGS $MIN"
fi
CPPARGS="-g"
if [ "${{ matrix.cxxflags }}" != "" ] ; then
CPPARGS="$CPPARGS ${{ matrix.cxxflags }}"
fi
if [ "${{ matrix.arch }}" = "win64" ]; then
ARGS="${ARGS} --cross-file=win64-cross.txt"
fi
if [ "${{ runner.os }}" = "Linux" ] && [ "${{ matrix.name }}" != "windows" ] && [ "${{ matrix.sanitize }}" != "" ] ; then
# Address sanitizer can't find its dylibs on OS X?
ARGS="${ARGS} -Db_sanitize=${{ matrix.sanitize }}"
fi
echo meson setup build --prefix=$HOME/local --buildtype=${{ matrix.buildtype }} -Dcpp_args="$CPPARGS" ${ARGS}
meson setup build --prefix=$HOME/local --buildtype=${{ matrix.buildtype }} -Dcpp_args="$CPPARGS" ${ARGS}
- name: Upload meson log if configure failed
uses: actions/upload-artifact@v3
if: failure()
with:
name: meson-log-${{ matrix.name }}
path: ${{ github.workspace }}/build/meson-logs/meson-log.txt
- name: Copy shared libs (Windows)
if: matrix.arch == 'win64'
run: |
OUTPUT=$HOME/local
mkdir -p "${OUTPUT}/bin"
CXX=x86_64-w64-mingw32-g++-posix
# Copy compiler DLLS
for libname in gcc_s_seh-1 stdc++-6 ssp-0 winpthread-1 ; do
cp $($CXX --print-file-name lib${libname}.dll) ${OUTPUT}/bin
done
cp /home/runner/win_root/mingw64/bin/libboost_*.dll ${OUTPUT}/bin
- name: Build
run: |
ccache -p
ccache -s
ninja -C build install -j4
ccache -s
skip=none
case "${{ matrix.name }}" in
*-DEBUG_MACHINE) skip=some ;;
*-sanitize) skip=most ;;
esac
if [ "${skip}" = "none" ] ; then
if [ -n "${BOOST_ROOT}" ] ; then
if [ "${{ runner.os }}" == "macOS" ] ; then
export DYLD_LIBRARY_PATH="${BOOST_ROOT}/lib"
else
export LD_LIBRARY_PATH="${BOOST_ROOT}/lib"
fi
fi
if [ "${{ matrix.name }}" = "windows" ] ; then
export WINEPATH=$(winepath -w $HOME/local/bin)
fi
ninja -C build test
fi
- name: Get version
id: get_version
run: |
echo "version=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
- name: Copy shared libs (Linux)
if: matrix.arch == 'linux64'
run: |
OUTPUT=$HOME/local
cp $(${CXX} -print-file-name=libstdc++.so.6) $OUTPUT/lib/bali-phy/libstdc++.so.6
if [ -n "${BOOST_ROOT}" -a -e "${BOOST_ROOT}/lib" ] ; then
# copy boost shared libs if they exist
cp ${BOOST_ROOT}/lib/libboost*so* ${OUTPUT}/lib/bali-phy/
else
# apparently this only works for system libraries.
for libname in $(ldd ${OUTPUT}/bin/bali-phy | grep libboost | sed s'/\s*lib\(boost.*\) =>.*/\1/') ; do
echo cp $($CXX --print-file-name lib${libname}) ${OUTPUT}/lib/bali-phy/
cp $($CXX --print-file-name lib${libname}) ${OUTPUT}/lib/bali-phy/
done
fi
ldd ${OUTPUT}/bin/bali-phy
- name: Copy shared libs (Mac)
if: runner.os == 'macOS'
run: |
OUTPUT=$HOME/local
# copy boost shared libs if they exist
if [ -n "${BOOST_ROOT}" -a -e "${BOOST_ROOT}/lib" ] ; then
cp ${BOOST_ROOT}/lib/libboost*dylib* ${OUTPUT}/lib/bali-phy/
fi
- name: Ad hoc sign Mac executables
if: runner.os == 'macOS'
run: |
OUTPUT=$HOME/local
brew install findutils file-formula
for exe in $(gfind ${OUTPUT} -type f -executable -exec file --mime-type '{}' \; | grep x-mach-binary | sed 's/: application.*//') ; do
echo codesign -s - ${exe}
codesign -s - ${exe}
done
otool -L ${OUTPUT}/bin/bali-phy
# otool -l ${OUTPUT}/bin/bali-phy
- name: Test
run: |
export seed=$RANDOM
if [ "${{ matrix.name }}" = "windows" ] ; then
export WINEPATH=$(winepath -w $HOME/local/bin)
BALIPHY="wine bali-phy"
STATREPORT="wine statreport"
else
export PATH=$HOME/local/bin:$PATH
BALIPHY=bali-phy
STATREPORT=statreport
fi
echo "Running tests with seed=$seed"
echo ::group::Basic tests
${BALIPHY} help
cp $HOME/local/share/doc/bali-phy/examples/5S-rRNA/5d-muscle.fasta .
${BALIPHY} --seed=$seed 5d-muscle.fasta --test
${BALIPHY} --seed=$seed 5d-muscle.fasta --iter=50
${BALIPHY} --seed=$(($seed+1)) 5d-muscle.fasta --iter=50
${STATREPORT} 5d-muscle-1/C1.log
if [ "${{ matrix.name }}" != "windows" ] ; then
bp-analyze 5d-muscle-1 5d-muscle-2
fi
${BALIPHY} --seed=$seed -m tests/prob_prog/demos/airline/Model.hs --test -V4
# Skip the rest of the tests if this is a DEBUG_MACHINE test.
skip=none
case "${{ matrix.name }}" in
*-DEBUG_MACHINE) skip=some ;;
*-sanitize) skip=most ;;
esac
if [ "$skip" = "none" ] ; then
echo ::group::Test suite
cd tests
./run-tests.py ${BALIPHY} --seed=$seed
cd
echo ::endgroup::
else
echo ::group::Reduced test suite
( cd tests/prob_prog/demos ; ../../run-tests.py ${BALIPHY} --seed=$seed )
( cd tests/prob_prog/coal_mining ; ../../run-tests.py ${BALIPHY} --seed=$seed )
( cd tests/prob_prog/cluster ; ../../run-tests.py ${BALIPHY} --seed=$seed )
cd
echo ::endgroup::
fi
if [ "$skip" != "most" ] ; then
git clone https://gitlab.com/testiphy/testiphy.git
cd testiphy
rm -rf tests/likelihood/one-sequence
echo ::group::testiphy variable A
./testiphy ${BALIPHY} --seed=$seed
echo ::endgroup::
echo ::group::testiphy fixed A
./testiphy ${BALIPHY} --seed=$seed -Inone
echo ::endgroup::
fi
- name: Upload tests if they failed
uses: actions/upload-artifact@v3
if: failure()
with:
name: tests-${{ matrix.name }}
path: tests