-
-
Notifications
You must be signed in to change notification settings - Fork 2
688 lines (628 loc) · 27.3 KB
/
Copy pathcmake.yml
File metadata and controls
688 lines (628 loc) · 27.3 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
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
name: CMake Build Matrix
on:
push:
branches: [master,main]
tags:
- v*
pull_request:
branches: [master,main]
types: [opened, synchronize, closed]
env:
# CMAKE_VERSION: 3.29
# NINJA_VERSION: 1.11.1
# CCACHE_VERSION: 3.7.7
# BUILD_TYPE: Release
CI_RUNNING: 1
VCPKG_TARGET_TRIPLET: x64-windows
# # Conan cache environment variables
# CONAN_SYSREQUIRES_MODE: enabled
# CONAN_USER_HOME: "${{ github.workspace }}/conan-cache"
# CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-cache/short"
# # CLANG_TIDY_VERSION: "14.0.0"
CLANG_TIDY_VERSION: "19.1.1"
VERBOSE: 1
jobs:
build:
permissions:
contents: write
discussions: write
security-events: write
name: ${{ matrix.config.name }} ${{ matrix.config.build_type == 'Release' && 'rel' || 'dbg' }} ${{ matrix.config.package_generator }} ${{ matrix.config.build_shared }}
# runs-on: ${{ matrix.config.os }}
# name: ${{matrix.os}} ${{matrix.compiler}} ${{matrix.build_type}} ${{matrix.packaging_maintainer_mode == 'ON' && '(maintainer mode)' || ''}}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
# - {
# name: "Windows Latest MSVC", artifact: ".zip",
# os: windows-latest,
# compiler: msvc,
# gcov_executable: gcov-14,
# enable_ipo: OFF,
# build_type: Release,
# generator: "Visual Studio 17 2022",
# packaging_maintainer_mode: OFF,
# package_generator: ZIP,
# build_shared: OFF,
# cc: "cl", cxx: "cl",
# environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
# tcf: "-D CMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake"
# # https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/windows/Windows2022-Readme.md
# }
- {
name: "Ubuntu Latest GCC", artifact: ".deb",
os: ubuntu-latest,
compiler: gcc-14,
gcov_executable: OpenCppCoverage.exe,
enable_ipo: On,
build_type: Release,
generator: "Ninja Multi-Config", # generator: "Unix Makefiles"
packaging_maintainer_mode: ON,
package_generator: DEB,
build_shared: OFF,
cc: "gcc-14", cxx: "g++-14" # for 22.04, gcc-10, 11, 12 are valid.
# cc: "gcc-13", cxx: "g++-13"
# cc: "gcc-14", cxx: "g++-14"
# https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/ubuntu/Ubuntu2204-Readme.md
# https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/ubuntu/Ubuntu2404-Readme.md
}
- {
name: "Ubuntu Latest LLVM", artifact: ".tbz2",
os: ubuntu-latest,
compiler: llvm-19.1.1,
gcov_executable: "llvm-cov gcov",
enable_ipo: On,
build_type: Debug,
generator: "Ninja Multi-Config",
packaging_maintainer_mode: ON,
package_generator: TBZ2,
build_shared: OFF,
cc: "clang", cxx: "clang++"
}
# - {
# name: "macOS Latest Arm64", artifact: ".dmg",
# os: macos-latest,
# compiler: clang,
# gcov_executable: gcov-14,
# enable_ipo: On,
# build_type: release,
# generator: "Ninja Multi-Config",
# packaging_maintainer_mode: ON,
# package_generator: DragNDrop, # for DMG: "DragNDrop", for PKG: "Bundle"
# build_shared: OFF,
# cc: "clang", cxx: "clang++"
# # https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/macos/macos-14-arm64-Readme.md
# # https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20240827.4
# }
# # - {
# # name: "macOS Latest Arm64", artifact: "macOS.7z",
# # os: macos-latest,
# # compiler: llvm-19.1.1,
# # cc: "clang", cxx: "clang++"
# # }
# # macOS Latest Intel not support in free plan
# # - {
# # name: "macOS Latest Intel", artifact: "macOS-intel.7z",
# # os: macos-latest-large,
# # cc: "clang", cxx: "clang++"
# #
# # # https://github.com/actions/runner-images
# # }
# os:
# # - windows-2022
# # - ubuntu-20.04
# # - ubuntu-24.04
# - ubuntu-latest
# - macos-latest
# - windows-latest
# # - macos-14 # arm64
# # - macos-13 # intel
# compiler:
# # - llvm-14.0.0
# # - gcc-11
# # # - llvm
# # # - gcc
# # # you can specify the version after `-` like `llvm-18`.
# - llvm-19.1.1
# - gcc-14
# generator:
# - "Ninja Multi-Config"
# build_type:
# - Release
# - Debug
# # developer_mode:
# # - ON
# # - OFF
# packaging_maintainer_mode:
# - ON
# - OFF
# build_shared:
# - OFF
# exclude:
# # mingw is determined by this author to be too buggy to support
# - os: "windows-2022"
# compiler: gcc-11
# # mingw is determined by this author to be too buggy to support
# - os: windows-latest
# compiler: gcc-14
# - os: windows-latest
# compiler: llvm-19.1.1
# # - os: windows-latest
# # developer_mode: ON
# - os: windows-latest
# build_type: Debug
# - os: windows-latest
# compiler: gcc-11
# - os: windows-latest
# compiler: gcc-14
# - os: macos-latest
# compiler: gcc-11
# - os: macos-latest
# compiler: gcc-14
# - os: macos-latest
# compiler: llvm-19.1.1
# - os: macos-latest
# build_type: Debug
# - os: macos-13
# compiler: gcc-11
# - os: macos-13
# compiler: gcc-14
# - os: macos-13
# compiler: llvm-19.1.1
# - os: macos-13
# build_type: Debug
# - os: macos-14
# compiler: gcc-11
# - os: macos-14
# compiler: gcc-14
# - os: macos-14
# compiler: llvm-19.1.1
# - os: macos-14
# build_type: Debug
# - os: macos-10.15
# compiler: gcc-11
# - os: macos-10.15
# compiler: gcc-14
# - os: macos-10.15
# compiler: llvm-19.1.1
# - os: macos-10.15
# build_type: Debug
# - os: ubuntu-latest
# compiler: llvm-19.1.1
# # - os: ubuntu-latest
# # developer_mode: ON
# # - os: ubuntu-latest
# # build_type: Debug
# include:
# # # Add appropriate variables for gcov version required. This will intentionally break
# # # if you try to use a compiler that does not have gcov set
# # - compiler: gcc-11
# # gcov_executable: gcov
# - compiler: gcc-14
# gcov_executable: gcov-14
# enable_ipo: On
# # - compiler: llvm-14.0.0
# # gcov_executable: "llvm-cov gcov"
# - compiler: llvm-19.1.1
# enable_ipo: Off
# gcov_executable: "llvm-cov gcov"
# - os: macos-latest
# enable_ipo: Off
# # Set up preferred package generators, for given build configurations
# - build_type: Release
# packaging_maintainer_mode: On
# # developer_mode: OFF
# package_generator: TBZ2
# # - os: macOS-14
# # build_type: Release
# # developer_mode: OFF
# # package_generator: DMG
# # - os: macOS-13
# # build_type: Release
# # developer_mode: OFF
# # package_generator: DMG
# - os: ubuntu-latest
# build_type: Release
# developer_mode: OFF
# package_generator: DEB
# # Windows msvc builds
# - os: windows-latest
# compiler: msvc
# generator: "Visual Studio 17 2022"
# build_type: Debug
# packaging_maintainer_mode: On
# enable_ipo: On
# # - os: windows-latest
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Release
# # packaging_maintainer_mode: On
# # enable_ipo: On
# # - os: windows-latest
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Debug
# # packaging_maintainer_mode: Off
# - os: windows-latest
# compiler: msvc
# generator: "Visual Studio 17 2022"
# build_type: Release
# packaging_maintainer_mode: Off
# package_generator: ZIP
# # - os: windows-latest
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Release
# # packaging_maintainer_mode: On
# # enable_ipo: On
# # build_shared: On
# # - os: windows-2022
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Release
# # developer_mode: OFF
# # package_generator: ZIP
# # - os: windows-2022
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Debug
# # developer_mode: On
# # - os: windows-2022
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Release
# # developer_mode: On
# # - os: windows-2022
# # compiler: msvc
# # generator: "Visual Studio 17 2022"
# # build_type: Debug
# # developer_mode: Off
# # # This exists solely to make sure a non-multiconfig build works
# # - os: ubuntu-latest
# # compiler: gcc-14
# # generator: "Unix Makefiles"
# # build_type: Debug
# # gcov_executable: gcov-14
# # packaging_maintainer_mode: On
# # enable_ipo: Off
# #
# # # ubuntu-20.04 runner could get stuck on github ...
# # # # This exists solely to make sure a non-multiconfig build works
# # # - os: ubuntu-20.04
# # # compiler: gcc-11
# # # generator: "Unix Makefiles"
# # # build_type: Debug
# # # gcov_executable: gcov
# # # developer_mode: On
# config:
# - {
# name: "Windows Latest MSVC", artifact: "Windows-MSVC.7z",
# os: windows-latest,
# cc: "cl", cxx: "cl",
# environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
# tcf: "-D CMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake"
#
# # https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/windows/Windows2022-Readme.md
# }
# #- {
# # name: "Windows Latest MinGW", artifact: "Windows-MinGW.7z",
# # os: windows-latest,
# # cc: "gcc", cxx: "g++"
# #}
# - {
# name: "Ubuntu Latest GCC", artifact: "Linux.7z",
# os: ubuntu-latest,
# cc: "gcc-12", cxx: "g++-12" # for 22.04, gcc-10, 11, 12 are valid.
# # cc: "gcc-13", cxx: "g++-13"
# # cc: "gcc-14", cxx: "g++-14"
#
# # https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/ubuntu/Ubuntu2204-Readme.md
# # https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/ubuntu/Ubuntu2404-Readme.md
# }
# - {
# name: "macOS Latest Arm64", artifact: "macOS.7z",
# os: macos-latest,
# cc: "clang", cxx: "clang++"
#
# # https://github.com/actions/runner-images/blob/macos-14-arm64/20240827.4/images/macos/macos-14-arm64-Readme.md
# # https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20240827.4
# }
# # macOS Latest Intel not support in free plan
# # - {
# # name: "macOS Latest Intel", artifact: "macOS-intel.7z",
# # os: macos-latest-large,
# # cc: "clang", cxx: "clang++"
# #
# # # https://github.com/actions/runner-images
# # }
steps:
- name: Check for llvm version mismatches
if: ${{ contains(matrix.config.compiler, 'llvm') && !contains(matrix.config.compiler, env.CLANG_TIDY_VERSION) }}
uses: actions/github-script@v8
with:
script: |
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')
# https://github.com/actions/checkout
- uses: actions/checkout@v5
with:
submodules: 'recursive'
# fetch-depth: 0
# ref: my-branch
# - name: Install dependencies
# if: matrix.os == 'ubuntu-latest'
# # if: runner.os == 'Linux' # Linux, Windows, macOS
# run: |
# sudo apt-get update # ensure indexes are up-to-date
# sudo apt-get install -y libboost-dev
- name: Project Name
uses: cardinalby/export-env-action@v2
with:
envFile: '.github/constants.env'
- name: Set VERSION variable from tag
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
VERSION="${{ github.event.release.tag_name }}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "PROJECT: $PROJECT_NAME"
echo "VERSION: $VERSION"
echo "RELEASE TAGNAME: ${{ github.event.release.tag_name }}"
- name: Set VERSION variable from tag
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
run: |
if [ -f .version.cmake ]; then
VERSION="v$(cat .version.cmake|grep -Eo 'VERSION \d+\.\d+\.\d+'|awk '{print $2}')"
else
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo v0.0.1)"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "PROJECT: $PROJECT_NAME"
echo "VERSION: $VERSION"
echo "RELEASE TAGNAME: ${{ github.event.release.tag_name }}"
# - name: Install 7zip
# run: |
# if [ "$RUNNER_OS" == "Linux" ]; then
# sudo apt install -y p7zip-full
# elif [ "$RUNNER_OS" == "Windows" ]; then
# # choco install yaml-cpp
# vcpkg install 7zip
# elif [ "$RUNNER_OS" == "Darwin" ]; then
# # brew install p7zip
# true
# elif [ "$RUNNER_OS" == "macOS" ]; then
# # brew install p7zip
# true
# else
# echo "RUNNER OS ($RUNNER_OS) not supported"
# exit 1
# fi
# shell: bash
- name: Install yaml-cpp
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt install -y libyaml-cpp-dev
elif [ "$RUNNER_OS" == "Windows" ]; then
# choco install yaml-cpp
vcpkg install yaml-cpp:x64-windows
elif [ "$RUNNER_OS" == "Darwin" ]; then
brew install yaml-cpp
elif [ "$RUNNER_OS" == "macOS" ]; then
echo "install yaml-cpp in macOS"
brew install yaml-cpp
# cannot work for arm64 macOS:
# ls -la $(brew --prefix yaml-cpp)/ /usr/local/include/yaml-cpp/ /usr/local/lib/libyaml-cpp*
# ls -la $(brew --prefix yaml-cpp)/ /opt/homebrew/include/yaml-cpp/ /opt/homebrew/lib/libyaml-cpp*
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
- name: Cache/CCache
uses: actions/cache@v4
with:
path: |
./build/
~/vcpkg
~/.cache/vcpkg/archives
${{ env.LOCALAPPDATA }}/vcpkg/archives
${{ env.APPDATA }}/vcpkg/archives
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
~/.cache/ccache
~/.ccache
~/.config/ccache
~/Library/Caches/ccache
${{ env.LOCALAPPDATA }}/ccache
${{ env.XDG_CACHE_HOME }}/ccache
key: ${{ runner.os }}-${{ matrix.config.build_type }}-${{ matrix.config.compiler }}-${{ hashFiles('**/CMakeLists.txt', './vcpkg.json') }}
restore-keys: |
${{ runner.os }}-${{ matrix.config.build_type }}-
# https://github.com/aminya/setup-cpp
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
# compiler: llvm # llvm, gcc, msvc, apple-clang, vcvarsall
compiler: ${{ matrix.config.compiler }}
vcvarsall: ${{ contains(matrix.config.os, 'windows' )}}
cmake: true # cmake, ninja, meson, make, task, bazel
ninja: true #
# make: false #
conan: true # vcpkg, conan, choco, brew, apt-fast, nala, git, setup-cpp
vcpkg: true #
cppcheck: true # instead of `true`, which chooses the default version, you can pass a specific version.
ccache: true #
clangtidy: ${{ env.CLANG_TIDY_VERSION }}
# clang-tidy: true # clang-tidy, clang-format, cppcheck, cpplint, flawfinder, lizard, infer, cmakelang, cmake-format, cmake-lint
doxygen: true #
graphviz: true #
gcovr: ${{ ! contains(matrix.config.os, 'windows' )}}
opencppcoverage: ${{ contains(matrix.config.os, 'windows' )}}
# gcovr, opencppcoverage, kcov
# python, powershell, sevenzip, tar
# - name: Cleanup Conan system packages (they are not properly cached)
# run: |
# conan remove -f '*/system'
# # https://github.com/marketplace/actions/setup-ccache-action
# # https://github.com/Chocobo1/setup-ccache-action
# - name: Setup ccache
# uses: Chocobo1/setup-ccache-action@v1
# with:
# update_packager_index: false
- name: container env tests
# if: matrix.os != 'windows-latest'
if: ${{ ! contains(matrix.config.os, 'windows') }}
shell: bash
run: |
echo "RUNNER_OS: $RUNNER_OS"
echo "VERSION: $VERSION"
echo "RELEASE TAGNAME: ${{ github.event.release.tag_name }}"
echo "uname -p (processor): $(uname -p)"
echo "uname -s (kernel name): $(uname -s)"
echo "uname -r (kernel release): $(uname -r)"
echo "uname -v (kernel version): $(uname -v)"
echo "uname -m (machine): $(uname -m)"
if [ "$RUNNER_OS" != "macOS" ]; then
echo "uname -i (hardware platform): $(uname -i)"
fi
echo "uname -o (operation system): $(uname -o)"
if [ "$RUNNER_OS" == "Linux" ]; then
cat /etc/*-release
fi
- name: cmake env tests
# if: matrix.os != 'windows-latest'
# if: ${{ ! contains(matrix.os, 'windows') }}
shell: cmake -P {0}
run: |
message(STATUS "PROCESSOR_ARCHITEW6432 = ${PROCESSOR_ARCHITEW6432}")
message(STATUS "PROCESSOR_ARCHITECTURE = ${PROCESSOR_ARCHITECTURE}")
message(STATUS "CMAKE_APPLE_SILICON_PROCESSOR = ${CMAKE_APPLE_SILICON_PROCESSOR}")
message(STATUS "CMAKE_SYSTEM = ${CMAKE_SYSTEM}")
message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}")
message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR = ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_HOST_SYSTEM_NAME = ${CMAKE_HOST_SYSTEM_NAME}")
message(STATUS "CMAKE_HOST_SYSTEM_VERSION = ${CMAKE_HOST_SYSTEM_VERSION}")
message(STATUS "CMAKE_HOST_APPLE = ${CMAKE_HOST_APPLE}")
message(STATUS "CMAKE_HOST_LINUX = ${CMAKE_HOST_LINUX}")
message(STATUS "CMAKE_HOST_UNIX = ${CMAKE_HOST_UNIX}")
message(STATUS "CMAKE_HOST_WIN32 = ${CMAKE_HOST_WIN32}")
message(STATUS "CMAKE_HOST_SOLARIS = ${CMAKE_HOST_SOLARIS}")
message(STATUS "CMAKE_HOST_BSD = ${CMAKE_HOST_BSD}")
message(STATUS "CMAKE_LIBRARY_ARCHITECTURE = ${CMAKE_LIBRARY_ARCHITECTURE}")
# make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
# has meaningful results
- name: CMake Configure
run: |
# cmake -S . -B ./build -G "${{matrix.config.generator}}" -DCMAKE_BUILD_TYPE:STRING="${{matrix.config.build_type}}" -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.config.developer_mode}} -DENABLE_COVERAGE:BOOL=${{ matrix.config.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
cmake -S . -B ./build -G "${{matrix.config.generator}}" -D${{ env.PROJECT_NAME }}_ENABLE_IPO=${{matrix.config.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.config.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.config.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.config.build_type == 'Debug' }} -DPKG_GENERATOR:STRING=${{matrix.config.package_generator}} -DGIT_SHA:STRING=${{ github.sha }}
- name: CMake Build
id: cmake-build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build ./build --config "${{matrix.config.build_type}}"
- name: CMake CTests - Unix
# Execute the build. You can specify a specific target with "--target <NAME>"
if: runner.os != 'Windows' && matrix.config.gcov_executable != '' && matrix.config.build_type == 'Debug'
id: cmake-ctest
run: |
export CTEST_OUTPUT_ON_FAILURE=ON
cmake -E chdir ./build ctest -V -C "${{matrix.config.build_type}}"
[ -d ./out/coverage ] || mkdir -pv ./out/coverage
cd ./build
gcovr --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.config.gcov_executable }}'
- name: CMake CTests - Windows
if: runner.os == 'Windows'
working-directory: ./build
run: |
OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -V -C "${{matrix.config.build_type}}"
# - name: Unix - Test and coverage
# if: runner.os != 'Windows'
# working-directory: ./build
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: |
# ctest -C ${{matrix.build_type}}
# gcovr -j ${{env.nproc}} --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'
# - name: Windows - Test and coverage
# if: runner.os == 'Windows'
# working-directory: ./build
# run: |
# OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}
# - name: Run tests
# if: runner.os != 'Windows'
# shell: cmake -P {0}
# run: |
# include(ProcessorCount)
# ProcessorCount(N)
# set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
# execute_process(
# COMMAND ctest -V -j ${N}
# WORKING_DIRECTORY build
# RESULT_VARIABLE result
# OUTPUT_VARIABLE output
# ERROR_VARIABLE output
# ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
# )
# if (NOT result EQUAL 0)
# string(REGEX MATCH "[0-9]+% tests.*[0-9.]+ sec.*$" test_results "${output}")
# string(REPLACE "\n" "%0A" test_results "${test_results}")
# message("::error::${test_results}")
# message(FATAL_ERROR "Running tests failed!")
# endif()
# - name: Unix - Coverage
# if: runner.os != 'Windows'
# working-directory: ./build
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: |
# ctest -C ${{matrix.build_type}}
# gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'
# - name: Windows - Test and coverage
# if: runner.os == 'Windows'
# working-directory: ./build
# run: |
# OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}
- name: Install Strip
if: ${{ matrix.config.build_type == 'Release' }}
run: cmake --install build --prefix instdir --strip --config "${{matrix.config.build_type}}"
- name: Pack
working-directory: instdir
if: ${{ matrix.config.build_type == 'Release' && matrix.config.package_generator != '' }}
# if: contains(github.ref, 'tags/v')
run: |
# cmake -E tar cfv ../${{ matrix.config.artifact }} --format=7zip .
cpack -V -G ${{matrix.config.package_generator}} -C "${{matrix.config.build_type}}" --config ../build/CPackConfig.cmake
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2.3.3 # pin to v2.2.1 to solve 422 error, see its issue #616
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.config.build_type == 'Release' && matrix.config.package_generator != '' }}
env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
with:
generate_release_notes: true
discussion_category_name: Announcements
# tag_name: ${{ github.ref }}
tag_name: ${{ github.event.release.tag_name }}
# release_name: Release ${{ github.ref }}
draft: false
prerelease: false
append_body: true
preserve_order: true
# body_path: relnotes.md
body: ${{ github.event.head_commit.message }}
# body: |
# This release was created by: ${{ github.event.sender.login }}
# Release of ${{ github.ref }}, built from commit ${{ env.SHORT_SHA }}, is now available.
# files: |
# ./cmdr-*.*
# build/*-*${{ matrix.config.build_type }}*-*.*
files: |
build/packages/*${{ matrix.config.artifact }}
# - name: Publish to codecov
# uses: codecov/codecov-action@v2
# with:
# flags: ${{ runner.os }}
# name: ${{ runner.os }}-coverage
# files: ./build/coverage.xml