cmake.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. name: CMake
  2. on:
  3. push:
  4. paths:
  5. - '.github/workflows/cmake.yml'
  6. - 'src/**'
  7. - 'CMakeModules/**'
  8. - CMakeLists.txt
  9. - 'protocols/**'
  10. branches: [ main ]
  11. pull_request:
  12. paths:
  13. - '.github/workflows/cmake.yml'
  14. - 'src/**'
  15. - 'CMakeModules/**'
  16. - CMakeLists.txt
  17. - 'protocols/**'
  18. branches: [ main ]
  19. workflow_dispatch:
  20. jobs:
  21. formatting:
  22. name: Formatting check
  23. runs-on: ubuntu-latest
  24. steps:
  25. - uses: actions/checkout@v4
  26. - name: Run clang-format style check for C/C++ programs.
  27. uses: jidicula/clang-format-action@v4.18.0
  28. with:
  29. check-path: "src"
  30. exclude-regex: "(src/External)"
  31. - run: echo "Formatted with clang-format version ${{ steps.clang-format.outputs.clang-format-version }}"
  32. tests:
  33. #needs: formatting
  34. env:
  35. BUILD_TYPE: Release
  36. strategy:
  37. matrix:
  38. os: [ubuntu-24.04]
  39. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  40. # You can convert this to a matrix build if you need cross-platform coverage.
  41. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  42. runs-on: ${{ matrix.os }}
  43. steps:
  44. - uses: actions/checkout@v3
  45. with:
  46. submodules: true
  47. # cache some build information
  48. - name: ccache
  49. uses: hendrikmuhs/ccache-action@v1.2
  50. with:
  51. key: ${{ github.job }}-${{ matrix.os }}
  52. - name: Install dependencies
  53. 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
  54. - name: Configure CMake
  55. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  56. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  57. 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
  58. - name: Build
  59. # Build your program with the given configuration
  60. run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target tests --verbose
  61. - name: Run tests
  62. # Run the unit tests available
  63. run: ${{github.workspace}}/build/output/tests
  64. build:
  65. needs: tests
  66. permissions:
  67. actions: read
  68. contents: read
  69. security-events: write
  70. strategy:
  71. matrix:
  72. build_type: [Release, Debug]
  73. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  74. # You can convert this to a matrix build if you need cross-platform coverage.
  75. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  76. runs-on: ubuntu-24.04
  77. steps:
  78. - uses: actions/checkout@v3
  79. with:
  80. submodules: true
  81. - name: ccache
  82. uses: hendrikmuhs/ccache-action@v1.2
  83. with:
  84. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  85. - name: Initialize CodeQL
  86. # Initializes the CodeQL tools for scanning.
  87. uses: github/codeql-action/init@v3
  88. if: ${{ matrix.build_type == 'Debug' }}
  89. with:
  90. languages: 'cpp'
  91. - name: Install dependencies
  92. 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 wayland-scanner++ wayland-protocols libwayland-dev
  93. - name: Configure CMake
  94. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  95. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  96. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  97. - name: Build
  98. # Build your program with the given configuration
  99. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose
  100. - name: Perform CodeQL Analysis
  101. if: ${{ matrix.build_type == 'Debug' }}
  102. uses: github/codeql-action/analyze@v3
  103. clang-build:
  104. needs: tests
  105. permissions:
  106. actions: read
  107. contents: read
  108. security-events: write
  109. strategy:
  110. matrix:
  111. build_type: [Debug, Release]
  112. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  113. # You can convert this to a matrix build if you need cross-platform coverage.
  114. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  115. runs-on: ubuntu-24.04
  116. steps:
  117. - uses: actions/checkout@v3
  118. with:
  119. submodules: true
  120. - name: ccache
  121. uses: hendrikmuhs/ccache-action@v1.2
  122. with:
  123. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  124. - name: Install dependencies
  125. 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 wayland-scanner++ wayland-protocols libwayland-dev
  126. - name: Configure CMake
  127. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  128. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  129. 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++
  130. - name: Build
  131. # Build your program with the given configuration
  132. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose