cmake.yml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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]
  107. variant: [kde, generic]
  108. include:
  109. - distro: fedora-44
  110. image: fedora:44
  111. install: >-
  112. dnf -y install git gcc gcc-c++ make cmake pkgconf-pkg-config binutils tar gzip
  113. libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel libXxf86vm-devel
  114. mesa-libGL-devel mesa-libEGL-devel glew-devel freeglut-devel sdl2-compat-devel lz4-devel
  115. zlib-ng-compat-devel ffmpeg-free-devel glm-devel glfw-devel mpv-devel pulseaudio-libs-devel
  116. freetype-devel harfbuzz-devel dbus-devel wayland-devel wayland-protocols-devel fftw-devel gmp-devel
  117. nodejs24-devel
  118. runs-on: ubuntu-24.04
  119. container: ${{ matrix.image }}
  120. steps:
  121. # git has to be there before checkout, otherwise it falls back to a tarball without submodules
  122. - name: Install dependencies
  123. run: ${{ matrix.install }}
  124. - uses: actions/checkout@v7
  125. with:
  126. submodules: true
  127. - name: Configure CMake
  128. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  129. - name: Build
  130. run: cmake --build build --parallel $(nproc)
  131. - name: Package
  132. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64 "$RUNNER_TEMP"
  133. - uses: actions/upload-artifact@v7
  134. with:
  135. name: linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}
  136. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64.tar.gz
  137. if-no-files-found: error
  138. release:
  139. needs: [build, distro-build]
  140. if: startsWith(github.ref, 'refs/tags/')
  141. runs-on: ubuntu-latest
  142. permissions:
  143. contents: write
  144. steps:
  145. - uses: actions/checkout@v7
  146. - uses: actions/download-artifact@v8
  147. with:
  148. path: release
  149. merge-multiple: true
  150. - name: Upload to the release
  151. env:
  152. GH_TOKEN: ${{ github.token }}
  153. run: |
  154. # a release made on GitHub already exists, a manual run on a bare tag has none yet
  155. if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
  156. gh release upload "$GITHUB_REF_NAME" --clobber release/*.tar.gz
  157. else
  158. gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes release/*.tar.gz
  159. fi
  160. clang-build:
  161. needs: tests
  162. permissions:
  163. actions: read
  164. contents: read
  165. security-events: write
  166. strategy:
  167. matrix:
  168. build_type: [Debug, Release]
  169. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  170. # You can convert this to a matrix build if you need cross-platform coverage.
  171. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  172. runs-on: ubuntu-24.04
  173. steps:
  174. - uses: actions/checkout@v7
  175. with:
  176. submodules: true
  177. - name: ccache
  178. uses: hendrikmuhs/ccache-action@v1.2.24
  179. with:
  180. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  181. - name: Install dependencies
  182. 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
  183. - name: Configure CMake
  184. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  185. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  186. 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++
  187. - name: Build
  188. # Build your program with the given configuration
  189. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose