Skip to content

Commit cd12ee7

Browse files
committed
Setup CodeQL analysis
1 parent 9d86b2e commit cd12ee7

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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: Restore Conan cache
63+
if: matrix.language == 'c-cpp'
64+
uses: actions/cache/restore@v4
65+
with:
66+
key: ${{ needs.build-conan-deps.outputs.conan-key }}
67+
path: ${{ env.CONAN_HOME }}/p
68+
fail-on-cache-miss: true
69+
70+
- name: Restore CMake configs
71+
if: matrix.language == 'c-cpp'
72+
uses: actions/cache/restore@v4
73+
with:
74+
key: ${{ needs.build-conan-deps.outputs.cmake-prefix-debug-key }}
75+
path: /tmp/cmake-prefix-dbg.tar
76+
fail-on-cache-miss: true
77+
78+
- name: Extract CMake configs
79+
if: matrix.language == 'c-cpp'
80+
run: |
81+
mkdir conan-env
82+
tar -xf /home/runner/tmp/cmake-prefix-dbg.tar -C conan-env/ --strip-components=1
83+
84+
- name: Initialize CodeQL
85+
uses: github/codeql-action/init@v3
86+
with:
87+
languages: ${{ matrix.language }}
88+
build-mode: ${{ matrix.build-mode }}
89+
90+
- name: Configure project
91+
if: matrix.language == 'c-cpp'
92+
run: |
93+
cmake -DCMAKE_BUILD_TYPE=Debug \
94+
-DCMAKE_PREFIX_PATH="$PWD/conan-env" \
95+
-DENABLE_DEVELOPER_MODE=OFF \
96+
-DHICTK_ENABLE_TESTING=ON \
97+
-DHICTK_BUILD_EXAMPLES=ON \
98+
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
99+
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
100+
-DCMAKE_INSTALL_PREFIX=dest \
101+
-S . \
102+
-B build
103+
104+
- name: Build project
105+
if: matrix.language == 'c-cpp'
106+
run: cmake --build build -j $(nproc)
107+
108+
- uses: github/codeql-action/analyze@v3
109+
with:
110+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)