cmake.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. # Arch has V8's shared library only in the AUR (libnode, Node.js built with --shared). Built once per package
  102. # version, independent of the tests so it overlaps them. A new version starts from the previous one's ccache.
  103. # LTO is off, makepkg's own -flto without node's --enable-lto handling loses V8's assembly stack scanner at link
  104. # time; debug is off since -g makes V8 much slower to compile
  105. libnode-arch:
  106. runs-on: ubuntu-24.04
  107. container: archlinux:latest
  108. steps:
  109. - name: Install dependencies
  110. run: >-
  111. pacman -Syu --noconfirm --needed base-devel curl ccache ada brotli c-ares icu libffi libnghttp2
  112. libnghttp3 libngtcp2 libuv openssl simdjson zlib zstd ninja procps-ng python
  113. - name: Fetch libnode PKGBUILD
  114. id: libnode
  115. run: |
  116. mkdir -p /tmp/libnode
  117. curl -fsSL "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=libnode" -o /tmp/libnode/PKGBUILD
  118. sed -i -e '/--enable-lto/d' -e "/^makedepends=/i options=('!lto' '!debug')" /tmp/libnode/PKGBUILD
  119. # parsed, not sourced (that would run AUR code as root); the hash keeps a changed PKGBUILD off old caches
  120. pkgver="$(sed -n 's/^pkgver=//p' /tmp/libnode/PKGBUILD | tr -d "'\"")"
  121. pkgrel="$(sed -n 's/^pkgrel=//p' /tmp/libnode/PKGBUILD | tr -d "'\"")"
  122. [ -n "$pkgver" ] && [ -n "$pkgrel" ] || { echo "no pkgver/pkgrel in the libnode PKGBUILD" >&2; exit 1; }
  123. echo "version=$pkgver-$pkgrel-$(sha256sum /tmp/libnode/PKGBUILD | cut -c1-12)" >> "$GITHUB_OUTPUT"
  124. - name: Restore libnode package
  125. id: libnode-cache
  126. uses: actions/cache/restore@v4
  127. with:
  128. path: /tmp/libnode-pkg
  129. key: libnode-${{ steps.libnode.outputs.version }}
  130. - name: Restore ccache
  131. if: steps.libnode-cache.outputs.cache-hit != 'true'
  132. uses: actions/cache/restore@v4
  133. with:
  134. path: /tmp/libnode-ccache
  135. key: libnode-ccache-${{ steps.libnode.outputs.version }}
  136. restore-keys: libnode-ccache-
  137. - name: Build libnode
  138. if: steps.libnode-cache.outputs.cache-hit != 'true'
  139. run: |
  140. useradd -m builder
  141. mkdir -p /tmp/libnode-ccache
  142. chown -R builder /tmp/libnode /tmp/libnode-ccache
  143. su builder -c 'export CCACHE_DIR=/tmp/libnode-ccache CCACHE_MAXSIZE=2G CCACHE_COMPILERCHECK=content
  144. PATH=/usr/lib/ccache/bin:$PATH; ccache -z; cd /tmp/libnode && makepkg --noconfirm --nodeps; ccache -s'
  145. mkdir -p /tmp/libnode-pkg
  146. cp /tmp/libnode/libnode-[0-9]*.pkg.tar.zst /tmp/libnode-pkg/
  147. # saved right away, a later failure in this run must not throw the build away
  148. - name: Save ccache
  149. if: steps.libnode-cache.outputs.cache-hit != 'true'
  150. uses: actions/cache/save@v4
  151. with:
  152. path: /tmp/libnode-ccache
  153. key: libnode-ccache-${{ steps.libnode.outputs.version }}
  154. - name: Save libnode package
  155. if: steps.libnode-cache.outputs.cache-hit != 'true'
  156. uses: actions/cache/save@v4
  157. with:
  158. path: /tmp/libnode-pkg
  159. key: libnode-${{ steps.libnode.outputs.version }}
  160. # for the Arch distribution builds and the smoke test's fresh Arch container
  161. - uses: actions/upload-artifact@v7
  162. with:
  163. name: libnode-arch
  164. path: /tmp/libnode-pkg/libnode-[0-9]*.pkg.tar.zst
  165. if-no-files-found: error
  166. distro-build:
  167. needs: [tests, libnode-arch]
  168. strategy:
  169. fail-fast: false
  170. matrix:
  171. distro: [fedora-44, arch]
  172. variant: [kde, generic]
  173. include:
  174. - distro: arch
  175. image: archlinux:latest
  176. # libnode comes from the libnode-arch job, these are its dependencies plus CEF's
  177. install: >-
  178. pacman -Syu --noconfirm --needed git base-devel curl cmake glew freeglut sdl2-compat lz4 zlib ffmpeg glm
  179. glfw mpv libpulse freetype2 harfbuzz dbus wayland wayland-protocols mesa libxrandr libxinerama
  180. libxcursor libxi libxxf86vm fftw gmp nss at-spi2-core libcups libxcomposite libxdamage libxkbcommon
  181. pango cairo alsa-lib libdrm libxshmfence ada brotli c-ares icu libffi libnghttp2 libnghttp3 libngtcp2
  182. libuv openssl simdjson zstd
  183. - distro: fedora-44
  184. image: fedora:44
  185. install: >-
  186. dnf -y install git gcc gcc-c++ make cmake pkgconf-pkg-config binutils tar gzip
  187. libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel libXxf86vm-devel
  188. mesa-libGL-devel mesa-libEGL-devel glew-devel freeglut-devel sdl2-compat-devel lz4-devel
  189. zlib-ng-compat-devel ffmpeg-free-devel glm-devel glfw-devel mpv-devel pulseaudio-libs-devel
  190. freetype-devel harfbuzz-devel dbus-devel wayland-devel wayland-protocols-devel fftw-devel gmp-devel
  191. nodejs24-devel
  192. runs-on: ubuntu-24.04
  193. container: ${{ matrix.image }}
  194. steps:
  195. # git has to be there before checkout, otherwise it falls back to a tarball without submodules
  196. - name: Install dependencies
  197. run: ${{ matrix.install }}
  198. - uses: actions/download-artifact@v8
  199. if: matrix.distro == 'arch'
  200. with:
  201. name: libnode-arch
  202. path: /tmp/libnode-pkg
  203. - name: Install libnode
  204. if: matrix.distro == 'arch'
  205. run: pacman -U --noconfirm /tmp/libnode-pkg/libnode-[0-9]*.pkg.tar.zst
  206. - uses: actions/checkout@v7
  207. with:
  208. submodules: true
  209. - name: Configure CMake
  210. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  211. - name: Build
  212. run: cmake --build build --parallel $(nproc)
  213. - name: Package
  214. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64 "$RUNNER_TEMP"
  215. - uses: actions/upload-artifact@v7
  216. with:
  217. name: linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}
  218. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64.tar.gz
  219. if-no-files-found: error
  220. # one tarball for every distribution: built on Debian 12 (glibc 2.36, the oldest base with FFmpeg 5.1 and a
  221. # V8 >= 10.2 libnode), every library that isn't the system's bundled, glibc floor 2.35 (Ubuntu 22.04), see
  222. # tools/package_release.sh
  223. portable:
  224. needs: tests
  225. strategy:
  226. matrix:
  227. variant: [kde, generic]
  228. runs-on: ubuntu-24.04
  229. container: debian:12
  230. steps:
  231. - name: Install dependencies
  232. env:
  233. DEBIAN_FRONTEND: noninteractive
  234. run: >-
  235. apt-get update && apt-get -y install --no-install-recommends git ca-certificates curl build-essential
  236. cmake pkg-config patchelf python3 binutils libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
  237. libgl-dev libegl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev
  238. libavutil-dev libswscale-dev libswresample-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev
  239. libpulse-dev libfftw3-dev libfreetype-dev libharfbuzz-dev libdbus-1-dev libnode-dev libwayland-dev
  240. wayland-protocols libgmp-dev libnss3 libnspr4 libcups2 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1
  241. libxdamage1 libgbm1 libxkbcommon0 libasound2 libpango-1.0-0 libcairo2 libdrm2 libxshmfence1
  242. libatspi2.0-0
  243. - uses: actions/checkout@v7
  244. with:
  245. submodules: true
  246. - name: Configure CMake
  247. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  248. - name: Build
  249. run: cmake --build build --parallel $(nproc)
  250. - name: Package
  251. run: tools/package_release.sh --portable build linux-wallpaperengine-${{ matrix.variant }}-portable-x86_64 "$RUNNER_TEMP"
  252. - uses: actions/upload-artifact@v7
  253. with:
  254. name: linux-wallpaperengine-${{ matrix.variant }}-portable
  255. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-portable-x86_64.tar.gz
  256. if-no-files-found: error
  257. # every release tarball unpacked in a bare container of the distributions it is meant for: libraries resolve
  258. # (portable: with only what a desktop has; distribution builds: plus their packages, found by soname) and
  259. # --help runs
  260. smoke:
  261. needs: [build, distro-build, portable]
  262. strategy:
  263. fail-fast: false
  264. matrix:
  265. include:
  266. - { image: 'ubuntu:22.04', tarball: kde-portable }
  267. - { image: 'ubuntu:22.04', tarball: generic-portable }
  268. - { image: 'ubuntu:24.04', tarball: kde-portable }
  269. - { image: 'ubuntu:26.04', tarball: kde-portable }
  270. - { image: 'debian:12', tarball: kde-portable }
  271. - { image: 'debian:13', tarball: kde-portable }
  272. - { image: 'fedora:43', tarball: kde-portable }
  273. - { image: 'fedora:44', tarball: kde-portable }
  274. - { image: 'fedora:45', tarball: kde-portable }
  275. - { image: 'opensuse/leap:16.0', tarball: kde-portable }
  276. - { image: 'opensuse/tumbleweed', tarball: kde-portable }
  277. - { image: 'archlinux:latest', tarball: kde-portable }
  278. - { image: 'ubuntu:24.04', tarball: kde-ubuntu-24.04 }
  279. - { image: 'fedora:44', tarball: kde-fedora-44 }
  280. - { image: 'archlinux:latest', tarball: kde-arch }
  281. runs-on: ubuntu-24.04
  282. container: ${{ matrix.image }}
  283. steps:
  284. - uses: actions/checkout@v7
  285. - uses: actions/download-artifact@v8
  286. with:
  287. # the Ubuntu build's artifact has no distribution in its name
  288. name: linux-wallpaperengine-${{ matrix.tarball == 'kde-ubuntu-24.04' && 'kde' || matrix.tarball }}
  289. path: tarball
  290. - uses: actions/download-artifact@v8
  291. if: matrix.tarball == 'kde-arch'
  292. with:
  293. name: libnode-arch
  294. path: libnode
  295. - name: Smoke test
  296. run: |
  297. libnode=(libnode/libnode-[0-9]*.pkg.tar.zst)
  298. [ -e "${libnode[0]}" ] && export LIBNODE_PKG="$PWD/${libnode[0]}"
  299. tools/smoke_test_release.sh --install-deps tarball/*.tar.gz
  300. shell: bash
  301. release:
  302. needs: [build, distro-build, portable, smoke]
  303. if: startsWith(github.ref, 'refs/tags/')
  304. runs-on: ubuntu-latest
  305. permissions:
  306. contents: write
  307. steps:
  308. - uses: actions/checkout@v7
  309. - uses: actions/download-artifact@v8
  310. with:
  311. path: release
  312. merge-multiple: true
  313. - name: Upload to the release
  314. env:
  315. GH_TOKEN: ${{ github.token }}
  316. run: |
  317. # a release made on GitHub already exists, a manual run on a bare tag has none yet
  318. if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
  319. gh release upload "$GITHUB_REF_NAME" --clobber release/*.tar.gz
  320. else
  321. gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes release/*.tar.gz
  322. fi
  323. # the -bin package points at the release's portable tarball, so it is updated after the upload
  324. aur:
  325. needs: release
  326. # pre-release tags are no valid pkgver
  327. if: ${{ !github.event.release.prerelease }}
  328. runs-on: ubuntu-latest
  329. env:
  330. HAS_AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY != '' }}
  331. steps:
  332. - uses: actions/checkout@v7
  333. - name: Set the version
  334. run: sed -i -e "s/^pkgver=.*/pkgver=${GITHUB_REF_NAME#v}/" -e "s/^pkgrel=.*/pkgrel=1/"
  335. packaging/aur/linux-wallpaperengine-kde-bin/PKGBUILD
  336. - name: Publish linux-wallpaperengine-kde-bin to the AUR
  337. if: env.HAS_AUR_KEY == 'true'
  338. uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
  339. with:
  340. pkgname: linux-wallpaperengine-kde-bin
  341. pkgbuild: ./packaging/aur/linux-wallpaperengine-kde-bin/PKGBUILD
  342. updpkgsums: true
  343. commit_username: ${{ secrets.AUR_USERNAME }}
  344. commit_email: ${{ secrets.AUR_EMAIL }}
  345. ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
  346. commit_message: Update to ${{ github.ref_name }}
  347. clang-build:
  348. needs: tests
  349. permissions:
  350. actions: read
  351. contents: read
  352. security-events: write
  353. strategy:
  354. matrix:
  355. build_type: [Debug, Release]
  356. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  357. # You can convert this to a matrix build if you need cross-platform coverage.
  358. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  359. runs-on: ubuntu-24.04
  360. steps:
  361. - uses: actions/checkout@v7
  362. with:
  363. submodules: true
  364. - name: ccache
  365. uses: hendrikmuhs/ccache-action@v1.2.24
  366. with:
  367. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  368. - name: Install dependencies
  369. 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
  370. - name: Configure CMake
  371. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  372. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  373. 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++
  374. - name: Build
  375. # Build your program with the given configuration
  376. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose