Skip to content

Commit 0b764e8

Browse files
committed
Refactor CodeQL workflows
1 parent d8de6d9 commit 0b764e8

File tree

3 files changed

+105
-25
lines changed

3 files changed

+105
-25
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2025 Roberto Rossini <[email protected]>
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Run CodeQL analysis (actions)
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- ".github/workflows/*.yml"
11+
pull_request:
12+
paths:
13+
- ".github/workflows/*.yml"
14+
schedule:
15+
- cron: "0 5 1 * *" # run monthly at 05:00
16+
17+
# https://stackoverflow.com/a/72408109
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
cancel-in-progress: true
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
analyze:
27+
name: Analyze (actions)
28+
runs-on: ubuntu-24.04
29+
permissions:
30+
contents: read
31+
security-events: write
32+
33+
steps:
34+
- name: Checkout repo
35+
uses: actions/checkout@v4
36+
37+
- name: Initialize CodeQL
38+
uses: github/codeql-action/init@v3
39+
with:
40+
languages: actions
41+
build-mode: none
42+
43+
- name: Run Analysis
44+
uses: github/codeql-action/analyze@v3
45+
with:
46+
category: "/language:actions"
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
# Copyright (C) 2025 Roberto Rossini <[email protected]>
22
# SPDX-License-Identifier: MIT
33

4-
name: Run CodeQL analysis
4+
name: Run CodeQL analysis (C++)
55

66
on:
77
push:
88
branches: [main]
99
paths:
10-
- ".github/workflows/*.yml"
10+
- ".github/workflows/codeql-cpp.yml"
1111
- "cmake/**"
12-
- "docs/*.py"
1312
- "examples/**"
1413
- "src/**"
15-
- "test/fuzzer/scripts/*.py"
1614
- "test/integration/**"
1715
- "test/units/**"
18-
- "utils/devel/*.py"
1916
- "CMakeLists.txt"
20-
- "conanfile.py"
21-
schedule:
22-
- cron: "0 5 1 * *" # run monthly at 05:00
17+
schedule:
18+
- cron: "0 5 1 * *" # run monthly at 05:00
2319

2420
# https://stackoverflow.com/a/72408109
2521
concurrency:
@@ -37,16 +33,9 @@ jobs:
3733
os: ubuntu-20.04
3834

3935
analyze:
40-
name: Analyze (${{ matrix.language }})
36+
name: Analyze (C++)
4137
runs-on: ubuntu-24.04
4238
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 }
5039
permissions:
5140
contents: read
5241
security-events: write
@@ -60,41 +49,36 @@ jobs:
6049
uses: actions/checkout@v4
6150

6251
- name: Symlink Conan home
63-
if: matrix.language == 'c-cpp'
6452
run: |
6553
mkdir -p /home/runner/opt/conan
6654
ln -s /home/runner/opt/conan/ /opt/conan
6755
6856
- name: Restore Conan cache
69-
if: matrix.language == 'c-cpp'
7057
uses: actions/cache/restore@v4
7158
with:
7259
key: ${{ needs.build-conan-deps.outputs.conan-key }}
7360
path: ${{ env.CONAN_HOME }}/p
7461
fail-on-cache-miss: true
7562

7663
- name: Restore CMake configs
77-
if: matrix.language == 'c-cpp'
7864
uses: actions/cache/restore@v4
7965
with:
8066
key: ${{ needs.build-conan-deps.outputs.cmake-prefix-debug-key }}
8167
path: /tmp/cmake-prefix-dbg.tar
8268
fail-on-cache-miss: true
8369

8470
- name: Extract CMake configs
85-
if: matrix.language == 'c-cpp'
8671
run: |
8772
mkdir conan-env
8873
tar -xf /home/runner/tmp/cmake-prefix-dbg.tar -C conan-env/ --strip-components=1
8974
9075
- name: Initialize CodeQL
9176
uses: github/codeql-action/init@v3
9277
with:
93-
languages: ${{ matrix.language }}
94-
build-mode: ${{ matrix.build-mode }}
78+
languages: c-cpp
79+
build-mode: manual
9580

9681
- name: Configure project
97-
if: matrix.language == 'c-cpp'
9882
run: |
9983
cmake -DCMAKE_BUILD_TYPE=Debug \
10084
-DCMAKE_PREFIX_PATH="$PWD/conan-env" \
@@ -108,10 +92,9 @@ jobs:
10892
-B build
10993
11094
- name: Build project
111-
if: matrix.language == 'c-cpp'
11295
run: cmake --build build -j $(nproc)
11396

11497
- name: Run Analysis
11598
uses: github/codeql-action/analyze@v3
11699
with:
117-
category: "/language:${{ matrix.language }}"
100+
category: "/language:c-cpp"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (C) 2025 Roberto Rossini <[email protected]>
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Run CodeQL analysis (Python)
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- ".github/workflows/codeql-python.yml"
11+
- "docs/*.py"
12+
- "test/fuzzer/scripts/*.py"
13+
- "utils/devel/*.py"
14+
pull_request:
15+
paths:
16+
- "docs/*.py"
17+
- "test/fuzzer/scripts/*.py"
18+
- "utils/devel/*.py"
19+
schedule:
20+
- cron: "0 5 1 * *" # run monthly at 05:00
21+
22+
# https://stackoverflow.com/a/72408109
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
analyze:
32+
name: Analyze (python)
33+
runs-on: ubuntu-24.04
34+
permissions:
35+
contents: read
36+
security-events: write
37+
38+
steps:
39+
- name: Checkout repo
40+
uses: actions/checkout@v4
41+
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v3
44+
with:
45+
languages: python
46+
build-mode: none
47+
48+
- name: Run Analysis
49+
uses: github/codeql-action/analyze@v3
50+
with:
51+
category: "/language:python"

0 commit comments

Comments
 (0)