-
Notifications
You must be signed in to change notification settings - Fork 17
470 lines (410 loc) · 17 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
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
name: Continuous Integration
on:
push:
branches:
- develop
- master
- '*'
tags:
- "v*.*.*"
pull_request:
branches:
- develop
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
jobs:
cpp-matrix:
runs-on: ubuntu-latest
name: Generate Test Matrix
outputs:
matrix: ${{ steps.cpp-matrix.outputs.matrix }}
steps:
- name: Clone cpp-actions
uses: actions/checkout@v3
- name: Generate Test Matrix
uses: alandefreitas/cpp-actions/cpp-matrix@v1.5.0
id: cpp-matrix
with:
compilers: |
gcc 13.2
clang 16
msvc 14.34
standards: '>=20'
max-standards: 1
latest-factors: gcc
factors: clang # Don't include Asan because `clang/AST/Decl.h` fails
build:
needs: cpp-matrix
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.cpp-matrix.outputs.matrix) }}
defaults:
run:
shell: bash
name: ${{ matrix.name }}
runs-on: ${{ matrix.runs-on }}
container: ${{ matrix.container }}
permissions:
contents: write
steps:
- name: Clone MrDocs
uses: actions/checkout@v3
- name: Install LLVM
id: llvm-install
shell: bash
run: |
set -xe
# Determine LLVM configuration type
llvm_config_type="${{ matrix.build-type }}"
if [ "${{ runner.os }}" == "Windows" ]; then
llvm_runner_os="Windows"
# if [ "$llvm_config_type" == "Release" ]; then
# llvm_config_type="RelWithDebInfo"
# fi
llvm_archive_type="7z"
llvm_config_type="Release"
else
llvm_runner_os="Linux"
llvm_archive_type="tar.xz"
llvm_config_type="Release"
fi
llvm_commit_id=29b20829
llvm_archive_filename="$llvm_runner_os-$llvm_config_type-$llvm_commit_id.$llvm_archive_type"
llvm_url="https://github.com/cppalliance/mrdocs/releases/download/llvm-package-release/$llvm_archive_filename"
if ! curl --head --silent --fail "$llvm_url"; then
llvm_url="https://mrdox.com/llvm+clang/$llvm_archive_filename"
fi
# Download LLVM binaries
curl -L -o "$llvm_archive_filename" "$llvm_url"
# Install LLVM to runner.tool_cache/llvm+clang
llvm_root="${{runner.tool_cache}}/llvm+clang"
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
mkdir -p "$llvm_root"
if [ "${{ runner.os }}" != "Windows" ]; then
tar -xvf "$llvm_archive_filename" -C "$llvm_root" --strip-components=1
else
7z x "$llvm_archive_filename"
cd "$llvm_config_type"
mv * "$llvm_root"
cd ..
rm -rf "$llvm_config_type"
fi
# Export LLVM_ROOT
echo "llvm_root=$llvm_root"
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
- name: Install Duktape
id: duktape-install
shell: bash
run: |
set -xe
curl -L -o "duktape-2.7.0.tar.xz" "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz"
duktape_dir="${{runner.tool_cache}}/duktape"
duktape_dir=$(echo "$duktape_dir" | sed 's/\\/\//g')
mkdir -p "$duktape_dir"
tar -xvf "duktape-2.7.0.tar.xz" -C "$duktape_dir"
echo "duktape-dir=$duktape_dir/duktape-2.7.0" >> $GITHUB_OUTPUT
echo "duktape_dir=$duktape_dir/duktape-2.7.0"
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Setup C++
uses: alandefreitas/cpp-actions/setup-cpp@v1.5.0
id: setup-cpp
with:
compiler: ${{ matrix.compiler }}
version: ${{ matrix.version }}
check-latest: ${{ matrix.compiler == 'clang' }}
- name: Install packages
uses: alandefreitas/cpp-actions/package-install@v1.5.0
id: package-install
with:
apt-get: ${{ matrix.install }} openjdk-11-jdk ninja-build ${{ matrix.compiler == 'clang' && 'libstdc++-12-dev' || '' }}
vcpkg: fmt libxml2[tools]
cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }}
ccflags: ${{ matrix.ccflags }}
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }}
cxxflags: ${{ matrix.cxxflags }}
- name: CMake Workflow
uses: alandefreitas/cpp-actions/cmake-workflow@v1.5.0
with:
cmake-version: '>=3.20'
generator: Ninja
toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }}
build-type: ${{ matrix.build-type }}
cxxstd: ${{ matrix.cxxstd }}
cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }}
ccflags: ${{ matrix.ccflags }}
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }}
cxxflags: ${{ matrix.cxxflags }}${{ ( matrix.compiler == 'gcc' && ' -static-libstdc++') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }}
install-prefix: .local
extra-args: ${{ format('-D LLVM_ROOT="{0}" -D Clang_ROOT="{0}" -D DUKTAPE_SOURCE_ROOT="{1}" -D CMAKE_EXPORT_COMPILE_COMMANDS=ON', steps.llvm-install.outputs.llvm-root || '/usr/local', steps.duktape-install.outputs.duktape-dir) }}
export-compile-commands: ${{ matrix.time-trace }}
package: ${{ matrix.is-main }}
package-dir: packages
- name: Upload GitHub Release Artifacts
if: ${{ matrix.is-main && matrix.compiler != 'clang' }}
uses: actions/upload-artifact@v3
with:
name: release-packages-${{ runner.os }}
path: build/packages
retention-days: 1
- name: FlameGraph
uses: alandefreitas/cpp-actions/flamegraph@v1.5.0
if: matrix.time-trace
with:
build-dir: build
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Codecov
if: ${{ matrix.coverage }}
run: |
set -x
# Find gcov
gcov_tool="gcov"
if command -v "gcov-${{ steps.setup-cpp.outputs.version-major }}.${{ steps.setup-cpp.outputs.version-minor }}" &> /dev/null; then
gcov_tool="gcov"
elif command -v "gcov-${{ steps.setup-cpp.outputs.version-major }}" &> /dev/null; then
gcov_tool="gcov-${{ steps.setup-cpp.outputs.version-major }}"
fi
lcov -c -q -o "./build/coverage.info" -d "./build" --include "$(pwd)/*" --gcov-tool "$gcov_tool"
# Upload to codecov
bash <(curl -s https://codecov.io/bash) -f "./build/coverage.info"
# Update summary
echo "# Coverage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graphs/sunburst.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "$GITHUB_REF_NAME: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/branch/$GITHUB_REF_NAME/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
docs:
needs: build
defaults:
run:
shell: bash
name: Documentation
timeout-minutes: 30
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Clone mrdocs
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Generate Site
working-directory: docs
run: |
npm install
master_antora_exists=$(curl --silent --fail --head https://github.com/cppalliance/mrdocs/blob/master/docs/antora.yml >/dev/null && echo "true" || echo "false")
develop_antora_exists=$(curl --silent --fail --head https://github.com/cppalliance/mrdocs/blob/develop/docs/antora.yml >/dev/null && echo "true" || echo "false")
if [ "$master_antora_exists" == "true" ] && [ "$develop_antora_exists" == "true" ]; then
# Antora is set up in both master and develop: render complete playbook
npx antora antora-playbook.yml
else
# Antora is not set up in master and develop yet: render local playbook while integration is not complete
# The local playbook is used for local development and for the documentation included in the release
npx antora local-antora-playbook.yml
fi
- name: Publish to GitHub Pages
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/site
force_orphan: true
- name: Update website
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }}
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
# Add SSH key
mkdir -p /home/runner/.ssh
ssh-keyscan dev-websites.cpp.al >> /home/runner/.ssh/known_hosts
echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > /home/runner/.ssh/github_actions
chmod 600 /home/runner/.ssh/github_actions
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add /home/runner/.ssh/github_actions
# Copy files
chmod 755 -R $(pwd)/docs/build/site
scp -r $(pwd)/docs/build/site/* ubuntu@dev-websites.cpp.al:/var/www/mrdox.com/
demos:
needs: build
defaults:
run:
shell: bash
name: Demos
timeout-minutes: 120
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Clone mrdocs
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: release-packages-Linux
path: packages
- name: List artifacts
run: ls -R
working-directory: packages
- name: Setup C++
uses: alandefreitas/cpp-actions/setup-cpp@v1.5.0
id: setup-cpp
with:
compiler: clang
version: 16
check-latest: true
- name: Install packages
uses: alandefreitas/cpp-actions/package-install@v1.5.0
id: package-install
with:
apt-get: libstdc++-12-dev asciidoctor
cc: ${{ steps.setup-cpp.outputs.cc }}
cxx: ${{ steps.setup-cpp.outputs.cxx }}
- name: Install mrdocs from release package
run: |
set -x
sudo find packages -name 'MrDocs-*-Linux.tar.gz' -exec tar -xzf {} -C /usr/local --strip-components=1 \;
mrdocs --version
- name: Clone Boost.URL
uses: alandefreitas/cpp-actions/boost-clone@v1.5.0
id: boost-url-clone
with:
branch: master
modules: url
boost-dir: boost
modules-scan-paths: '"test example"'
modules-exclude-paths: ''
trace-commands: true
- name: Configure Boost.URL
working-directory: boost/libs/url
run: |
set -x
if [ -d "__build__" ]; then
rm -rf __build__
fi
mkdir __build__
cd __build__
mkdir __include_dirs__
cd __include_dirs__
output_file="include_dirs.txt"
echo "cmake_minimum_required(VERSION 3.22)" > CMakeLists.txt
echo "project(get_implicit_dirs)" >> CMakeLists.txt
echo "file(WRITE \"${output_file}\" \"\${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}\")" >> CMakeLists.txt
mkdir __build__
cd __build__
cmake -D CMAKE_CXX_COMPILER=${{ steps.setup-cpp.outputs.cxx }} -D CMAKE_C_COMPILER=${{ steps.setup-cpp.outputs.cc }} ..
cd ..
default_includes=$(cat "$output_file")
cd ..
cmake -D BOOST_URL_BUILD_TESTS=OFF -D BOOST_URL_BUILD_EXAMPLES=OFF -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="$default_includes" -D CMAKE_CXX_COMPILER=${{ steps.setup-cpp.outputs.cxx }} -D CMAKE_C_COMPILER=${{ steps.setup-cpp.outputs.cc }} ..
- name: Generate demos
run: |
config_template=$(printf '%s\n' \
"verbose: true" \
"source-root: ." \
"generate: %s" \
"multipage: %s" \
"inaccessible-members: never" \
"filters:" \
" symbols:" \
" exclude:" \
" - 'boost::urls::detail'" \
" - 'boost::urls::*::detail'" \
)
set -x
for variant in single multi; do
for format in adoc html xml; do
[[ $variant = multi ]] && multiline="true" || multiline="false"
printf "$config_template\n" $format $multiline > $(pwd)/boost/libs/url/mrdocs.yml
mkdir -p "demos/boost-url/$variant/$format"
mrdocs --config="$(pwd)/boost/libs/url/mrdocs.yml" "$(pwd)/boost/libs/url/__build__/compile_commands.json" --addons="$(pwd)/share/mrdocs/addons" --output="$(pwd)/demos/boost-url/$variant/$format"
done
asciidoctor -R "$(pwd)/demos/boost-url/$variant/adoc" -D "$(pwd)/demos/boost-url/$variant/adoc-asciidoc" "$(pwd)/demos/boost-url/$variant/adoc/**/*.adoc"
done
tar -cjf $(pwd)/demos.tar.gz -C $(pwd)/demos --strip-components 1 .
echo "demos_path=$(pwd)/demos.tar.gz" >> $GITHUB_ENV
- name: Upload demo artifacts
uses: actions/upload-artifact@v3
with:
name: demos
path: ${{ env.demos_path }}
retention-days: 1
- name: Update website demos
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }}
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
# Add SSH key
mkdir -p /home/runner/.ssh
ssh-keyscan dev-websites.cpp.al >> /home/runner/.ssh/known_hosts
echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > /home/runner/.ssh/github_actions
chmod 600 /home/runner/.ssh/github_actions
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add /home/runner/.ssh/github_actions
# Copy files
demo_dir="/var/www/mrdox.com/demos/${{ github.ref_name }}"
ssh ubuntu@dev-websites.cpp.al "rm -rf $demo_dir; mkdir -p $demo_dir"
chmod 755 -R $(pwd)/demos
scp -r $(pwd)/demos/* ubuntu@dev-websites.cpp.al:$demo_dir/
releases:
needs: build
defaults:
run:
shell: bash
name: Releases
timeout-minutes: 120
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Clone mrdocs
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: release-packages-Linux
path: build
- uses: actions/download-artifact@v3
with:
name: release-packages-Windows
path: build
- name: List artifacts
run: ls -R
working-directory: build
- name: Create changelog
uses: alandefreitas/cpp-actions/create-changelog@v1.5.0
with:
output-path: CHANGELOG.md
thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
limit: 150
- name: Remove branch release
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name)) }}
uses: dev-drprasad/delete-tag-and-release@v1.0
with:
tag_name: ${{ github.ref_name }}-release
github_token: ${{ secrets.GITHUB_TOKEN }}
delete_release: true
- name: Create GitHub Package Release
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }}
uses: softprops/action-gh-release@v1
with:
files: build/MrDocs-?.?.?-*.*
name: ${{ github.ref_name || github.ref }}
tag_name: ${{ github.ref_name || github.ref }}${{ ((!startsWith(github.ref, 'refs/tags/')) && '-release') || '' }}
body_path: CHANGELOG.md
prerelease: false
draft: false
token: ${{ github.token }}
- uses: dev-drprasad/delete-older-releases@v0.2.1
if: ${{ github.event_name == 'push' && contains(fromJSON('["master", "develop"]'), github.ref_name) }}
with:
keep_latest: 1
delete_tag_pattern: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}