|
| 1 | +# Copyright (C) 2025 Roberto Rossini <[email protected]> |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: Run CodeQL analysis |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + paths: |
| 10 | + - ".github/workflows/*.yml" |
| 11 | + - "cmake/**" |
| 12 | + - "docs/*.py" |
| 13 | + - "examples/**" |
| 14 | + - "src/**" |
| 15 | + - "test/fuzzer/scripts/*.py" |
| 16 | + - "test/integration/**" |
| 17 | + - "test/units/**" |
| 18 | + - "utils/devel/*.py" |
| 19 | + - "CMakeLists.txt" |
| 20 | + - "conanfile.py" |
| 21 | + schedule: |
| 22 | + - cron: "0 5 1 * *" # run monthly at 05:00 |
| 23 | + |
| 24 | +# https://stackoverflow.com/a/72408109 |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: read |
| 31 | + |
| 32 | +jobs: |
| 33 | + build-conan-deps: |
| 34 | + name: Build Conan deps |
| 35 | + uses: paulsengroup/hictk/.github/workflows/build-conan-deps.yml@main |
| 36 | + with: |
| 37 | + os: ubuntu-20.04 |
| 38 | + |
| 39 | + analyze: |
| 40 | + name: Analyze (${{ matrix.language }}) |
| 41 | + runs-on: ubuntu-24.04 |
| 42 | + needs: [build-conan-deps] |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + include: |
| 47 | + - { language: actions, build-mode: none } |
| 48 | + - { language: c-cpp, build-mode: manual } |
| 49 | + - { language: python, build-mode: none } |
| 50 | + permissions: |
| 51 | + contents: read |
| 52 | + security-events: write |
| 53 | + |
| 54 | + env: |
| 55 | + CCACHE_DISABLE: "1" |
| 56 | + CONAN_HOME: "/opt/conan/" |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout repo |
| 60 | + uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Symlink Conan home |
| 63 | + if: matrix.language == 'c-cpp' |
| 64 | + run: | |
| 65 | + mkdir -p /home/runner/opt/conan |
| 66 | + ln -s /home/runner/opt/conan /opt/conan |
| 67 | +
|
| 68 | + - name: Restore Conan cache |
| 69 | + if: matrix.language == 'c-cpp' |
| 70 | + uses: actions/cache/restore@v4 |
| 71 | + with: |
| 72 | + key: ${{ needs.build-conan-deps.outputs.conan-key }} |
| 73 | + path: ${{ env.CONAN_HOME }}/p |
| 74 | + fail-on-cache-miss: true |
| 75 | + |
| 76 | + - name: Restore CMake configs |
| 77 | + if: matrix.language == 'c-cpp' |
| 78 | + uses: actions/cache/restore@v4 |
| 79 | + with: |
| 80 | + key: ${{ needs.build-conan-deps.outputs.cmake-prefix-debug-key }} |
| 81 | + path: /tmp/cmake-prefix-dbg.tar |
| 82 | + fail-on-cache-miss: true |
| 83 | + |
| 84 | + - name: Extract CMake configs |
| 85 | + if: matrix.language == 'c-cpp' |
| 86 | + run: | |
| 87 | + mkdir conan-env |
| 88 | + tar -xf /home/runner/tmp/cmake-prefix-dbg.tar -C conan-env/ --strip-components=1 |
| 89 | +
|
| 90 | + - name: Initialize CodeQL |
| 91 | + uses: github/codeql-action/init@v3 |
| 92 | + with: |
| 93 | + languages: ${{ matrix.language }} |
| 94 | + build-mode: ${{ matrix.build-mode }} |
| 95 | + |
| 96 | + - name: Configure project |
| 97 | + if: matrix.language == 'c-cpp' |
| 98 | + run: | |
| 99 | + cmake -DCMAKE_BUILD_TYPE=Debug \ |
| 100 | + -DCMAKE_PREFIX_PATH="$PWD/conan-env" \ |
| 101 | + -DENABLE_DEVELOPER_MODE=OFF \ |
| 102 | + -DHICTK_ENABLE_TESTING=ON \ |
| 103 | + -DHICTK_BUILD_EXAMPLES=ON \ |
| 104 | + -DHICTK_DOWNLOAD_TEST_DATASET=OFF \ |
| 105 | + -DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \ |
| 106 | + -DCMAKE_INSTALL_PREFIX=dest \ |
| 107 | + -S . \ |
| 108 | + -B build |
| 109 | +
|
| 110 | + - name: Build project |
| 111 | + if: matrix.language == 'c-cpp' |
| 112 | + run: cmake --build build -j $(nproc) |
| 113 | + |
| 114 | + - name: Run Analysis |
| 115 | + uses: github/codeql-action/analyze@v3 |
| 116 | + with: |
| 117 | + category: "/language:${{ matrix.language }}" |
0 commit comments