-
Notifications
You must be signed in to change notification settings - Fork 77
352 lines (331 loc) · 14.4 KB
/
github-cxx-qt-tests.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
# SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-FileContributor: Andrew Hayzen <[email protected]>
# SPDX-FileContributor: Be <[email protected]>
#
# SPDX-License-Identifier: MIT OR Apache-2.0
name: cxx-qt tests
on:
push:
pull_request:
schedule:
# Run daily at 01:01
# This ensures CI still works and ensures the cache remains active
- cron: "1 1 * * *"
# Cancel any previous runs for the same pull request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
clang_format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y clang-format-12
- run: ./scripts/clang_format_check.sh .
license_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v3
rust_format_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup component add rustfmt
- run: cargo fmt --all --check --verbose
markdown_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: '**/*.md'
build:
# Run after pre checks
needs: [clang_format, license_check, rust_format_check, markdown_lint]
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu 22.04 (gcc) Qt5
os: ubuntu-22.04
qt_version: 5
vcpkg: off
vcpkg_triplet: x64-linux-release
cores: 4
# FIXME: valgrind complains about invalid debuginfo. Might be fixed when Ubuntu updates to valgrind 3.20
# https://bugs.kde.org/show_bug.cgi?id=452758
ctest_args: --exclude-regex '^(example_qml_features_test_valgrind|example_qml_minimal_myobject_test_valgrind)$'
qt_qpa_platform: offscreen
compiler_cache_path: /home/runner/.cache/sccache
cargo_dir: ~/.cargo
packages-extra: >-
qtbase5-dev
qtdeclarative5-dev
qtquickcontrols2-5-dev
qml-module-qtquick2
qml-module-qtquick-controls2
qml-module-qttest
workspace: /home/runner/cxx-qt
- name: Ubuntu 22.04 (gcc) Qt6
os: ubuntu-22.04
qt_version: 6
vcpkg: off
vcpkg_triplet: x64-linux-release
cores: 4
# FIXME: valgrind complains about invalid debuginfo. Might be fixed when Ubuntu updates to valgrind 3.20
# https://bugs.kde.org/show_bug.cgi?id=452758
ctest_args: --exclude-regex '^(example_qml_features_test_valgrind|example_qml_minimal_myobject_test_valgrind)$'
qt_qpa_platform: offscreen
compiler_cache_path: /home/runner/.cache/sccache
cargo_dir: ~/.cargo
packages-extra: >-
qt6-base-dev
qt6-declarative-dev
qt6-declarative-dev-tools
qml6-module-qtquick-controls
qml6-module-qtquick-window
qml6-module-qttest
qml6-module-qtqml-workerscript
libgl1-mesa-dev
libvulkan-dev
libxkbcommon-dev
workspace: /home/runner/cxx-qt
- name: macOS 12 (clang) Qt5
os: macos-12
qt_version: 5
vcpkg: on
vcpkg_triplet: x64-osx-release
cores: 3
# FIXME: qmltestrunner fails to import QtQuick module
# https://github.com/KDAB/cxx-qt/issues/110
#
# FIXME: clang-format-14 causes formatting differences if it is selected by brew
# once Ubuntu 22.04 is we can move to clang-format-14 everywhere
# for now we need at least clang-format-12 otherwise include reordering fails after clang-format off
# https://github.com/KDAB/cxx-qt/issues/121
ctest_args: --exclude-regex '^(cargo_clippy|cargo_doc|example_qml_features_test|example_qml_minimal_myobject_test|cargo_build_rerun|.*valgrind)$'
qt_qpa_platform: cocoa
compiler_cache_path: /Users/runner/Library/Caches/Mozilla.sccache
cargo_dir: ~/.cargo
workspace: /Users/runner/cxx-qt
cc: clang
cxx: clang++
- name: macOS 12 (clang) Qt6
os: macos-12
qt_version: 6
vcpkg: on
vcpkg_triplet: x64-osx-release
cores: 3
# FIXME: qmltestrunner fails to import QtQuick module
# https://github.com/KDAB/cxx-qt/issues/110
ctest_args: --exclude-regex '^(cargo_clippy|cargo_doc|example_qml_features_test|example_qml_minimal_myobject_test|cargo_build_rerun|.*valgrind)$'
qt_qpa_platform: cocoa
compiler_cache_path: /Users/runner/Library/Caches/Mozilla.sccache
cargo_dir: ~/.cargo
workspace: /Users/runner/cxx-qt
cc: clang
cxx: clang++
- name: Windows 2022 (MSVC) Qt5
os: windows-2022
qt_version: 5
vcpkg: on
# Use a short buildtrees root for building vcpkg
vcpkg_buildtrees_root: C:\v
vcpkg_triplet: x64-windows-release
cores: 4
ctest_args: --exclude-regex '^(cargo_clippy|cargo_doc|cargo_build_rerun|.*valgrind)$'
exe_suffix: .exe
qt_qpa_platform: windows
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
cargo_dir: C:\Users\runneradmin\.cargo
cc: cl
cxx: cl
# The D drive runs out of space when building dependencies with vcpkg.
workspace: C:\cxx-qt
- name: Windows 2022 (MSVC) Qt6
os: windows-2022
qt_version: 6
vcpkg: on
# Use a short buildtrees root for building vcpkg
vcpkg_buildtrees_root: C:\v
vcpkg_triplet: x64-windows-release
cores: 4
ctest_args: --exclude-regex '^(cargo_clippy|cargo_doc|cargo_build_rerun|.*valgrind)$'
exe_suffix: .exe
qt_qpa_platform: windows
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
cargo_dir: C:\Users\runneradmin\.cargo
cc: cl
cxx: cl
# The D drive runs out of space when building dependencies with vcpkg.
workspace: C:\cxx-qt
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
env:
# Match the deployment target that Qt was built with via vcpkg, otherwise the following error occurs
# ld: warning: object file (LIB) was built for newer macOS version (12.7) than being linked (12.0)
MACOSX_DEPLOYMENT_TARGET: 12.7
# sccache is around 180-300M in size for a normal build
# With GitHub caches we have a 10 GB limit / 6 conditions = 1666 MB
# Allow a larger cache size so that code in branches can be cached
# but still leave room for the tools cache
SCCACHE_CACHE_SIZE: 600M
steps:
# On Windows, the D drive that the workspace is on by default runs out of space when
# vcpkg builds Qt, so the repo needs to be cloned to the C drive. GitHub's checkout
# action does not support cloning to a path outside GITHUB_WORKSPACE:
# https://github.com/actions/checkout/issues/197
- name: "Clone Git repository"
uses: LebedevRI/checkout@issue197
with:
path: ${{ matrix.workspace }}
# Ensure clippy and rustfmt is installed, they should come from github runner
#
# Note we still need rustfmt for the cxx-qt-gen tests
- name: "Install Rust toolchain"
run: rustup component add clippy rustfmt
- name: "Rust tools cache"
uses: actions/cache@v4
id: rust-tools-cache
with:
path: |
${{ matrix.cargo_dir }}/bin/sccache${{ matrix.exe_suffix }}
${{ matrix.cargo_dir }}/bin/mdbook${{ matrix.exe_suffix }}
${{ matrix.cargo_dir }}/bin/mdbook-linkcheck${{ matrix.exe_suffix }}
key: ${{ matrix.os }}_sccache-0.7.6_mdbook-0.4.36_mdbook-linkcheck-0.7.7
- name: "Build Rust tools"
if: steps.rust-tools-cache.outputs.cache-hit != 'true'
# Do not build with storage backends enabled, we only need local
run: |
cargo install --no-default-features sccache
cargo install mdbook mdbook-linkcheck
# We want our compiler cache to always update to the newest state.
# The best way for us to achieve this is to **always** update the cache after every landed commit.
# That way it will closely follow our development.
# And if a PR diverges a lot with its cache that's not a big deal, as it will be merged eventually.
#
# This is a workaround for the fact that GH doesn't support updating existing caches.
# See: https://github.com/azu/github-actions-overwrite-cache-example
#
# Ideally we'd like to use this:
# - name: "Compiler cache"
# uses: actions/cache@v4
# with:
# update: true <------- THIS DOESN'T EXIST YET
# path: ${{ matrix.compiler_cache_path }}
# key: ${{ matrix.name }}_compiler_cache
- name: "Restore Compiler Cache"
id: compiler-cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ matrix.compiler_cache_path }}
key: ${{ matrix.name }}_compiler_cache
- name: "[Ubuntu] Install dependencies"
if: runner.os == 'Linux'
run: >-
sudo apt-get update &&
sudo apt-get install -y
ninja-build
clang-format-12
libssl-dev
pkg-config
valgrind
${{ matrix.packages-extra }}
# hack around https://bugs.launchpad.net/ubuntu/+source/qtchooser/+bug/1964763
- name: "[Ubuntu] Add Qt6 tools to PATH"
if: runner.os == 'Linux' && matrix.qt_version == 6
run: echo "PATH=/usr/lib/qt6/bin:${PATH}" >> "${GITHUB_ENV}"
- name: "[macOS] Install dependencies"
if: runner.os == 'macOS'
# FIXME: clang-format-14 causes formatting differences if it is selected by brew
# once Ubuntu 22.04 is we can move to clang-format-14 everywhere
# for now we need at least clang-format-12 otherwise include reordering fails after clang-format off
# https://github.com/KDAB/cxx-qt/issues/121
#
# automake is needed for building libicu which is a dependency of Qt
run: brew install automake autoconf-archive ninja clang-format
# Note that for nuget uploads to work this must be run as the kdab user
# eg a branch on the kdab repo rather than a users fork
#
# Otherwise you may see the following error:
# Pushing NuGet to "cxx-qt-github-packages" failed. Use --debug for more information.
- name: "Authenticate to GitHub Packages"
if: runner.os != 'Linux' && github.repository_owner == 'KDAB'
shell: bash
run: |
nuget sources add -Name cxx-qt-github-packages -Source https://nuget.pkg.github.com/KDAB/index.json -Username KDAB -Password ${{ secrets.GITHUB_TOKEN }} -NonInteractive
nuget setapikey ${{ secrets.GITHUB_TOKEN }} -Source cxx-qt-github-packages -NonInteractive
echo "VCPKG_BINARY_SOURCES=clear;nuget,cxx-qt-github-packages,readwrite;" >> "${GITHUB_ENV}"
# Required for CMake to find Ninja
- name: "[Windows] Set up MSVC Developer Command Prompt"
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v4
# Ninja is required on Windows for CMAKE_CXX_COMPILER_LAUNCHER to work for using sccache.
#
# Until debug and release packages are split we only build release packages for vcpkg
# to improve CI run times, hence VCPKG_HOST_TRIPLET and VCPKG_TARGET_TRIPLET
# https://github.com/microsoft/vcpkg/issues/1626
- name: "Configure"
run: >-
cmake
-D USE_QT5=${{ matrix.qt_version == 5 }}
-D CMAKE_BUILD_TYPE=Release
-D VCPKG=${{ matrix.vcpkg }}
-D VCPKG_HOST_TRIPLET=${{ matrix.vcpkg_triplet }}
-D VCPKG_BUILDTREES_ROOT=${{ matrix.vcpkg_buildtrees_root }}
-D VCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }}
-G Ninja
-S . -B build
working-directory: ${{ matrix.workspace }}
env:
RUSTC_WRAPPER: sccache
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
- name: "Build"
run: cmake --build build --config Release --parallel ${{ matrix.cores }}
working-directory: ${{ matrix.workspace }}
env:
RUSTC_WRAPPER: sccache
- name: "Test"
run: ctest ${{ matrix.ctest_args }} -C Release -T test --output-on-failure --parallel ${{ matrix.cores }}
working-directory: ${{ matrix.workspace }}/build
env:
RUSTC_WRAPPER: sccache
QT_QPA_PLATFORM: ${{ matrix.qt_qpa_platform }}
QT_SELECT: qt${{ matrix.qt_version }}
- name: "Print compiler cache statistics"
run: sccache --show-stats
# This is a workaround for the fact that GH doesn't support updating existing caches.
# See: https://github.com/azu/github-actions-overwrite-cache-example
- name: "Delete previous compiler cache"
# Updating th cache doesn't work from forks
# So update it once it's merged into the repo
if: ${{ steps.compiler-cache-restore.outputs.cache-hit && github.event_name == 'push' }}
working-directory: ${{ matrix.workspace }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "${{ matrix.name }}_compiler_cache" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Save Compiler Cache"
# Updating th cache doesn't work from forks
# So update it once it's merged into the repo
if: ${{ github.event_name == 'push' }}
uses: actions/cache/save@v4
with:
path: ${{ matrix.compiler_cache_path }}
key: ${{ matrix.name }}_compiler_cache
- name: Upload GitHub Actions artifacts of vcpkg logs
if: always()
uses: actions/upload-artifact@v4
with:
name: vcpkg-logs-${{ matrix.name }}
path: |
${{ matrix.workspace }}/vcpkg/buildtrees/**/*.log
${{ matrix.workspace }}/build/vcpkg-bootstrap.log
${{ matrix.workspace }}/build/vcpkg-manifest-install.log
${{ matrix.workspace }}/build/vcpkg_installed/vcpkg/issue_body.md
if-no-files-found: ignore