Debian Codegraph @

.github/workflows/build-linux.yml

raw
1 ---
2 name: Linux
3
4 on:
5 push:
6 branches: [master]
7 tags: ['v*']
8 pull_request:
9 branches: [master]
10
11 concurrency:
12 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13 cancel-in-progress: true
14
15 env:
16 common_packages: >-
17 ninja-build
18
19 libxfixes-dev
20 libxtst-dev
21
22 extra-cmake-modules
23 libwayland-dev
24
25 libegl-dev
26
27 gnupg2
28
29 xvfb
30 openbox
31 xdotool
32 qt6_packages: >-
33 qt6-base-private-dev
34 qt6-base-dev
35 qt6-base-dev-tools
36 qt6-tools-dev
37 qt6-tools-dev-tools
38 qt6-l10n-tools
39 qt6-declarative-dev
40
41 libqt6svg6-dev
42 libqt6svg6
43
44 libqt6waylandclient6
45 qt6-wayland
46 qt6-wayland-dev
47 qt6-wayland-dev-tools
48
49 libqca-qt6-dev
50 libqca-qt6-2
51 libqca-qt6-plugins
52
53 qtkeychain-qt6-dev
54 test_wayland_packages: >-
55 kwin-wayland
56 kwin-wayland-backend-virtual
57 libwayland-server0
58
59 QCA_VERSION: '2.3.10'
60 QTKEYCHAIN_VERSION: '0.15.0'
61
62 LINUXDEPLOY_URL: 'https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20250213-2/linuxdeploy-x86_64.AppImage'
63 LINUXDEPLOY_SHA256: '4648f278ab3ef31f819e67c30d50f462640e5365a77637d7e6f2ad9fd0b4522a'
64 LINUXDEPLOY_PLUGIN_QT_URL: 'https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/1-alpha-20250213-1/linuxdeploy-plugin-qt-x86_64.AppImage'
65 LINUXDEPLOY_PLUGIN_QT_SHA256: '15106be885c1c48a021198e7e1e9a48ce9d02a86dd0a1848f00bdbf3c1c92724'
66 LINUXDEPLOY_PLUGIN_APPIMAGE_URL: 'https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/1-alpha-20250213-1/linuxdeploy-plugin-appimage-x86_64.AppImage'
67 LINUXDEPLOY_PLUGIN_APPIMAGE_SHA256: '992d502a248e14ab185448ddf6f6e7d25558cb84d4623c354c3af350c25fccb3'
68
69 jobs:
70 build:
71 permissions:
72 contents: read
73 name: ${{matrix.buildname}}
74 runs-on: ${{matrix.os}}
75 strategy:
76 # Avoid canceling all jobs on transient failures.
77 fail-fast: false
78 matrix:
79 include:
80 - os: ubuntu-latest
81 buildname: Qt 6
82 compiler: g++
83 compiler_package: g++
84 custom_qt: '6.10.2'
85 with_native_notifications: false
86 with_kf6_wayland_clipboard: false
87 has_webp: false
88 coverage: true
89 cmake_preset: Debug
90 compiler_flags: >-
91 --coverage
92 -fprofile-arcs
93 -ftest-coverage
94 -fprofile-abs-path
95 -fprofile-update=atomic
96 test_wayland: true
97 test_gnome: true
98 test_x11: true
99
100 - os: ubuntu-latest
101 buildname: Qt 6 Clang
102 compiler: clang++
103 compiler_package: clang
104 with_native_notifications: false
105 with_kf6_wayland_clipboard: false
106 has_webp: false
107 cmake_preset: Debug
108 test_x11: true
109
110 # Pinned to ubuntu-24.04: KDE Neon repo below uses 'noble' (24.04 codename).
111 - os: ubuntu-24.04
112 buildname: AppImage
113 compiler: g++
114 compiler_package: g++
115 with_native_notifications: true
116 with_kf6_wayland_clipboard: true
117 has_webp: true
118 cmake_preset: AppImage-Release
119 appimage: true
120 test_wayland: true
121 test_x11: true
122 steps:
123 - name: Checkout source code
124 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
125 with:
126 submodules: false
127 persist-credentials: false
128 # Full commit history needed for sortable version string (git describe in CMake).
129 # Blobless filter skips file content for historical commits to speed up clone.
130 fetch-depth: 0
131 filter: blob:none
132
133 - name: Enable ccache
134 uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
135 with:
136 key: ${{ github.job }}-${{ matrix.os }}
137
138 - name: Set up ccache
139 run: |
140 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
141
142 - name: Set up KDE Neon repo for KF6 packages
143 if: matrix.with_native_notifications || matrix.with_kf6_wayland_clipboard
144 run: |
145 sudo gpg --dearmor -o /usr/share/keyrings/neon-archive-keyring.gpg \
146 utils/github/kde-neon-public.key
147 echo "deb [signed-by=/usr/share/keyrings/neon-archive-keyring.gpg] https://archive.neon.kde.org/stable noble main" |
148 sudo tee /etc/apt/sources.list.d/neon.list
149
150 - name: Install dependencies
151 env:
152 PACKAGES: >-
153 ${{ matrix.compiler_package }}
154 ${{ env.common_packages }}
155 ${{ !matrix.custom_qt && env.qt6_packages || '' }}
156 ${{ matrix.coverage && 'lcov' || '' }}
157 ${{ matrix.test_wayland && env.test_wayland_packages || '' }}
158 ${{ matrix.custom_qt && 'libssl-dev libsecret-1-dev pkg-config' || '' }}
159 ${{ matrix.coverage && 'procps' || '' }}
160 ${{ matrix.test_gnome && 'gnome-shell gnome-shell-common glib2.0-bin' || '' }}
161 ${{ matrix.with_native_notifications && 'libkf6notifications-dev kf6-kstatusnotifieritem-dev' || '' }}
162 ${{ matrix.with_kf6_wayland_clipboard && 'libkf6guiaddons-dev' || '' }}
163 ${{ matrix.appimage && 'libfuse2t64' || '' }}
164 RETRY_COUNT: "4"
165 RETRY_INITIAL_DELAY_SECONDS: "10"
166 run: |
167 retry() {
168 local delay="$RETRY_INITIAL_DELAY_SECONDS"
169 local attempts=$((RETRY_COUNT + 1))
170 for attempt in $(seq 0 "$RETRY_COUNT"); do
171 if [ "$attempt" -gt 0 ]; then sleep "$delay"; delay=$((delay * 2)); fi
172 if "$@"; then return 0; fi
173 echo "::warning::Command failed (attempt $attempt/$attempts)"
174 done
175 echo "::error::Command failed after $attempts attempts"
176 return 1
177 }
178 retry sudo apt-get update -y
179 install_packages() {
180 echo "$PACKAGES" | xargs sudo apt-get install -y --no-install-recommends
181 }
182 retry install_packages
183
184 - name: Install Qt
185 if: matrix.custom_qt
186 uses: jurplel/install-qt-action@48d3ad6db93f3627c8ee7a0454bc6f3744f7e730 # v4
187 with:
188 version: ${{ matrix.custom_qt }}
189 modules: qt5compat
190
191 - name: Build QCA and QtKeychain
192 if: matrix.custom_qt
193 run: |
194 set -e
195 git clone --depth 1 --branch v${{ env.QCA_VERSION }} https://github.com/KDE/qca.git /tmp/qca
196 cmake -G Ninja -S /tmp/qca -B /tmp/qca-build \
197 -DCMAKE_BUILD_TYPE=Release \
198 -DCMAKE_INSTALL_PREFIX=/usr/local \
199 -DBUILD_WITH_QT6=ON \
200 -DBUILD_TESTS=OFF \
201 -DBUILD_TOOLS=OFF \
202 -DBUILD_PLUGINS=ossl
203 cmake --build /tmp/qca-build --parallel
204 sudo cmake --install /tmp/qca-build
205
206 git clone --depth 1 --branch ${{ env.QTKEYCHAIN_VERSION }} https://github.com/frankosterfeld/qtkeychain.git /tmp/qtkeychain
207 cmake -G Ninja -S /tmp/qtkeychain -B /tmp/qtkeychain-build \
208 -DCMAKE_BUILD_TYPE=Release \
209 -DCMAKE_INSTALL_PREFIX=/usr/local \
210 -DBUILD_WITH_QT6=ON \
211 -DBUILD_TRANSLATIONS=OFF
212 cmake --build /tmp/qtkeychain-build --parallel
213 sudo cmake --install /tmp/qtkeychain-build
214
215 echo "LD_LIBRARY_PATH=/usr/local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
216
217 - name: Download miniaudio
218 uses: ./.github/actions/download-miniaudio
219
220 - name: Build with CMake
221 run: |
222 cmake --preset '${{ matrix.cmake_preset }}' \
223 -DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
224 -DCMAKE_CXX_FLAGS="${{matrix.compiler_flags}}" \
225 -DCMAKE_C_FLAGS="${{matrix.compiler_flags}}" \
226 -DWITH_NATIVE_NOTIFICATIONS=${{matrix.with_native_notifications}}
227 cmake --build --preset '${{ matrix.cmake_preset }}'
228
229 - name: Create gnupg directory for tests
230 run: mkdir -p ~/.gnupg && chmod go-rwx ~/.gnupg
231
232 - name: Set up test environment
233 run: |
234 echo "COPYQ_TESTS_EXECUTABLE=${{github.workspace}}/_install/copyq/${{ matrix.cmake_preset }}/bin/copyq" >> "$GITHUB_ENV"
235 echo "COPYQ_TESTS_SKIP_WEBP=${{ !matrix.has_webp && 1 || 0 }}" >> "$GITHUB_ENV"
236
237 - name: Set up AppImage tools
238 if: matrix.appimage
239 run: |
240 mkdir -p "$HOME/.local/bin"
241 dest="$HOME/.local/bin"
242
243 wget -q -O "$dest/linuxdeploy" "$LINUXDEPLOY_URL"
244 echo "$LINUXDEPLOY_SHA256 $dest/linuxdeploy" | sha256sum -c
245
246 wget -q -O "$dest/linuxdeploy-plugin-qt" "$LINUXDEPLOY_PLUGIN_QT_URL"
247 echo "$LINUXDEPLOY_PLUGIN_QT_SHA256 $dest/linuxdeploy-plugin-qt" | sha256sum -c
248
249 wget -q -O "$dest/linuxdeploy-plugin-appimage" "$LINUXDEPLOY_PLUGIN_APPIMAGE_URL"
250 echo "$LINUXDEPLOY_PLUGIN_APPIMAGE_SHA256 $dest/linuxdeploy-plugin-appimage" | sha256sum -c
251
252 chmod +x "$dest"/linuxdeploy*
253 echo "$dest" >> "$GITHUB_PATH"
254
255 - name: Get version string
256 if: matrix.appimage
257 id: version
258 uses: ./.github/actions/get-version
259 with:
260 build_dir: ${{ github.workspace }}/build/copyq/${{ matrix.cmake_preset }}
261
262 - name: Create AppImage
263 if: matrix.appimage
264 env:
265 DESTDIR: ${{github.workspace}}/AppDir
266 EXTRA_QT_MODULES: svg;tls
267 EXTRA_PLATFORM_PLUGINS: libqwayland.so
268 QMAKE: qmake6
269 VERSION: ${{ steps.version.outputs.version }}
270 run: |
271 DESTDIR="$DESTDIR" cmake --install build/copyq/${{ matrix.cmake_preset }}
272
273 # Bundle Qt/KF6 plugin directories that linuxdeploy-plugin-qt does
274 # not detect automatically.
275 qt_plugins="$(qmake6 -query QT_INSTALL_PLUGINS)"
276 deps_only_flags=()
277 for dir in \
278 kf6/kwindowsystem \
279 wayland-shell-integration \
280 wayland-decoration-client \
281 wayland-graphics-integration-client \
282 ; do
283 src="$qt_plugins/$dir"
284 dst="$DESTDIR/usr/plugins/$dir"
285 if [ -d "$src" ]; then
286 mkdir -p "$dst"
287 cp -a "$src"/*.so "$dst/"
288 deps_only_flags+=(--deploy-deps-only "$dst")
289 fi
290 done
291
292 # Bundle QCA ossl plugin. Its location varies across distros
293 # (e.g. lib/qca-qt6/crypto, lib64/qt6/plugins/crypto).
294 mkdir -p "$DESTDIR/usr/plugins/crypto"
295 qca_ossl=$(find /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu \
296 -name 'libqca-ossl.so' -print -quit 2>/dev/null)
297 if [ -z "$qca_ossl" ]; then
298 echo "::error::QCA ossl plugin (libqca-ossl.so) not found"
299 exit 1
300 fi
301 echo "Found QCA ossl plugin: $qca_ossl"
302 cp -a "$qca_ossl" "$DESTDIR/usr/plugins/crypto/"
303 deps_only_flags+=(--deploy-deps-only "$DESTDIR/usr/plugins/crypto")
304
305 linuxdeploy --appdir "$DESTDIR" \
306 --desktop-file "$DESTDIR/usr/share/applications/com.github.hluk.copyq.desktop" \
307 --icon-file "$DESTDIR/usr/share/icons/hicolor/scalable/apps/copyq.svg" \
308 --executable "$DESTDIR/usr/bin/copyq" \
309 "${deps_only_flags[@]}" \
310 --plugin qt \
311 --output appimage
312
313 - name: Upload AppImage
314 if: matrix.appimage
315 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
316 with:
317 path: CopyQ-*.AppImage
318 archive: false
319
320 - name: Smoke-test AppImage
321 if: matrix.appimage
322 run: '"$APPIMAGE" --version'
323 env:
324 APPIMAGE: ${{github.workspace}}/CopyQ-${{ steps.version.outputs.version }}-x86_64.AppImage
325
326 - name: Set up AppImage for tests
327 if: matrix.appimage
328 run: |
329 echo "COPYQ_TESTS_EXECUTABLE=$APPIMAGE" >> "$GITHUB_ENV"
330 env:
331 APPIMAGE: ${{github.workspace}}/CopyQ-${{ steps.version.outputs.version }}-x86_64.AppImage
332
333 - name: Test on GNOME
334 working-directory: >-
335 ${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}
336 if: matrix.test_gnome
337 run: '${{github.workspace}}/utils/github/test-linux-gnome-extension.sh'
338
339 - name: Test on Wayland
340 working-directory: >-
341 ${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}
342 if: matrix.test_wayland
343 run: '${{github.workspace}}/utils/github/test-linux-wayland.sh'
344
345 - name: Test on X11
346 working-directory: >-
347 ${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}
348 if: matrix.test_x11 && !matrix.appimage
349 run: '${{github.workspace}}/utils/github/test-linux.sh'
350
351 - name: Test on X11 (AppImage)
352 working-directory: >-
353 ${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}
354 if: matrix.test_x11 && matrix.appimage
355 run: |
356 ${{github.workspace}}/utils/github/test-linux.sh \
357 testCore:clipboardToItem \
358 testCore:itemToClipboard \
359 testCore:commandClipboard \
360 testCore:commandHasClipboardFormat \
361 testCore:tabEncryption \
362 testCore:tabEncryptionPasswordNew \
363 testCore:tabEncryptionPasswordCurrent \
364 testCore:expireEncryptionPassword
365
366 ${{github.workspace}}/utils/github/test-linux.sh testItemEncrypted
367
368 - name: Update coverage
369 if: matrix.coverage
370 working-directory: >-
371 ${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}
372 run: |
373 lcov --capture --directory . \
374 --base-directory '${{github.workspace}}' \
375 --no-external \
376 --rc branch_coverage=1 \
377 --rc geninfo_no_exception_branch=1 \
378 --output-file coverage-full.info
379 # Remove 3rd party files in source tree
380 lcov --remove coverage-full.info \
381 '*/plugins/itemfakevim/fakevim/*' \
382 '*/src/gui/fix_icon_id.h' \
383 --output-file coverage.info
384
385 - name: Upload coverage to Codecov
386 if: matrix.coverage
387 uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5
388 with:
389 files: ${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}/coverage.info
390 fail_ci_if_error: true
391 verbose: true
392 token: ${{ secrets.CODECOV_TOKEN }}
393
394 release:
395 if: startsWith(github.ref, 'refs/tags/v')
396 needs: build
397 runs-on: ubuntu-latest
398 permissions:
399 contents: write
400 steps:
401 - name: Download artifacts
402 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
403 with:
404 pattern: 'CopyQ-*.AppImage'
405
406 - name: Upload to release
407 run: |
408 gh release create "$GITHUB_REF_NAME" --draft --notes "" 2>/dev/null || true
409 gh release upload "$GITHUB_REF_NAME" CopyQ-*/*.AppImage --clobber
410 env:
411 GH_TOKEN: ${{ github.token }}
412 GH_REPO: ${{ github.repository }}