-
Notifications
You must be signed in to change notification settings - Fork 15
181 lines (160 loc) · 7.07 KB
/
knut-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
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: MIT
name: knut tests
on:
push:
branches:
- main
pull_request:
branches:
- main
# 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:
build:
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu (clang&clazy)
os: ubuntu-latest
compiler_cache_path: /home/runner/.cache/sccache
cmake_preset: clazy
- name: Ubuntu (gcc)
os: ubuntu-latest
compiler_cache_path: /home/runner/.cache/sccache
cmake_preset: ci
- name: Windows
os: windows-latest
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache
cmake_preset: ci
- name: MacOS
os: macos-latest
compiler_cache_path: /Users/runner/Library/Caches/Mozilla.sccache
cmake_preset: ci
env:
SCCACHE_CACHE_SIZE: "2G"
steps:
- name: Inspect Environment Variables
run: env
- name: Checkout sources
uses: actions/checkout@v4
# Ideally, we'd simply like to replace this with:
# submodules: recursive
# on the "Checkout sources" step
# However, this is not possible, as the secret key to access the Github repository is not available from forks.
# So we need to conditionally check for the secret key.
- name: Checkout submodules
run: |
git submodule update --init --force --depth=1 --recursive -- 3rdparty/*
- name: Configure SSH for connection to codereview.kdab.com (main repo only)
uses: shimataro/ssh-key-action@v2
# The GERRIT_SSH_KEY is only available in the main knut repo **after** merging a PR
# So only run this step if that's the case.
if: ${{ github.repository == 'KDAB/knut' && github.event_name == 'push' }}
with:
key: ${{ secrets.GERRIT_SSH_KEY }}
name: id_knut-github-gerrit-access
known_hosts: "[codereview.kdab.com]:29418 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII7rIogDqC3Za+LV37295k312ihzhH/HsSNDE6+VHQMF"
config: |
Host codereview.kdab.com
HostName codereview.kdab.com
User knut-github-gerrit-access
IdentityFile ~/.ssh/id_knut-github-gerrit-access
- name: Checkout private submodules (main repo only)
# The GERRIT_SSH_KEY is only available in the main knut repo **after** merging a PR
# So only run this step if that's the case.
if: ${{ github.repository == 'KDAB/knut' && github.event_name == 'push' }}
run: |
git submodule update --init --force --depth=1 --recursive -- 3rdparty-kdab/*
- name: Install ninja-build tool
uses: aseprite/get-ninja@main
- name: Install Qt 6
uses: jurplel/install-qt-action@v4
with:
version: 6.5.* # 6.5 is the current LTS (as of 2024-06-06)
cache: true
- name: Make sure MSVC is found when Ninja generator is in use
uses: ilammy/msvc-dev-cmd@v1
# Note: The Compiler cache steps were adapted from the CXX-Qt repository (https://github.com/kdab/cxx-qt)
#
# 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.os }}_${{ matrix.cmake_preset }}_compiler_cache
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install recent clang
uses: KyleMayes/install-llvm-action@v2
if: ${{ matrix.cmake_preset == 'clazy' }}
with:
version: "17"
env: true
- name: Build & Install clazy
if: ${{ matrix.cmake_preset == 'clazy' }}
run: |
git clone --depth=1 https://github.com/KDE/clazy.git
cd clazy/
cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DLINK_CLAZY_TO_LLVM=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja -DLLVM_ROOT=${{ env.LLVM_PATH }}
cmake --build .
sudo cmake --build . --target install
cd ..
echo "CLANGXX=${{ env.LLVM_PATH }}/bin/clang++" >> $GITHUB_ENV
- name: Configure project
run: cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache --preset=${{ matrix.cmake_preset }}
- name: Build Project
run: cmake --build --preset=${{ matrix.cmake_preset }}
- name: Run tests
run: ctest --preset=${{ matrix.cmake_preset }}
# We only upload artifacts if building or testing has failed
# That way we can debug if necessary, but don't pay the 30s-60s
# of upload time if everything is going well.
- name: Output the build results as an artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: knut-binaries-${{ matrix.os }}-${{ github.head_ref || github.ref_name }}
path: build-${{ matrix.cmake_preset }}/bin/
overwrite: true
# 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' }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "${{ matrix.os }}_${{ matrix.cmake_preset }}_compiler_cache" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Save Compiler Cache"
uses: actions/cache/save@v4
# Updating th cache doesn't work from forks
# So update it once it's merged into the repo
if: ${{ github.event_name == 'push' }}
with:
path: ${{ matrix.compiler_cache_path }}
key: ${{ matrix.os }}_${{ matrix.cmake_preset }}_compiler_cache