-
Notifications
You must be signed in to change notification settings - Fork 1
521 lines (428 loc) · 19.4 KB
/
ubuntu-ci.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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# Copyright (C) 2022 Roberto Rossini (roberros@uio.no)
# SPDX-License-Identifier: MIT
name: Ubuntu CI
on:
push:
branches: [ main ]
paths:
- ".github/workflows/ubuntu-ci.yml"
- "cmake/**"
- "examples/**"
- "src/**"
- "test/**"
- "CMakeLists.txt"
- "conanfile.txt"
tags:
- 'v*.*.*'
pull_request:
paths:
- ".github/workflows/ubuntu-ci.yml"
- "cmake/**"
- "examples/**"
- "src/**"
- "test/**"
- "CMakeLists.txt"
- "conanfile.txt"
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
matrix-factory:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-result.outputs.result }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.after }}
- name: Detect CI type
id: ci-type
run: |
if git log --format=%B -n 1 ${{ github.event.after }} | grep -qF '[ci full]'; then
echo "type=full" >> $GITHUB_OUTPUT
else
echo "type=short" >> $GITHUB_OUTPUT
fi
- name: Generate matrix
uses: actions/github-script@v6
id: set-result
with:
script: |
// Documentation
// https://docs.github.com/en/actions/learn-github-actions/contexts#fromjson
// https://github.com/actions/runner/issues/982#issuecomment-809360765
var ci_short = "${{ steps.ci-type.outputs.type }}" === "short"
var includes = []
// Debug builds (short CI)
includes.push({ compiler: 'gcc-8', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'gcc-12', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'ON' })
includes.push({ compiler: 'clang-8', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-15', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'ON' })
// Release builds (short CI)
includes.push({ compiler: 'gcc-12', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
includes.push({ compiler: 'clang-15', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
if (ci_short) {
return { include: includes }
}
// Debug builds (long CI)
includes.push({ compiler: 'gcc-9', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'gcc-10', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'gcc-11', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'ON' })
includes.push({ compiler: 'clang-9', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-10', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-11', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-12', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-13', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'ON' })
includes.push({ compiler: 'clang-14', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Debug', developer_mode: 'ON' })
// Release builds (long CI)
includes.push({ compiler: 'gcc-8', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
includes.push({ compiler: 'gcc-9', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
includes.push({ compiler: 'gcc-10', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
includes.push({ compiler: 'gcc-11', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
includes.push({ compiler: 'clang-8', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-9', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-10', os: 'ubuntu-20.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-11', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
includes.push({ compiler: 'clang-12', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
includes.push({ compiler: 'clang-13', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
includes.push({ compiler: 'clang-14', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'ON' })
// Make sure project builds with CMake 3.25
includes.push({ compiler: 'clang-15', os: 'ubuntu-22.04', generator: 'Ninja', cmake: '3.25.2', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
// Make sure project builds with make
includes.push({ compiler: 'clang-15', os: 'ubuntu-22.04', generator: 'Unix Makefiles', cmake: '3.26.*', conan: '2.0.*', build_type: 'Release', developer_mode: 'OFF' })
return { include: includes }
cache-test-dataset:
uses: paulsengroup/hictk/.github/workflows/cache-test-dataset.yml@main
build-project:
needs: matrix-factory
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }}
container:
image: ghcr.io/paulsengroup/ci-docker-images/${{ matrix.os }}-cxx-${{ matrix.compiler }}:latest
options: "--user=root"
env:
CCACHE_DIR: "/opt/ccache-cache"
CCACHE_COMPILERCHECK: "content"
CCACHE_COMPRESSLEVEL: "1"
CCACHE_MAXSIZE: "350M"
CONAN_HOME: "/opt/conan/"
steps:
- uses: actions/checkout@v4
- name: Fix permissions
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Check build deps are up-to-date
id: build-deps-outdated
run: |
pattern='[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+$'
flag=false
if [[ $(cmake --version | grep -o "$pattern") != ${{ matrix.cmake }} ||
$(conan --version | grep -o "$pattern") != ${{ matrix.conan }} ]]; then
flag=true
fi
echo "outdated=$flag" >> $GITHUB_OUTPUT
- name: Update build deps
if: ${{ steps.buld-deps-outdated.outputs.outdated }}
run: |
apt-get update
apt-get install -y --no-install-recommends python3-pip
python3 -m pip install \
"cmake==${{ matrix.cmake }}" \
"conan==${{ matrix.conan }}"
- name: Generate cache keys
id: cache-key
run: |
set -u
os="${{ matrix.os }}"
compiler="${{ matrix.compiler }}"
generator="${{ matrix.generator }}"
build_type="${{ matrix.build_type }}"
dev_mode="${{ matrix.developer_mode }}"
conanfile_hash="${{ hashFiles('conanfile.txt') }}"
workflow_hash="${{ hashFiles('.github/workflows/ubuntu-ci.yml') }}"
combined_hash="${{ hashFiles('conanfile.txt', '.github/workflows/ubuntu-ci.yml') }}"
# This can be used by to always update a cache entry (useful e.g. for ccache)
current_date="$(date '+%s')"
conan_key_prefix="conan-$os-$compiler-$conanfile_hash-$build_type-$generator-$dev_mode"
ccache_key_prefix="ccache-$os-$compiler-$conanfile_hash-$build_type-$generator-$dev_mode"
echo "conan-key=$conan_key_prefix" | tee -a $GITHUB_OUTPUT
echo "conan-restore-key=$conan_key_prefix" | tee -a $GITHUB_OUTPUT
echo "ccache-key=${ccache_key_prefix}-${current_date}" | tee -a $GITHUB_OUTPUT
echo "ccache-restore-key=$ccache_key_prefix" | tee -a $GITHUB_OUTPUT
- name: Restore Conan cache
id: cache-conan
uses: actions/cache/restore@v3
with:
key: conan-${{ steps.cache-key.outputs.conan-restore-key }}
path: ${{ env.CONAN_HOME }}
- name: Clean Conan cache (pre-build)
if: steps.cache-conan.outputs.cache-hit != 'true'
run: |
conan cache clean "*" --build
conan cache clean "*" --download
conan cache clean "*" --source
conan remove --confirm "*"
- name: Install build dependencies
run: |
conan install . \
--build=missing \
-pr:b="$CONAN_DEFAULT_PROFILE_PATH" \
-pr:h="$CONAN_DEFAULT_PROFILE_PATH" \
-s build_type="${{ matrix.build_type }}" \
-s compiler.libcxx=libstdc++11 \
-s compiler.cppstd=17 \
--output-folder=build
- name: Clean Conan cache (post-build)
if: steps.cache-conan.outputs.cache-hit != 'true'
run: |
conan cache clean "*" --build
conan cache clean "*" --download
conan cache clean "*" --source
- name: Save Conan cache
uses: actions/cache/save@v3
if: steps.cache-conan.outputs.cache-hit != 'true'
with:
key: conan-${{ steps.cache-key.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}
- name: Cache Ccache folder
uses: actions/cache@v3
with:
key: ${{ steps.cache-key.outputs.ccache-key }}
restore-keys: ${{ steps.cache-key.outputs.ccache-restore-key }}
path: ${{ env.CCACHE_DIR }}
- name: Configure project
run: |
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_PREFIX_PATH="$PWD/build" \
-DENABLE_DEVELOPER_MODE=${{ matrix.developer_mode }} \
-DOPT_ENABLE_CLANG_TIDY=OFF \
-DOPT_ENABLE_CPPCHECK=OFF \
-DHICTK_ENABLE_TESTING=ON \
-DHICTK_BUILD_EXAMPLES=ON \
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-DCMAKE_INSTALL_PREFIX=dest \
-S . \
-B build
- name: Build project
run: cmake --build build -j $(nproc)
- name: Package binaries
run: |
cmake --install build
tar -cf - -C dest/ bin |
zstd -T0 -13 -o binaries.tar.zst
- name: Package unit tests
run: |
tar -cf - build/ | zstd -T0 -13 -o unit-tests.tar.zst
- name: Upload unit tests
uses: actions/upload-artifact@v3
with:
name: >
unit-tests-${{ matrix.os }}-
${{ matrix.compiler }}-
${{ matrix.generator }}-
${{ matrix.build_type }}-
${{ matrix.developer_mode }}
path: unit-tests.tar.zst
if-no-files-found: error
retention-days: 1
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: >
binaries-${{ matrix.os }}-
${{ matrix.compiler }}-
${{ matrix.generator }}-
${{ matrix.build_type }}-
${{ matrix.developer_mode }}
path: binaries.tar.zst
if-no-files-found: error
retention-days: 1
- name: Print Ccache statistics
run: ccache -s
run-unit-tests:
name: Run unit tests
needs: [ matrix-factory, cache-test-dataset, build-project ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }}
container:
image: ghcr.io/paulsengroup/ci-docker-images/modle/${{ matrix.os }}-cxx-${{ matrix.compiler }}:latest
options: "--user=root"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Fix permissions
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Restore test dataset
uses: actions/cache/restore@v3
with:
key: ${{ needs.cache-test-dataset.outputs.cache-key }}
path: test/data/hictk_test_data.tar.xz
fail-on-cache-miss: true
- name: Download unit tests artifact
uses: actions/download-artifact@v3
with:
name: >
unit-tests-${{ matrix.os }}-
${{ matrix.compiler }}-
${{ matrix.generator }}-
${{ matrix.build_type }}-
${{ matrix.developer_mode }}
- name: Extract binaries and test dataset
run: |
zstd -dcf unit-tests.tar.zst | tar -xf -
tar -xf test/data/hictk_test_data.tar.xz
- name: Run unit tests
run: |
ctest --test-dir build/ \
--schedule-random \
--output-on-failure \
--no-tests=error \
--timeout 200 \
-j $(nproc) |&
head -n 1000
run-integration-tests:
name: Run integration tests
needs: [ matrix-factory, cache-test-dataset, build-project ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }}
container:
image: ghcr.io/paulsengroup/ci-docker-images/modle/${{ matrix.os }}-cxx-${{ matrix.compiler }}:latest
options: "--user=root"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Fix permissions
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Install test dependencies
run: |
apt-get update
apt-get install -y --no-install-recommends default-jdk python3-pip xz-utils
python3 -m pip install 'cooler>=0.9.2'
- name: Cache hic_tools
id: cache-hictools
uses: actions/cache@v3
with:
key: hic_tools
path: hic_tools.jar
- name: Download hic_tools
if: steps.cache-hictools.outputs.cache-hit != 'true'
run: |
apt-get install -y --no-install-recommends curl
curl -L 'https://github.com/aidenlab/HiCTools/releases/download/v3.30.00/hic_tools.3.30.00.jar' \
-o hic_tools.jar
- name: Restore test dataset
uses: actions/cache/restore@v3
with:
key: ${{ needs.cache-test-dataset.outputs.cache-key }}
path: test/data/hictk_test_data.tar.xz
fail-on-cache-miss: true
- name: Download binaries artifact
uses: actions/download-artifact@v3
with:
name: >
binaries-${{ matrix.os }}-
${{ matrix.compiler }}-
${{ matrix.generator }}-
${{ matrix.build_type }}-
${{ matrix.developer_mode }}
- name: Extract binaries and test dataset
run: |
zstd -dcf binaries.tar.zst | tar -xf -
tar -xf test/data/hictk_test_data.tar.xz
- name: Test hictk balance
run: |
test/scripts/hictk_balance.sh bin/hictk hic_tools.jar
- name: Test hictk dump chroms
run: |
test/scripts/hictk_dump_chroms.sh bin/hictk
- name: Test hictk dump bins
run: |
test/scripts/hictk_dump_bins.sh bin/hictk
- name: Test hictk dump resolutions
run: |
test/scripts/hictk_dump_resolutions.sh bin/hictk
- name: Test hictk dump normalizations
run: |
test/scripts/hictk_dump_normalizations.sh bin/hictk
- name: Test hictk dump cells
run: |
test/scripts/hictk_dump_cells.sh bin/hictk
- name: Test hictk dump genome-wide
run: |
test/scripts/hictk_dump_gw.sh bin/hictk
- name: Test hictk dump cis
run: |
test/scripts/hictk_dump_cis.sh bin/hictk
- name: Test hictk dump trans
run: |
test/scripts/hictk_dump_trans.sh bin/hictk
- name: Test hictk dump balanced
run: |
test/scripts/hictk_dump_balanced.sh bin/hictk
- name: Test hictk convert (hic2cool)
run: |
test/scripts/hictk_convert_hic2cool.sh bin/hictk
- name: Test hictk convert (cool2hic)
run: |
test/scripts/hictk_convert_cool2hic.sh bin/hictk hic_tools.jar
- name: Test hictk load coo sorted
run: |
test/scripts/hictk_load_coo.sh bin/hictk sorted
- name: Test hictk load coo unsorted
run: |
test/scripts/hictk_load_coo.sh bin/hictk unsorted
- name: Test hictk load bg2 sorted
run: |
test/scripts/hictk_load_bg2.sh bin/hictk sorted
- name: Test hictk load bg2 unsorted
run: |
test/scripts/hictk_load_bg2.sh bin/hictk unsorted
- name: Test hictk load 4dn sorted
run: |
test/scripts/hictk_load_4dn.sh bin/hictk sorted
- name: Test hictk load 4dn unsorted
run: |
test/scripts/hictk_load_4dn.sh bin/hictk unsorted
- name: Test hictk merge
run: |
test/scripts/hictk_merge.sh bin/hictk
- name: Test hictk validate
run: |
test/scripts/hictk_validate.sh bin/hictk
- name: Test hictk zoomify
run: |
test/scripts/hictk_zoomify.sh bin/hictk
ubuntu-ci-status-check:
name: Status Check (Ubuntu CI)
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- matrix-factory
- cache-test-dataset
- build-project
- run-unit-tests
- run-integration-tests
steps:
- name: Collect job results
if: |
needs.matrix-factory.result != 'success' ||
needs.cache-test-dataset.result != 'success' ||
needs.build-project.result != 'success' ||
needs.run-unit-tests.result != 'success' ||
needs.run-integration-tests.result != 'success'
run: exit 1