Skip to content

Commit 54123d7

Browse files
ci: add clang-tidy and ThreadSanitizer
- New static-analysis.yml with clang-tidy, clang-tidy-extended, and ThreadSanitizer jobs - clang-tidy runs narrow security-focused checks on every push/PR - clang-tidy-extended runs broader checks (bugprone-*, cert-*, clang-analyzer-*, performance-*, portability-*) with continue-on-error: true - TSan runs full pytest suite with continue-on-error: true — currently finding real data races in get_conn/sftp_request_send and process_one_request - TSan logs written to workspace-local log_path files and uploaded as artifacts - Hard-fail FUSE preflight, all actions pinned to Node 24-capable SHAs, runner pinned to ubuntu-24.04
1 parent 25b58aa commit 54123d7

2 files changed

Lines changed: 134 additions & 0 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Checks: '-*,bugprone-unsafe-functions,bugprone-signal-handler,cert-env33-c,cert-err33-c,cert-str34-c'
2+
WarningsAsErrors: ''
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: static analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
clang-tidy:
17+
name: clang-tidy
18+
runs-on: ubuntu-24.04
19+
timeout-minutes: 15
20+
steps:
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Install dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y clang clang-tidy ninja-build pkg-config libglib2.0-dev libfuse3-dev
32+
pip3 install meson
33+
34+
- name: Build compile database
35+
env:
36+
CC: clang
37+
run: meson setup build
38+
39+
- name: Run clang-tidy
40+
run: run-clang-tidy -p build -warnings-as-errors='*' sshfs.c cache.c
41+
42+
clang-tidy-extended:
43+
name: clang-tidy (extended)
44+
runs-on: ubuntu-24.04
45+
timeout-minutes: 20
46+
continue-on-error: true
47+
steps:
48+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
52+
with:
53+
python-version: '3.12'
54+
55+
- name: Install dependencies
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install -y clang clang-tidy ninja-build pkg-config libglib2.0-dev libfuse3-dev
59+
pip3 install meson
60+
61+
- name: Build compile database
62+
env:
63+
CC: clang
64+
run: meson setup build
65+
66+
- name: Run extended clang-tidy
67+
run: |
68+
run-clang-tidy -p build \
69+
-checks='-*,bugprone-*,cert-*,clang-analyzer-*,performance-*,portability-*' \
70+
sshfs.c cache.c
71+
72+
tsan:
73+
name: ThreadSanitizer
74+
runs-on: ubuntu-24.04
75+
timeout-minutes: 30
76+
continue-on-error: true
77+
steps:
78+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
79+
80+
- name: Set up Python
81+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
82+
with:
83+
python-version: '3.12'
84+
85+
- name: Install dependencies
86+
run: |
87+
sudo apt-get update
88+
sudo apt-get install -y clang llvm ninja-build pkg-config libglib2.0-dev libfuse3-dev fuse3 openssh-client openssh-server
89+
pip3 install meson pytest pytest-timeout
90+
91+
- name: Setup SSH
92+
run: |
93+
mkdir -p ~/.ssh
94+
chmod 700 ~/.ssh
95+
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -q -N ""
96+
cat ~/.ssh/id_ed25519.pub > ~/.ssh/authorized_keys
97+
chmod 600 ~/.ssh/authorized_keys
98+
sudo systemctl start ssh || sudo service ssh start
99+
ssh -o StrictHostKeyChecking=no -o BatchMode=yes localhost true
100+
101+
- name: Build with TSan
102+
env:
103+
CC: clang
104+
run: |
105+
meson setup build -Db_sanitize=thread -Db_lundef=false -Dwerror=true
106+
ninja -C build
107+
108+
- name: Check FUSE availability
109+
run: |
110+
test -e /dev/fuse
111+
command -v fusermount3
112+
113+
- name: Create TSan log directory
114+
run: mkdir -p tsan-logs
115+
116+
- name: Test
117+
env:
118+
TSAN_OPTIONS: "halt_on_error=1:second_deadlock_stack=1:log_path=${{ github.workspace }}/tsan-logs/tsan"
119+
run: |
120+
cd build
121+
python3 -m pytest test/ --timeout=180 --maxfail=99 --junitxml=test-results.xml
122+
timeout-minutes: 20
123+
124+
- name: Upload test results
125+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
126+
if: always()
127+
with:
128+
name: test-results-tsan
129+
path: |
130+
build/test-results.xml
131+
build/meson-logs/
132+
tsan-logs/

0 commit comments

Comments
 (0)