Skip to content

Commit 4b94a0f

Browse files
committed
chg: dev: migrate codeql to config file with custom query pack
Signed-off-by: Stephen L Arnold <[email protected]>
1 parent 75709bb commit 4b94a0f

File tree

6 files changed

+59
-16
lines changed

6 files changed

+59
-16
lines changed

.github/codeql/codeql-config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: "CodeQL config"
2+
3+
queries:
4+
- name: Use custom query pack (security-and-quality plus critical minus dev)
5+
uses: ./.github/codeql/default.qls

.github/codeql/default.qls

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://github.com/zbazztian/custom-queries/blob/master/cpp/default.qls
2+
3+
# add standard security and quality query set
4+
- import: codeql-suites/cpp-security-and-quality.qls
5+
from: codeql/cpp-queries
6+
- exclude:
7+
id:
8+
- cpp/fixme-comment
9+
- cpp/short-global-name
10+
11+
# add non-standard queries, which are normally disabled
12+
- queries: '.'
13+
from: codeql/cpp-queries
14+
- include:
15+
id:
16+
- cpp/descriptor-may-not-be-closed
17+
- cpp/descriptor-never-closed
18+
- cpp/file-may-not-be-closed
19+
- cpp/file-never-closed
20+
- cpp/memory-may-not-be-freed
21+
- cpp/memory-never-freed

.github/codeql/qlpack.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: custom-cpp-query-pack
2+
version: 1.0.0
3+
libraryPathDependencies: codeql-cpp

.github/workflows/codeql.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ on:
1111

1212
jobs:
1313
analyze:
14-
name: Analyze Cpp
14+
name: Analyze Code
1515
runs-on: ubuntu-22.04
16+
env:
17+
LLVM_VER: 15
1618
permissions:
1719
# required for all workflows
1820
security-events: write
@@ -27,7 +29,7 @@ jobs:
2729
matrix:
2830
include:
2931
- language: c-cpp
30-
build-mode: autobuild
32+
build-mode: manual
3133
- language: python
3234
build-mode: none
3335
- language: actions
@@ -48,29 +50,41 @@ jobs:
4850
with:
4951
languages: ${{ matrix.language }}
5052
build-mode: ${{ matrix.build-mode }}
53+
config-file: ./.github/codeql/codeql-config.yml
5154

5255
- name: Install dependencies
53-
if: matrix.language == 'cpp'
56+
- if: matrix.build-mode == 'manual'
5457
run: |
5558
sudo apt-get -qq update
5659
sudo apt-get install -yqq software-properties-common redis-server
57-
sudo add-apt-repository -y -s ppa:nerdboy/embedded
5860
sudo add-apt-repository -y -s ppa:ubuntu-toolchain-r/ppa
5961
sudo apt-get -qq update
60-
sudo apt-get install -y libhiredis-dev autoconf automake
61-
sudo apt-get install -y libjson-c-dev
62+
sudo apt-get install -yqq libjson-c-dev libhiredis-dev libgtest-dev libgmock-dev lcov
6263
sudo systemctl stop redis
63-
sudo apt-get install -y g++-11 g++-11-multilib
64-
echo "CC=gcc-11" >> $GITHUB_ENV
65-
echo "CXX=g++-11" >> $GITHUB_ENV
64+
sudo apt-get install -y clang-${{ env.LLVM_VER }} llvm-${{ env.LLVM_VER }} lld-${{ env.LLVM_VER }} llvm-${{ env.LLVM_VER }}-tools g++-multilib
65+
echo "CC=clang-${{ env.LLVM_VER }}" >> $GITHUB_ENV
66+
echo "CXX=clang++-${{ env.LLVM_VER }}" >> $GITHUB_ENV
67+
echo "LLVM_VER_DIR=/usr/lib/llvm-${{ env.LLVM_VER }}" >> $GITHUB_ENV
6668
6769
- if: matrix.build-mode == 'manual'
6870
uses: actions/setup-python@v5
6971
with:
70-
python-version: "3.10"
72+
python-version: "3.11"
73+
74+
- if: matrix.build-mode == 'manual'
75+
name: Install Tox
76+
run: |
77+
python -m pip install --upgrade pip
78+
pip install tox
7179
72-
- name: Autobuild
73-
uses: github/codeql-action/autobuild@v3
80+
- if: matrix.build-mode == 'manual'
81+
name: Build
82+
env:
83+
CC: ${{ env.CC }}
84+
CXX: ${{ env.CXX }}
85+
LLVM_VER_DIR: ${{ env.LLVM_VER_DIR }}
86+
run: |
87+
tox -e clang
7488
7589
- name: Perform CodeQL Analysis
7690
uses: github/codeql-action/analyze@v3

.github/workflows/smoke.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
build/coverage/html
8686
build/coverage/lcov.info
8787
88-
check:
88+
ci_metrics:
8989
name: Collect metrics
9090
runs-on: ubuntu-22.04
9191
permissions:

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ commands =
7676
clang: bash -c 'cmake --build . --target coverage'
7777
lcov: lcov_cobertura build/coverage/lcov.info --base-dir {toxinidir} --output coverage.xml
7878
lint: bash -c 'cpplint --output=gsed {toxinidir}/src/* {toxinidir}/inc/*'
79-
{bionic,tests}: gcovr --gcov-ignore-parse-errors=negative_hits.warn -s -b -r {toxinidir} .
79+
{bionic,tests}: gcovr --gcov-ignore-parse-errors=negative_hits.warn -s --txt-metric branch -r {toxinidir} .
8080
bionic: gcovr -r {toxinidir} --xml-pretty -o coverage.xml .
8181
bionic: gcovr -r {toxinidir} --html --html-details -o {toxinidir}/coverage/coverage.html .
8282
{bionic}: bash -c 'RIPC_RUNTIME_DIR=$ENV_RIPC_RUNTIME_DIR {toxinidir}/scripts/run_redis.sh stop'
83-
ctest: bash -c 'ctest --build-generator {posargs:"Unix Makefiles"} --build-and-test . build --build-options -DWITH_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug --test-command ctest --rerun-failed --output-on-failure -V'
84-
ctest: gcovr --gcov-ignore-parse-errors=negative_hits.warn -s -b build/
83+
ctest: bash -c 'ctest --build-generator {posargs:"Ninja"} --build-and-test . build --build-options -DWITH_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug --test-command ctest --rerun-failed --output-on-failure -V'
84+
ctest: gcovr --gcov-ignore-parse-errors=negative_hits.warn -s --txt-metric branch build/
8585
cover: gcovr --xml-pretty -o coverage.xml build/
8686
# runtime assertion error without || true => (SIGSEGV)) (exited with code -11)
8787
grind: bash -c 'valgrind --tool=memcheck --xml=yes --xml-file=json_check.xml --leak-check=full --show-leak-kinds=definite,possible --error-exitcode=127 ./json_test || true'

0 commit comments

Comments
 (0)