codeql.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. name: CodeQL
  2. on:
  3. schedule:
  4. - cron: '23 3 * * 1'
  5. workflow_dispatch:
  6. permissions:
  7. contents: read
  8. jobs:
  9. analyze:
  10. name: Analyze C++
  11. runs-on: ubuntu-24.04
  12. permissions:
  13. actions: read
  14. contents: read
  15. security-events: write
  16. steps:
  17. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
  18. with:
  19. submodules: true
  20. - name: ccache
  21. uses: hendrikmuhs/ccache-action@f09c25b45002a07be2955cbe52e8cee55643f89d # v1.2.24
  22. with:
  23. key: ${{ github.job }}
  24. - name: Install dependencies
  25. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcomposite-dev libxdamage-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
  26. - name: Initialize CodeQL
  27. uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4
  28. with:
  29. languages: c-cpp
  30. build-mode: manual
  31. queries: security-extended
  32. - name: Build
  33. run: |
  34. cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=1 -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  35. cmake --build build --target linux-wallpaperengine -j"$(nproc)"
  36. - name: Perform CodeQL analysis
  37. uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4
  38. with:
  39. category: /language:c-cpp
  40. upload: never
  41. output: sarif-results
  42. # paths-ignore does not apply to a manual C++ build, so third-party results are dropped from the SARIF here
  43. - name: Drop third-party results
  44. run: |
  45. python3 - <<'EOF'
  46. import glob, json
  47. skipped = ("src/External/", "build/")
  48. for name in glob.glob("sarif-results/*.sarif"):
  49. with open(name) as f:
  50. sarif = json.load(f)
  51. for run in sarif["runs"]:
  52. run["results"] = [
  53. r for r in run.get("results", [])
  54. if not any(
  55. l["physicalLocation"]["artifactLocation"]["uri"].startswith(skipped)
  56. for l in r.get("locations", [])
  57. )
  58. ]
  59. with open(name, "w") as f:
  60. json.dump(sarif, f)
  61. EOF
  62. - name: Upload results
  63. uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4
  64. with:
  65. sarif_file: sarif-results
  66. category: /language:c-cpp