Skip to content

Commit 5e5cc51

Browse files
committed
ci: add CodeChecker static analysis workflow
Only diagnose flutter-pi sources by default. The diagnosis results are uploaded as an HTML workflow artifact for debugging. Also, remove the old (unused) CodeQL workflow, which had a lot of hard to disable false positives.
1 parent 0d1f85a commit 5e5cc51

File tree

7 files changed

+114
-131
lines changed

7 files changed

+114
-131
lines changed

.codechecker.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"analyze": [
3+
"-d",
4+
"clang-diagnostic-reserved-macro-identifier",
5+
"-d",
6+
"clang-diagnostic-reserved-identifier",
7+
"-d",
8+
"cert-err33-c",
9+
"-d",
10+
"clang-diagnostic-sign-compare",
11+
"-d",
12+
"clang-diagnostic-implicit-int-float-conversion",
13+
"-d",
14+
"clang-diagnostic-switch-enum",
15+
"--analyzers",
16+
"clangsa",
17+
"clang-tidy",
18+
"gcc",
19+
"-i",
20+
".codechecker.skipfile"
21+
]
22+
}

.codechecker.skipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
+*/flutter-pi/src
2+
-*

.github/workflows/codeql-buildscript.sh

100644100755
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#!/usr/bin/env bash
22

3-
sudo apt install -y cmake libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev ttf-mscorefonts-installer fontconfig libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev
4-
mkdir build && cd build
5-
cmake ..
6-
make -j`nproc`
3+
# gstreamer and libc++ want different versions of libunwind-dev.
4+
# We explicitly install the version that gstreamer wants so
5+
# we don't get install errors.
6+
7+
sudo apt-get install -y --no-install-recommends \
8+
git cmake pkg-config ninja-build clang clang-tools \
9+
libgl-dev libgles-dev libegl-dev libvulkan-dev libdrm-dev libgbm-dev libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev \
10+
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
11+
libunwind-dev
12+
13+
$WRAPPER cmake \
14+
-S . -B build \
15+
-GNinja \
16+
-DCMAKE_BUILD_TYPE=Debug \
17+
-DBUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN=ON \
18+
-DBUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN=ON \
19+
-DENABLE_VULKAN=ON \
20+
-DENABLE_SESSION_SWITCHING=ON \
21+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
22+
23+
$WRAPPER cmake --build build

.github/workflows/codeql.yml

Lines changed: 0 additions & 122 deletions
This file was deleted.

.github/workflows/fail_on_error.py renamed to .github/workflows/fail_on_warning.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ def codeql_sarif_contain_error(filename):
2020
rule_index = res['rule']['index']
2121
else:
2222
continue
23+
2324
try:
2425
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
25-
except IndexError as e:
26-
print(e, rule_index, len(rules_metadata))
27-
else:
28-
if rule_level == 'error':
29-
return True
26+
except LookupError:
27+
# According to the SARIF schema (https://www.schemastore.org/schemas/json/sarif-2.1.0-rtm.6.json),
28+
# the defalt level is "warning" if not specified.
29+
rule_level = 'warning'
30+
31+
if rule_level == 'error':
32+
return True
33+
elif rule_level == 'warning':
34+
return True
3035
return False
3136

3237
if __name__ == "__main__":

.github/workflows/static-analysis.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
push:
5+
branches: [ "main", "master" ]
6+
schedule:
7+
- cron: '0 0 * * *'
8+
pull_request:
9+
branches: '*'
10+
11+
jobs:
12+
codechecker:
13+
name: CodeChecker
14+
15+
# Use latest Ubuntu 24.04 for latest GCC.
16+
# CodeChecker requires gcc >= 13.0.0.
17+
# ubuntu-latest is ubuntu 22.04 (atm)
18+
runs-on: ubuntu-24.04
19+
20+
permissions:
21+
actions: read
22+
contents: read
23+
security-events: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: recursive
30+
31+
- name: Install Deps, Configure and Build
32+
run: |
33+
./.github/workflows/codeql-buildscript.sh
34+
35+
- name: Run CodeChecker
36+
uses: ardera/CodeChecker-Action@master
37+
id: codechecker
38+
with:
39+
ctu: true
40+
logfile: ${{ github.workspace }}/build/compile_commands.json
41+
config: ${{ github.workspace }}/.codechecker.json
42+
43+
- uses: actions/upload-artifact@v4
44+
id: upload
45+
with:
46+
name: "CodeChecker Bug Reports"
47+
path: ${{ steps.codechecker.outputs.result-html-dir }}
48+
49+
- name: Fail on Warnings
50+
if: ${{ steps.codechecker.outputs.warnings == 'true' }}
51+
run: |
52+
cat <<EOF >>$GITHUB_STEP_SUMMARY
53+
## ⚠️ CodeChecker found warnings
54+
Please see the 'CodeChecker Bug Reports' artifact for more details:
55+
- ${{ steps.upload.outputs.artifact-url }}
56+
EOF
57+
58+
exit 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.vscode
22
/build
33
/out
4+
/.codechecker
45

56
# CMake docs says it should not be checked in.
67
CMakeUserPresets.json

0 commit comments

Comments
 (0)