Skip to content

Commit 06c73cf

Browse files
authored
CI: Add smatch static analysis workflow
Smatch is an actively maintained kernel-aware static analyzer for C with a low false positive rate. Since the code checker can be run relatively quickly against the entire OpenZFS code base (15 min) it makes sense to add it as a GitHub Actions workflow. Today smatch reports a significant numbers warnings so the workflow is configured to always pass as long as the analysis was run. The results are available for reference. Long term it would ideal to resolve all of the errors/warnings at which point the workflow can be updated to fail when new problems are detected. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Toomas Soome <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #17935
1 parent 74b50a7 commit 06c73cf

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/smatch.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: smatch
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
smatch:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout smatch
16+
uses: actions/checkout@v4
17+
with:
18+
repository: error27/smatch
19+
ref: master
20+
path: smatch
21+
- name: Install smatch dependencies
22+
run: |
23+
sudo apt-get install -y llvm gcc make sqlite3 libsqlite3-dev libdbd-sqlite3-perl libssl-dev libtry-tiny-perl
24+
- name: Make smatch
25+
run: |
26+
cd $GITHUB_WORKSPACE/smatch
27+
make -j$(nproc)
28+
- name: Checkout OpenZFS
29+
uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
path: zfs
33+
- name: Install OpenZFS dependencies
34+
run: |
35+
cd $GITHUB_WORKSPACE/zfs
36+
sudo apt-get purge -y snapd google-chrome-stable firefox
37+
ONLY_DEPS=1 .github/workflows/scripts/qemu-3-deps-vm.sh ubuntu24
38+
- name: Autogen.sh OpenZFS
39+
run: |
40+
cd $GITHUB_WORKSPACE/zfs
41+
./autogen.sh
42+
- name: Configure OpenZFS
43+
run: |
44+
cd $GITHUB_WORKSPACE/zfs
45+
./configure --enable-debug
46+
- name: Make OpenZFS
47+
run: |
48+
cd $GITHUB_WORKSPACE/zfs
49+
make -j$(nproc) CHECK="$GITHUB_WORKSPACE/smatch/smatch" CC=$GITHUB_WORKSPACE/smatch/cgcc | tee $GITHUB_WORKSPACE/smatch.log
50+
- name: Smatch results log
51+
run: |
52+
grep -E 'error:|warn:|warning:' $GITHUB_WORKSPACE/smatch.log

0 commit comments

Comments
 (0)