Skip to content

Commit d9c4078

Browse files
committed
codechecker
Signed-off-by: Anas Nashif <[email protected]>
1 parent 168c79c commit d9c4078

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

.codechecker.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,13 @@ analyzer:
1717
- --disable=clang-diagnostic-reserved-identifier
1818
- --disable=clang-diagnostic-reserved-macro-identifier
1919

20+
# userspace includes c files
21+
- --disable=bugprone-suspicious-include
22+
23+
# LOG_ macros
24+
- --disable=alpha.core.SizeofPtr
25+
- --disable=bugprone-sizeof-expression
26+
- --disable=performance-no-int-to-ptr
27+
2028
# Cleanup
2129
- --clean

.github/workflows/codechecker.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Codechecker
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- v*-branch
7+
- collab-*
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
Codechecker:
17+
if: github.repository_owner == 'zephyrproject-rtos'
18+
runs-on:
19+
group: zephyr-runner-v2-linux-x64-4xlarge
20+
container:
21+
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026
22+
options: '--entrypoint /bin/bash'
23+
env:
24+
CCACHE_DIR: /node-cache/ccache-zephyr
25+
CCACHE_REMOTE_STORAGE: "redis://cache-*.keydb-cache.svc.cluster.local|shards=1,2,3"
26+
CCACHE_REMOTE_ONLY: "true"
27+
CCACHE_IGNOREOPTIONS: '-specs=* --specs=*'
28+
LLVM_TOOLCHAIN_PATH: /usr/lib/llvm-16
29+
BASE_REF: ${{ github.base_ref }}
30+
permissions:
31+
security-events: write
32+
steps:
33+
- name: Apply container owner mismatch workaround
34+
run: |
35+
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
36+
# match the container user UID because of the way GitHub
37+
# Actions runner is implemented. Remove this workaround when
38+
# GitHub comes up with a fundamental fix for this problem.
39+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
40+
41+
- name: Print cloud service information
42+
run: |
43+
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
44+
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
45+
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
46+
47+
- name: Clone cached Zephyr repository
48+
continue-on-error: true
49+
run: |
50+
git clone --shared /repo-cache/zephyrproject/zephyr .
51+
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
52+
53+
- name: Checkout
54+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
55+
with:
56+
fetch-depth: 0
57+
persist-credentials: false
58+
59+
- name: Environment Setup
60+
run: |
61+
echo "$HOME/.local/bin" >> $GITHUB_PATH
62+
git config --global user.email "[email protected]"
63+
git config --global user.name "Zephyr Bot"
64+
rm -fr ".git/rebase-apply"
65+
rm -fr ".git/rebase-merge"
66+
git clean -f -d
67+
git log --pretty=oneline | head -n 10
68+
west init -l . || true
69+
west config --global update.narrow true
70+
west config manifest.group-filter -- +ci,-optional,-hal,-babblesim
71+
# In some cases modules are left in a state where they can't be
72+
# updated (i.e. when we cancel a job and the builder is killed),
73+
# So first retry to update, if that does not work, remove all modules
74+
# and start over. (Workaround until we implement more robust module
75+
# west caching).
76+
# west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west2.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
77+
78+
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
79+
80+
- name: Check Environment
81+
run: |
82+
cmake --version
83+
${LLVM_TOOLCHAIN_PATH}/bin/clang --version
84+
gcc --version
85+
ls -la
86+
87+
- name: Run Tests with Twister
88+
id: twister
89+
run: |
90+
export ZEPHYR_BASE=${PWD}
91+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
92+
export ZEPHYR_SCA_VARIANT=codechecker
93+
export CODECHECKER_CONFIG_FILE=$ZEPHYR_BASE/.codechecker.yml
94+
export CODECHECKER_CLEANUP=y
95+
export CODECHECKER_EXPORT=sarif
96+
pip install codechecker==v6.25.1 cppcheck sarif-tools jq
97+
sudo apt-get update
98+
sudo apt-get install -y jq
99+
export PATH=/usr/lib/llvm-16/bin/:$PATH
100+
101+
./scripts/twister -i --force-color -N -v --build-only --timeout-multiplier 2 -p qemu_x86 -T tests/kernel/threads
102+
103+
#sarif copy --output results.sarif $(find twister-out -name "codechecker.sarif")
104+
jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' $(find twister-out -name "codechecker.sarif") > results.sarif
105+
106+
- name: Upload SARIF as artifact
107+
if: always()
108+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
109+
with:
110+
name: sarif
111+
if-no-files-found: ignore
112+
path: |
113+
build/sca/codechecker/codechecker.sarif
114+
results.sarif
115+
116+
- name: Upload Analysis Results
117+
if: always()
118+
uses: github/codeql-action/upload-sarif@v3
119+
with:
120+
sarif_file: results.sarif

west.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ manifest:
320320
- name: nrf_hw_models
321321
revision: b84bd7314a239f818e78f6927f5673247816df53
322322
path: modules/bsim_hw_models/nrf_hw_models
323+
groups:
324+
- hal
323325
- name: nrf_wifi
324326
revision: 662ed74dce955e6c243f91c45a66768f5971e3cb
325327
path: modules/lib/nrf_wifi

0 commit comments

Comments
 (0)