-
Notifications
You must be signed in to change notification settings - Fork 186
566 lines (473 loc) · 20 KB
/
ci_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
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
name: Verovio CI Build
on:
push:
# Trigger the workflow on push,
# but only for the branches specified
branches:
# Push events on develop branch
- 'develop'
# Push events on ci-test branch (uncomment if needed for testing purposes)
# - ci-test
paths-ignore:
- "**.md" # ignore changes to markdown files
# globals
env:
# general settings
MAIN_REPO_OWNER:
rism-digital # Main repo owner (default: rism-digital; should not be changed)
# If changed, owner needs deploy permission to <owner>/verovio.org and <owner>/verovio-doxygen (cf. Deploy jobs).
# DISABLE_DEPLOY_STEPS & IS_DRY_RUN are programmatically set to false for main repo owner.
DISABLE_DEPLOY_STEPS:
true # Flag used to disable deploy steps at all (default: true).
# TRUE (no matter what IS_DRY_RUN): Will skip deploy steps of the workflow.
# FALSE (together with IS_DRY_RUN = true): Will allow to run deploy steps in dry-run mode.
# FALSE (together with IS_DRY_RUN = false): Will allow to deploy/git push from fork.
# Will be programmatically set to 'false' for rism-digital repo.
IS_DRY_RUN:
true # Flag used for dry-run mode in 'git push' command (default: true).
# TRUE (needs DISABLE_DEPLOY_STEPS = false): Will allow to run deploy steps in dry-run mode.
# FALSE (needs DISABLE_DEPLOY_STEPS = false): Will allow to deploy/git push from fork.
# Will be programmatically set to 'false' for rism-digital repo.
# build artifacts
DOC_BUILD: doc-build
TOOLKIT_BUILD: toolkit-build
# doxygen
DOXYGEN_REPO: ${{ github.repository_owner }}/verovio-doxygen # works from rism-digital and from forks
DOXYGEN_BRANCH: develop
# emscripten
EM_VERSION: latest
EM_CACHE_FOLDER: "emsdk-cache"
EM_CACHE_ID: 3
# gh-pages
GH_PAGES_REPO: ${{ github.repository_owner }}/verovio.org # works from rism-digital and from forks
GH_PAGES_BRANCH: gh-pages
# temporary directories
DOXYGEN_DIR: doxygen-dir
GH_PAGES_DIR: gh-pages-dir
TEMP_DIR: temp-dir
jobs:
###############################################################################################
# Build c++ code on different os in parallel. #
# Adapted from https://github.com/DaanDeMeyer/reproc/blob/master/.github/workflows/main.yml . #
###############################################################################################
build_cpp:
# skip job if commit message contains "[skip-ci]"
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
name: Build ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.version }}
# This job runs on all the os specified in strategy.matrix.os
runs-on: ${{ matrix.os }}
# set matrix with config options
# (runs the following steps for every target in parallel)
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
compiler: g++
version: "10"
- os: ubuntu-22.04
compiler: g++
version: "11"
- os: ubuntu-22.04
compiler: g++
version: "12"
- os: ubuntu-20.04
compiler: clang
version: "10"
- os: ubuntu-20.04
compiler: clang
version: "11"
- os: ubuntu-20.04
compiler: clang
version: "12"
- os: macos-latest
compiler: xcode
version: "14.3"
- os: macos-latest
compiler: xcode
version: "15.3"
- os: macos-11
compiler: g++
version: "12"
steps:
- name: Checkout main repo
uses: actions/checkout@v4
# Installation step for Ubuntu
- name: Configure Ubuntu with ${{ matrix.compiler }}-${{ matrix.version }}
if: runner.os == 'Linux'
run: |
# check if compiler is available from runner by default
if dpkg -l | grep ${{ matrix.compiler }}-${{ matrix.version }}; then
echo "${{ matrix.compiler }}-${{ matrix.version }} available from runner..."
else
# if not, install compiler
sudo apt-get update -q
sudo apt-get install -y -q --no-install-recommends ${{ matrix.compiler }}-${{ matrix.version }}
fi
# set environment variables
if [ "${{ matrix.compiler }}" == "g++" ]; then
echo CC=gcc-${{ matrix.version }} >> $GITHUB_ENV
echo CXX=g++-${{ matrix.version }} >> $GITHUB_ENV
else
echo CC=clang-${{ matrix.version }} >> $GITHUB_ENV
echo CXX=clang++-${{ matrix.version }} >> $GITHUB_ENV
fi
# Installation step for MacOS
- name: Configure macOS with ${{ matrix.compiler }}-${{ matrix.version }}
if: runner.os == 'macOS'
run: |
if [ "${{ matrix.compiler }}" == "g++" ]; then
# set environment variables (use alias gcc)
echo CC=gcc-${{ matrix.version }} >> $GITHUB_ENV
echo CXX=g++-${{ matrix.version }} >> $GITHUB_ENV
else
TARGET_XCODE="/Applications/Xcode_${{ matrix.version }}.app/Contents/Developer"
# check XCode version
if [ $(xcode-select --print-path | grep Xcode) == $TARGET_XCODE ] ; then
echo "XCode ${{ matrix.version }} already set..."
else
# switch XCode version
# cf. https://github.com/actions/virtual-environments/issues/257#issuecomment-573562956
echo "Found active $(xcodebuild -version | grep Xcode). Switching to XCode ${{ matrix.version }}..."
sudo xcode-select -s $TARGET_XCODE
fi
# set environment variables from XCode
echo CC=$(xcrun --find clang) >> $GITHUB_ENV
echo CXX=$(xcrun --find clang++) >> $GITHUB_ENV
fi
- name: Check settings and dry-run make
working-directory: ${{ github.workspace }}/tools
run: |
echo "CC: ${CC}"
echo "CXX: ${CXX}"
cmake --version
cmake -S ../cmake -B debug -DCMAKE_BUILD_TYPE=Debug
- name: Run make
working-directory: ${{ github.workspace }}/tools
run: |
cmake ../cmake
make -j8
#####################################
# Set up and cache emscripten build #
#####################################
setup_emscripten:
# skip job if commit message contains "[skip-ci]"
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
name: Set up and cache emscripten
runs-on: ubuntu-20.04
steps:
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
# path for cache
path: ${{ env.EM_CACHE_FOLDER }}
# key for cache
key: ${{ runner.os }}-emsdk-${{ env.EM_VERSION }}-${{ env.EM_CACHE_ID }}
- name: Set up emsdk
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ env.EM_VERSION }}
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}
- name: Verify emscripten build
run: emcc -v
##################################
# Build the JS toolkit artifacts #
##################################
build_js:
name: Build JS toolkit
runs-on: ubuntu-20.04
needs: [setup_emscripten]
# set matrix with toolkit options (runs the following steps for every target in parallel)
strategy:
matrix:
toolkit:
- target: nohumdrum
message: "Building toolkit without humdrum"
options: "-c -H -M"
filepath: "verovio-toolkit.js*"
- target: light
message: "Building toolkit without humdrum as light version"
options: "-c -H -l -M"
filepath: "verovio-toolkit-light.js*"
- target: wasm
message: "Building toolkit without humdrum as wasm"
options: "-c -H -w -M"
filepath: "verovio*wasm*"
upload: true
- target: default
message: "Building default toolkit with humdrum"
options: "-c -M"
filepath: "*-hum.js*"
steps:
- name: Checkout main repo
uses: actions/checkout@v4
- name: Create TEMP_DIR
working-directory: ${{ github.workspace }}
run: mkdir -p $TEMP_DIR/
# Restore system libraries from cache
- name: Restore cache
id: restore_cache
uses: actions/cache@v3
with:
# path for cache
path: ${{ env.EM_CACHE_FOLDER }}
# key for cache
key: ${{ runner.os }}-emsdk-${{ env.EM_VERSION }}-${{ env.EM_CACHE_ID }}
# Install and/or activate emsdk
- name: Set up emsdk
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ env.EM_VERSION }}
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}
- name: Verify emscripten build
run: emcc -v
- name: ${{ matrix.toolkit.message }} (${{ matrix.toolkit.options }})
working-directory: ${{ github.workspace }}/emscripten
run: ./buildToolkit ${{ matrix.toolkit.options }}
- name: Copy build into TEMP_DIR
if: ${{ matrix.toolkit.upload == true }}
working-directory: ${{ github.workspace }}/emscripten
run: cp build/${{ matrix.toolkit.filepath }} $GITHUB_WORKSPACE/$TEMP_DIR/
- name: Upload js build artifact (${{ matrix.toolkit.target }})
if: ${{ matrix.toolkit.upload == true }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.TOOLKIT_BUILD }}
path: ${{ github.workspace }}/${{ env.TEMP_DIR }}/${{ matrix.toolkit.filepath }}
############################
# Copy the font CSS files #
############################
copy_font_files:
name: Copy the font files
runs-on: ubuntu-20.04
steps:
- name: Checkout main repo
uses: actions/checkout@v4
- name: Create TEMP_DIR
working-directory: ${{ github.workspace }}
run: mkdir -p $TEMP_DIR/data
- name: Copy build into TEMP_DIR
run: cp data/*.css $GITHUB_WORKSPACE/$TEMP_DIR/data/
- name: Upload font data artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.TOOLKIT_BUILD }}
path: ${{ github.workspace }}/${{ env.TEMP_DIR }}
##################################
# Check settings for deployment #
##################################
check_deploy_settings:
name: Check settings for deployment
runs-on: ubuntu-20.04
# run deployment only after finishing the build jobs
needs: [build_cpp, build_js]
# Github Environment Variables persist only on job level.
# To transfer values to later jobs, outputs mechanism has to be used.
# Cf. https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
# So global envs are reset here as outputs.
outputs:
_DISABLE_DEPLOY_STEPS: ${{ steps.settings.outputs.disable }}
_IS_DRY_RUN: ${{ steps.settings.outputs.dry-run }}
steps:
- name: Enable deploy steps for main repo owner
if: ${{ github.repository_owner == env.MAIN_REPO_OWNER }}
run: echo "DISABLE_DEPLOY_STEPS=false" >> $GITHUB_ENV
- name: Disable dry-run mode for main repo owner
if: ${{ github.repository_owner == env.MAIN_REPO_OWNER }}
run: echo "IS_DRY_RUN=false" >> $GITHUB_ENV
- name: Check deployment settings and set them as outputs
id: settings
run: |
echo "DISABLE_DEPLOY_STEPS = ${DISABLE_DEPLOY_STEPS}"
echo "IS_DRY_RUN = ${IS_DRY_RUN}"
echo "::set-output name=disable::${DISABLE_DEPLOY_STEPS}"
echo "::set-output name=dry-run::${IS_DRY_RUN}"
#########################################
# Deploy the toolkit builds to gh-pages #
#########################################
deploy_toolkit:
name: Deploy JS toolkit
runs-on: ubuntu-20.04
if: ${{ needs.check_deploy_settings.outputs._DISABLE_DEPLOY_STEPS == 'false' }}
# run deployment only after finishing the build jobs
needs: [build_cpp, build_js, check_deploy_settings]
steps:
- name: Checkout GH_PAGES_REPO into GH_PAGES_DIR
uses: actions/checkout@v4
with:
# repository to check out
repository: ${{ env.GH_PAGES_REPO }}
# Deploy key as secret for accessing <owner>/<GH_PAGES_REPO>;
# cf. explanation in https://github.com/rism-digital/verovio/pull/1751
ssh-key: ${{ secrets.GH_ACTIONS_DEPLOY_KEY }}
# ref (branch, tag or SHA) to check out
ref: ${{ env.GH_PAGES_BRANCH }}
# relative path under $GITHUB_WORKSPACE to place the repository
path: ${{ env.GH_PAGES_DIR }}
- name: Download TOOLKIT_BUILD artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.TOOLKIT_BUILD }}
path: artifacts/${{ env.TOOLKIT_BUILD }}
- name: Copy artifacts to gh-pages
run: |
cp -r artifacts/$TOOLKIT_BUILD/* $GH_PAGES_DIR/javascript/develop/
- name: Check git status before commit
working-directory: ${{ env.GH_PAGES_DIR }}
run: |
git config --get remote.origin.url
git status
- name: Configure git
working-directory: ${{ env.GH_PAGES_DIR }}
run: |
echo "Configuring git"
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Commit files
working-directory: ${{ env.GH_PAGES_DIR }}
run: |
echo "Running git commit"
git add .
git commit -m "Auto-commit of toolkit build for ${{ github.repository }}@${{ github.sha }}"
# - name: Check git status after commit
# working-directory: ${{ env.DOXYGEN_DIR }}
# run: |
# git config --get remote.origin.url
# git status
- name: Push changes to gh-pages (dry-run mode)
if: ${{ needs.check_deploy_settings.outputs._IS_DRY_RUN == 'true' }}
working-directory: ${{ env.GH_PAGES_DIR }}
run: git push -v --dry-run origin HEAD:$GH_PAGES_BRANCH
- name: Push changes to gh-pages
if: ${{ needs.check_deploy_settings.outputs._IS_DRY_RUN != 'true' }}
working-directory: ${{ env.GH_PAGES_DIR }}
run: git push origin HEAD:$GH_PAGES_BRANCH
- name: Congratulations
if: ${{ success() && needs.check_deploy_settings.outputs._IS_DRY_RUN != 'true' }}
run: echo "🎉 New JS toolkit builds deployed 🎊"
- name: Skipped
# skip deployment when deploy steps are disabled or when we are in dry-run mode
if: ${{ needs.check_deploy_settings.outputs._IS_DRY_RUN == 'true' }}
run: |
echo "Deploy job skipped due to deployment settings..."
echo "DISABLE_DEPLOY_STEPS = ${DISABLE_DEPLOY_STEPS}"
echo "IS_DRY_RUN = ${IS_DRY_RUN}"
###################################
# Build the doxygen documentation #
###################################
build_docs:
name: Build documentation
runs-on: ubuntu-20.04
# run only after finishing other build jobs
needs: [build_cpp, build_js]
steps:
- name: Checkout main repo
uses: actions/checkout@v4
- name: Install doxygen
run: |
sudo apt-get update -q
sudo apt-get install -y -q --no-install-recommends doxygen
- name: Check installation
run: doxygen --help
- name: Upgrade doxygen conf
working-directory: ${{ github.workspace }}/doc
run: doxygen -u verovio.conf
- name: Build documentation with (updated) doxygen conf
working-directory: ${{ github.workspace }}/doc
if: ${{ success() }}
run: (cat verovio.conf ; echo "OUTPUT_DIRECTORY = $GITHUB_WORKSPACE/$DOXYGEN_DIR") | doxygen -
- name: Upload doxygen build artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.DOC_BUILD }}
path: ${{ github.workspace }}/${{ env.DOXYGEN_DIR }}
###############################################
# Deploy the documentation to verovio-doxygen #
###############################################
deploy_docs:
name: Deploy documentation
runs-on: ubuntu-20.04
if: ${{ needs.check_deploy_settings.outputs._DISABLE_DEPLOY_STEPS == 'false' }}
# run deployment only after finishing the build job
needs: [build_docs, check_deploy_settings]
steps:
- name: Checkout DOXYGEN_REPO into DOXYGEN_DIR
uses: actions/checkout@v4
with:
# repository to check out
repository: ${{ env.DOXYGEN_REPO }}
# Deploy key as secret for accessing <owner>/<DOXYGEN_REPO>;
# cf. explanation in https://github.com/rism-digital/verovio/pull/1751
ssh-key: ${{ secrets.GH_ACTIONS_DEPLOY_KEY_DOXYGEN }}
# ref (branch, tag or SHA) to check out
ref: ${{ env.DOXYGEN_BRANCH }}
# relative path under $GITHUB_WORKSPACE to place the repository
path: ${{ env.DOXYGEN_DIR }}
- name: Download DOC_BUILD artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.DOC_BUILD }}
path: artifacts/${{ env.DOC_BUILD }}
- name: Remove old doc and copy build artifacts to DOXYGEN_DIR
run: |
rm -rf $DOXYGEN_DIR/html/*
rm -rf $DOXYGEN_DIR/xml/*
cp -a artifacts/$DOC_BUILD/* $DOXYGEN_DIR/
- name: Check git status before commit
working-directory: ${{ env.DOXYGEN_DIR }}
run: |
git config --get remote.origin.url
git status
- name: Configure git
working-directory: ${{ env.DOXYGEN_DIR }}
run: |
echo "Configuring git..."
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Commit files
working-directory: ${{ env.DOXYGEN_DIR }}
run: |
echo "Running git commit..."
git add .
git commit -m "Auto-commit of documentation build for ${{ github.repository }}@${{ github.sha }}"
# - name: Check git status after commit
# working-directory: ${{ env.DOXYGEN_DIR }}
# run: |
# git config --get remote.origin.url
# git status
- name: Push changes to doxygen (dry-run mode)
if: ${{ needs.check_deploy_settings.outputs._IS_DRY_RUN == 'true' }}
working-directory: ${{ env.DOXYGEN_DIR }}
run: git push -v --dry-run origin HEAD:$DOXYGEN_BRANCH
- name: Push changes to doxygen
if: ${{ needs.check_deploy_settings.outputs._IS_DRY_RUN != 'true' }}
working-directory: ${{ env.DOXYGEN_DIR }}
run: git push origin HEAD:$DOXYGEN_BRANCH
- name: Congratulations
if: ${{ success() && needs.check_deploy_settings.outputs._IS_DRY_RUN != 'true' }}
run: echo "🎉 New documentation deployed 🎊"
- name: Skipped
# skip deployment when deploy steps are disabled or when we are in dry-run mode
if: ${{ needs.check_deploy_settings.outputs._IS_DRY_RUN == 'true' }}
run: |
echo "Deploy job skipped due to deployment settings..."
echo "DISABLE_DEPLOY_STEPS = ${DISABLE_DEPLOY_STEPS}"
echo "IS_DRY_RUN = ${IS_DRY_RUN}"
###############################################
# Skip deployment steps according to settings #
###############################################
skip_deploy:
name: Skip deployment if set
runs-on: ubuntu-20.04
# always() is needed here to meet if-condition even if earlier steps failed
# cf. https://github.com/actions/runner/issues/491
if: ${{ always() && needs.check_deploy_settings.outputs._DISABLE_DEPLOY_STEPS == 'true' }}
needs: [check_deploy_settings, deploy_toolkit, deploy_docs]
steps:
- name: Skipped
# skip deployment when deploy steps are disabled or when we are in dry-run mode
run: |
echo "Deploy job skipped due to deployment settings..."
echo "DISABLE_DEPLOY_STEPS (env) = ${DISABLE_DEPLOY_STEPS}"
echo "IS_DRY_RUN (env) = ${IS_DRY_RUN}"