-
Notifications
You must be signed in to change notification settings - Fork 1
320 lines (277 loc) · 12.2 KB
/
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
name: CI
on:
workflow_dispatch:
push:
branches:
- master
- beta
- alpha
- +([0-9])?(.{+([0-9]),x}).x
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: 3.11
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --hook-stage manual --all-files
consistency:
if: ${{ !cancelled() && ! failure() }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: 3.11
- name: Install copier
run: |
pip install pyyaml-include==1.4.1
pip install copier==9.1.0
- name: Generate the project with the default value
run: |
find . -maxdepth 1 ! -name '.' \
! -name 'template' \
! -name 'includes' \
! -name '.git' \
! -name 'copier.yml' \
-exec rm -r {} +
copier copy -r HEAD -f . .
rm .copier-answers.yml
- name: Test for consistency
run: |
echo "List inconsistent files:"
git status --porcelain
git diff --exit-code || ( \
echo "# :warning: Inconsistent files found" >> $GITHUB_STEP_SUMMARY && \
echo "The following files are inconsistent with the template:" >> $GITHUB_STEP_SUMMARY && \
git status --porcelain | while read file; do echo "- $file"; done >> $GITHUB_STEP_SUMMARY && \
echo "" >> $GITHUB_STEP_SUMMARY && \
echo "Please run 'copier copy -r HEAD -f . .' to fix them." >>$GITHUB_STEP_SUMMARY && \
exit 1 \
)
checks:
runs-on: ${{ matrix.presets.os.name }}
needs: [pre-commit, consistency]
timeout-minutes: 15
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
presets:
- {os: {name: ubuntu-22.04, type: linux}, compiler: {name: gcc-11, type: gcc}}
- {os: {name: ubuntu-22.04, type: linux}, compiler: {name: llvm, type: llvm}}
- {os: {name: ubuntu-22.04, type: mingw-dynamic-linux}, compiler: {name: mingw, type: mingw}}
- {os: {name: macos-13, type: osx}, compiler: {name: applellvm, type: llvm}}
- {os: {name: macos-13, type: osx}, compiler: {name: llvm, type: llvm}}
# setup-cpp doesn't support mingw on macOS yet
# - {os: {name: macos-13, type: mingw-dynamic-darwin}, compiler: {name: mingw, type: mingw}}
- {os: {name: windows-2022, type: windows}, compiler: {name: msvc, type: msvc}}
- {os: {name: windows-2022, type: windows}, compiler: {name: llvm, type: llvm}}
- {os: {name: windows-2022, type: mingw-dynamic-windows}, compiler: {name: mingw, type: mingw}}
arch:
- {name: x64, type: x64}
vcpkg:
- true
- false
export_mode:
- ON
- OFF
cppcheck: [true, false]
include:
- presets: {os: {name: windows-2022, type: windows}, compiler: {name: msvc, type: msvc}}
arch: {name: x64, type: x64}
vcpkg: true
export_mode: ON
cppcheck: false
- presets: {os: {name: ubuntu-22.04, type: linux}, compiler: {name: gcc-11, type: gcc}}
arch: {name: x64, type: x64}
vcpkg: false
export_mode: OFF
cppcheck: false
- presets: {os: {name: ubuntu-22.04, type: linux}, compiler: {name: gcc-11, type: gcc}}
arch: {name: x64, type: x64}
vcpkg: true
export_mode: OFF
cppcheck: true
exclude:
- export_mode: ON
- vcpkg: false
- cppcheck: true
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: |
~/vcpkg
~/.cache/pip
~/.cache/vcpkg
~/AppData/Local/vcpkg
key: |
${{ matrix.arch.name }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ hashFiles('vcpkg.json') }}-${{ matrix.vcpkg }}
restore-keys: |
${{ matrix.arch.name }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}-${{ hashFiles('vcpkg.json') }}-
- uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.presets.compiler.name }}
vcvarsall: ${{ contains(matrix.presets.os.type, 'windows' )}}
cmake: true
ninja: true
vcpkg: ${{ matrix.vcpkg }}
ccache: true
cppcheck: ${{ matrix.cppcheck == true }}
python: true
opencppcoverage: ${{ contains(matrix.presets.os.type, 'windows' )}}
- name: Disable pre-installedd vcpkg for testing automaical vcpkg installation
if: ${{ matrix.vcpkg == false }}
run: |
echo "VCPKG_INSTALLATION_ROOT=" >> $GITHUB_ENV
- name: Lcov for coverage
if: contains(matrix.presets.compiler.type, 'gcc') && contains(matrix.presets.os.type, 'linux')
run: |
sudo apt-get update
sudo apt-get install lcov
- name: Gcovr for coverage
if: contains(matrix.presets.compiler.type, 'mingw') && contains(matrix.presets.os.type, 'mingw')
run: |
pip install gcovr
- name: Target Windows on Linux (Mingw-w64)
if: contains(matrix.presets.compiler.type, 'mingw') && contains(matrix.presets.os.type, 'linux')
run: |
sudo apt-get update && sudo apt-get install mingw-w64 wine wine64 powershell
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
wine64 true || true
echo "timeout 10s to execute a loop to check wine registry to be created"
timeout 10s bash -c "while [ ! -f ~/.wine/system.reg ] ; do echo 'waiting for wine registry to be created' ; sleep 1 ; done" && echo "wine registry created"
sed -i '/"PATH"/ s|"$|;Z:/usr/lib/gcc/x86_64-w64-mingw32/10-posix;Z:/usr/x86_64-w64-mingw32/lib"|g' ~/.wine/system.reg && echo "wine registry updated"
# see https://github.com/actions/runner-images/issues/9524
- name: Fix kernel mmap rnd bits
# Asan in llvm 14 provided in ubuntu 22.04 is incompatible with
# high-entropy ASLR in much newer kernels that GitHub runners are
# using leading to random crashes: https://reviews.llvm.org/D148280
if: contains(matrix.presets.compiler.type, 'gcc') && contains(matrix.presets.os.type, 'linux')
run: sudo sysctl vm.mmap_rnd_bits=28
- name: Configure CMake
run: |
cmake -S . --preset=${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON -DBUILD_TESTING=ON ${{ matrix.export_mode == 'ON' && '-DVCPKG_EXPORT_MODE=ON' || '' }}
- name: Build
run: |
cmake --build out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} --target all
- name: Coverage
run: |
cmake --build out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }} --target ccov-all
- name: Upload coverage report
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: out/build/${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.type }}/code_coverage
files: ./coverage.xml, ./coverage.info, ./coverage.json
flags: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == true && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}${{ matrix.cppcheck == true && '-cppcheck' || '' }}
name: ${{ matrix.arch.type }}-${{ matrix.presets.os.type }}-${{ matrix.presets.compiler.name }}${{ matrix.vcpkg == true && '-vcpkg' || '' }}${{ matrix.export_mode == 'ON' && '-export' || '' }}${{ matrix.cppcheck == true && '-cppcheck' || '' }}-coverage
docs:
name: Docs build and checks
runs-on: ubuntu-22.04
needs: [pre-commit, consistency]
timeout-minutes: 15
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ~/.cache/vcpkg
key: x64-linux-gcc-${{ hashFiles('vcpkg.json') }}
restore-keys: x64-linux-gcc-${{ hashFiles('vcpkg.json') }}
- uses: aminya/setup-cpp@v1
with:
compiler: gcc
cmake: true
ninja: true
ccache: true
doxygen: true
graphviz: true
python: true
- name: Install docs dependencies
run: |
pip install -r docs/requirements.txt
- name: Configure
run: cmake -S . --preset=x64-linux-gcc -DBUILD_TESTING=OFF -DCODE_COVERAGE=OFF
- name: Checks the docs with warnings as errors
run: cmake --build out/build/x64-linux-gcc --target ss-cpp-docs-check
- name: Checks the docs for broken links
run: cmake --build out/build/x64-linux-gcc --target ss-cpp-docs-linkcheck
pass:
if: always()
needs: [checks, docs]
runs-on: ubuntu-22.04
timeout-minutes: 2
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
release:
name: release
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request'
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
needs: [pass]
steps:
- name: Generate a bot token with BOT_APP_ID
id: bot_token
if: vars.BOT_APP_ID && env.BOT_PRIVATE_KEY != null
uses: actions/create-github-app-token@78e5f2ddc08efcb88fbbee6cfa3fed770ba550c3 # v1
env:
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
with:
app-id: ${{ vars.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Warn if use GITHUB_TOKEN
if: env._GITHUB_TOKEN == env._TO_BE_VERIFIED_TOKEN
env:
_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
_TO_BE_VERIFIED_TOKEN: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}
run: |
echo "# :warning: GITHUB_TOKEN is used" >> $GITHUB_STEP_SUMMARY
echo "The GITHUB_TOKEN is used instead of a bot token or PAT that will not emit the released publish event for triggering a released workflow." >> $GITHUB_STEP_SUMMARY
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
token: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 20
- uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
semantic_version: 22
extra_plugins: |
@semantic-release/exec
@semantic-release/github
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}