cmake.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. name: CMake
  2. on:
  3. release:
  4. types: [ published ]
  5. workflow_dispatch:
  6. jobs:
  7. formatting:
  8. name: Formatting check
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v7
  12. - name: Run clang-format style check for C/C++ programs.
  13. uses: jidicula/clang-format-action@v4.18.0
  14. with:
  15. check-path: "src"
  16. exclude-regex: "(src/External)"
  17. - run: echo "Formatted with clang-format version ${{ steps.clang-format.outputs.clang-format-version }}"
  18. tests:
  19. #needs: formatting
  20. env:
  21. BUILD_TYPE: Release
  22. strategy:
  23. matrix:
  24. os: [ubuntu-24.04]
  25. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  26. # You can convert this to a matrix build if you need cross-platform coverage.
  27. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  28. runs-on: ${{ matrix.os }}
  29. steps:
  30. - uses: actions/checkout@v7
  31. with:
  32. submodules: true
  33. # cache some build information
  34. - name: ccache
  35. uses: hendrikmuhs/ccache-action@v1.2.24
  36. with:
  37. key: ${{ github.job }}-${{ matrix.os }}
  38. - name: Install dependencies
  39. run: sudo apt-get update && sudo apt-get -y install libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libfftw3-dev libfreetype-dev libdbus-1-dev libnode-dev
  40. - name: Configure CMake
  41. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  42. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  43. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=1 -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  44. - name: Build
  45. # Build your program with the given configuration
  46. run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target tests --verbose
  47. - name: Run tests
  48. # Run the unit tests available
  49. run: ${{github.workspace}}/build/output/tests
  50. build:
  51. needs: tests
  52. permissions:
  53. actions: read
  54. contents: read
  55. security-events: write
  56. strategy:
  57. matrix:
  58. include:
  59. - build_type: Release
  60. variant: kde
  61. disable_kde: 'OFF'
  62. - build_type: Release
  63. variant: generic
  64. disable_kde: 'ON'
  65. - build_type: Debug
  66. variant: kde
  67. disable_kde: 'OFF'
  68. runs-on: ubuntu-24.04
  69. steps:
  70. - uses: actions/checkout@v7
  71. with:
  72. submodules: true
  73. - name: ccache
  74. uses: hendrikmuhs/ccache-action@v1.2.24
  75. with:
  76. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}-${{ matrix.variant }}
  77. - name: Initialize CodeQL
  78. # Initializes the CodeQL tools for scanning.
  79. uses: github/codeql-action/init@v4
  80. if: ${{ matrix.build_type == 'Debug' }}
  81. with:
  82. languages: 'cpp'
  83. - name: Install dependencies
  84. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev libdbus-1-dev libnode-dev wayland-scanner++ wayland-protocols libwayland-dev
  85. - name: Configure CMake
  86. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DDISABLE_KDE_FEATURES=${{matrix.disable_kde}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  87. - name: Build
  88. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --parallel $(nproc) --verbose
  89. - name: Perform CodeQL Analysis
  90. if: ${{ matrix.build_type == 'Debug' }}
  91. uses: github/codeql-action/analyze@v4
  92. - name: Package
  93. if: ${{ matrix.build_type == 'Release' }}
  94. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64 "$RUNNER_TEMP"
  95. - uses: actions/upload-artifact@v7
  96. if: ${{ matrix.build_type == 'Release' }}
  97. with:
  98. name: linux-wallpaperengine-${{ matrix.variant }}
  99. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64.tar.gz
  100. if-no-files-found: error
  101. distro-build:
  102. needs: tests
  103. strategy:
  104. fail-fast: false
  105. matrix:
  106. distro: [fedora-44, arch]
  107. variant: [kde, generic]
  108. include:
  109. - distro: arch
  110. image: archlinux:latest
  111. # libnode itself comes from the AUR below, these are its dependencies plus CEF's
  112. install: >-
  113. pacman -Syu --noconfirm --needed git base-devel curl cmake glew freeglut sdl2-compat lz4 zlib ffmpeg glm
  114. glfw mpv libpulse freetype2 harfbuzz dbus wayland wayland-protocols mesa libxrandr libxinerama
  115. libxcursor libxi libxxf86vm fftw gmp nss at-spi2-core libcups libxcomposite libxdamage libxkbcommon
  116. pango cairo alsa-lib libdrm libxshmfence ada brotli c-ares icu libffi libnghttp2 libnghttp3 libngtcp2
  117. libuv openssl simdjson zstd ninja procps-ng python
  118. - distro: fedora-44
  119. image: fedora:44
  120. install: >-
  121. dnf -y install git gcc gcc-c++ make cmake pkgconf-pkg-config binutils tar gzip
  122. libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel libXxf86vm-devel
  123. mesa-libGL-devel mesa-libEGL-devel glew-devel freeglut-devel sdl2-compat-devel lz4-devel
  124. zlib-ng-compat-devel ffmpeg-free-devel glm-devel glfw-devel mpv-devel pulseaudio-libs-devel
  125. freetype-devel harfbuzz-devel dbus-devel wayland-devel wayland-protocols-devel fftw-devel gmp-devel
  126. nodejs24-devel
  127. runs-on: ubuntu-24.04
  128. container: ${{ matrix.image }}
  129. steps:
  130. # git has to be there before checkout, otherwise it falls back to a tarball without submodules
  131. - name: Install dependencies
  132. run: ${{ matrix.install }}
  133. # Arch has V8's shared library only in the AUR (libnode, Node.js built with --shared): build it once per
  134. # package version and cache the package. LTO is off, makepkg's own -flto without node's --enable-lto handling
  135. # loses V8's assembly stack scanner at link time
  136. - name: Fetch libnode PKGBUILD
  137. if: matrix.distro == 'arch'
  138. id: libnode
  139. run: |
  140. mkdir -p /tmp/libnode
  141. curl -fsSL "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=libnode" -o /tmp/libnode/PKGBUILD
  142. sed -i -e '/--enable-lto/d' -e "/^makedepends=/i options=('!lto')" /tmp/libnode/PKGBUILD
  143. # parsed, not sourced (that would run AUR code as root); the hash keeps a changed PKGBUILD off old caches
  144. pkgver="$(sed -n 's/^pkgver=//p' /tmp/libnode/PKGBUILD | tr -d "'\"")"
  145. pkgrel="$(sed -n 's/^pkgrel=//p' /tmp/libnode/PKGBUILD | tr -d "'\"")"
  146. [ -n "$pkgver" ] && [ -n "$pkgrel" ] || { echo "no pkgver/pkgrel in the libnode PKGBUILD" >&2; exit 1; }
  147. echo "version=$pkgver-$pkgrel-$(sha256sum /tmp/libnode/PKGBUILD | cut -c1-12)" >> "$GITHUB_OUTPUT"
  148. - name: Cache libnode package
  149. if: matrix.distro == 'arch'
  150. id: libnode-cache
  151. uses: actions/cache@v4
  152. with:
  153. path: /tmp/libnode-pkg
  154. key: libnode-${{ steps.libnode.outputs.version }}-nolto
  155. - name: Build libnode
  156. if: matrix.distro == 'arch' && steps.libnode-cache.outputs.cache-hit != 'true'
  157. run: |
  158. useradd -m builder
  159. chown -R builder /tmp/libnode
  160. su builder -c 'cd /tmp/libnode && makepkg --noconfirm --nodeps'
  161. mkdir -p /tmp/libnode-pkg
  162. cp /tmp/libnode/libnode-[0-9]*.pkg.tar.zst /tmp/libnode-pkg/
  163. - name: Install libnode
  164. if: matrix.distro == 'arch'
  165. run: pacman -U --noconfirm /tmp/libnode-pkg/libnode-[0-9]*.pkg.tar.zst
  166. # the smoke test installs it into a fresh Arch container
  167. - uses: actions/upload-artifact@v7
  168. if: matrix.distro == 'arch' && matrix.variant == 'kde'
  169. with:
  170. name: libnode-arch
  171. path: /tmp/libnode-pkg/libnode-[0-9]*.pkg.tar.zst
  172. if-no-files-found: error
  173. - uses: actions/checkout@v7
  174. with:
  175. submodules: true
  176. - name: Configure CMake
  177. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  178. - name: Build
  179. run: cmake --build build --parallel $(nproc)
  180. - name: Package
  181. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64 "$RUNNER_TEMP"
  182. - uses: actions/upload-artifact@v7
  183. with:
  184. name: linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}
  185. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64.tar.gz
  186. if-no-files-found: error
  187. # one tarball for every distribution: built on Debian 12 (glibc 2.36, the oldest base with FFmpeg 5.1 and a
  188. # V8 >= 10.2 libnode), every library that isn't the system's bundled, glibc floor 2.35 (Ubuntu 22.04), see
  189. # tools/package_release.sh
  190. portable:
  191. needs: tests
  192. strategy:
  193. matrix:
  194. variant: [kde, generic]
  195. runs-on: ubuntu-24.04
  196. container: debian:12
  197. steps:
  198. - name: Install dependencies
  199. env:
  200. DEBIAN_FRONTEND: noninteractive
  201. run: >-
  202. apt-get update && apt-get -y install --no-install-recommends git ca-certificates curl build-essential
  203. cmake pkg-config patchelf python3 binutils libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
  204. libgl-dev libegl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev
  205. libavutil-dev libswscale-dev libswresample-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev
  206. libpulse-dev libfftw3-dev libfreetype-dev libharfbuzz-dev libdbus-1-dev libnode-dev libwayland-dev
  207. wayland-protocols libgmp-dev libnss3 libnspr4 libcups2 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1
  208. libxdamage1 libgbm1 libxkbcommon0 libasound2 libpango-1.0-0 libcairo2 libdrm2 libxshmfence1
  209. libatspi2.0-0
  210. - uses: actions/checkout@v7
  211. with:
  212. submodules: true
  213. - name: Configure CMake
  214. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  215. - name: Build
  216. run: cmake --build build --parallel $(nproc)
  217. - name: Package
  218. run: tools/package_release.sh --portable build linux-wallpaperengine-${{ matrix.variant }}-portable-x86_64 "$RUNNER_TEMP"
  219. - uses: actions/upload-artifact@v7
  220. with:
  221. name: linux-wallpaperengine-${{ matrix.variant }}-portable
  222. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-portable-x86_64.tar.gz
  223. if-no-files-found: error
  224. # every release tarball unpacked in a bare container of the distributions it is meant for: libraries resolve
  225. # (portable: with only what a desktop has; distribution builds: plus their packages, found by soname) and
  226. # --help runs
  227. smoke:
  228. needs: [build, distro-build, portable]
  229. strategy:
  230. fail-fast: false
  231. matrix:
  232. include:
  233. - { image: 'ubuntu:22.04', tarball: kde-portable }
  234. - { image: 'ubuntu:22.04', tarball: generic-portable }
  235. - { image: 'ubuntu:24.04', tarball: kde-portable }
  236. - { image: 'ubuntu:26.04', tarball: kde-portable }
  237. - { image: 'debian:12', tarball: kde-portable }
  238. - { image: 'debian:13', tarball: kde-portable }
  239. - { image: 'fedora:43', tarball: kde-portable }
  240. - { image: 'fedora:44', tarball: kde-portable }
  241. - { image: 'fedora:45', tarball: kde-portable }
  242. - { image: 'opensuse/leap:16.0', tarball: kde-portable }
  243. - { image: 'opensuse/tumbleweed', tarball: kde-portable }
  244. - { image: 'archlinux:latest', tarball: kde-portable }
  245. - { image: 'ubuntu:24.04', tarball: kde-ubuntu-24.04 }
  246. - { image: 'fedora:44', tarball: kde-fedora-44 }
  247. - { image: 'archlinux:latest', tarball: kde-arch }
  248. runs-on: ubuntu-24.04
  249. container: ${{ matrix.image }}
  250. steps:
  251. - uses: actions/checkout@v7
  252. - uses: actions/download-artifact@v8
  253. with:
  254. # the Ubuntu build's artifact has no distribution in its name
  255. name: linux-wallpaperengine-${{ matrix.tarball == 'kde-ubuntu-24.04' && 'kde' || matrix.tarball }}
  256. path: tarball
  257. - uses: actions/download-artifact@v8
  258. if: matrix.tarball == 'kde-arch'
  259. with:
  260. name: libnode-arch
  261. path: libnode
  262. - name: Smoke test
  263. run: |
  264. libnode=(libnode/libnode-[0-9]*.pkg.tar.zst)
  265. [ -e "${libnode[0]}" ] && export LIBNODE_PKG="$PWD/${libnode[0]}"
  266. tools/smoke_test_release.sh --install-deps tarball/*.tar.gz
  267. shell: bash
  268. release:
  269. needs: [build, distro-build, portable, smoke]
  270. if: startsWith(github.ref, 'refs/tags/')
  271. runs-on: ubuntu-latest
  272. permissions:
  273. contents: write
  274. steps:
  275. - uses: actions/checkout@v7
  276. - uses: actions/download-artifact@v8
  277. with:
  278. path: release
  279. merge-multiple: true
  280. - name: Upload to the release
  281. env:
  282. GH_TOKEN: ${{ github.token }}
  283. run: |
  284. # a release made on GitHub already exists, a manual run on a bare tag has none yet
  285. if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
  286. gh release upload "$GITHUB_REF_NAME" --clobber release/*.tar.gz
  287. else
  288. gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes release/*.tar.gz
  289. fi
  290. # the -bin package points at the release's portable tarball, so it is updated after the upload
  291. aur:
  292. needs: release
  293. # pre-release tags are no valid pkgver
  294. if: ${{ !github.event.release.prerelease }}
  295. runs-on: ubuntu-latest
  296. env:
  297. HAS_AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY != '' }}
  298. steps:
  299. - uses: actions/checkout@v7
  300. - name: Set the version
  301. run: sed -i -e "s/^pkgver=.*/pkgver=${GITHUB_REF_NAME#v}/" -e "s/^pkgrel=.*/pkgrel=1/"
  302. packaging/aur/linux-wallpaperengine-kde-bin/PKGBUILD
  303. - name: Publish linux-wallpaperengine-kde-bin to the AUR
  304. if: env.HAS_AUR_KEY == 'true'
  305. uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
  306. with:
  307. pkgname: linux-wallpaperengine-kde-bin
  308. pkgbuild: ./packaging/aur/linux-wallpaperengine-kde-bin/PKGBUILD
  309. updpkgsums: true
  310. commit_username: ${{ secrets.AUR_USERNAME }}
  311. commit_email: ${{ secrets.AUR_EMAIL }}
  312. ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
  313. commit_message: Update to ${{ github.ref_name }}
  314. clang-build:
  315. needs: tests
  316. permissions:
  317. actions: read
  318. contents: read
  319. security-events: write
  320. strategy:
  321. matrix:
  322. build_type: [Debug, Release]
  323. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  324. # You can convert this to a matrix build if you need cross-platform coverage.
  325. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  326. runs-on: ubuntu-24.04
  327. steps:
  328. - uses: actions/checkout@v7
  329. with:
  330. submodules: true
  331. - name: ccache
  332. uses: hendrikmuhs/ccache-action@v1.2.24
  333. with:
  334. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  335. - name: Install dependencies
  336. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev libdbus-1-dev libnode-dev wayland-scanner++ wayland-protocols libwayland-dev
  337. - name: Configure CMake
  338. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  339. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  340. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++
  341. - name: Build
  342. # Build your program with the given configuration
  343. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose