-
Notifications
You must be signed in to change notification settings - Fork 21
103 lines (79 loc) · 2.87 KB
/
static_analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Static Analysis
on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
BUILD_TYPE: Release
jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create static_analysis directory
run: mkdir -p static_analysis
- name: Run Cppcheck
run: |
sudo apt-get install -y cppcheck
cppcheck --enable=all --inconclusive --force --language=c++ --file-list=<(find lwlog/src/ -name "*.cpp" -o -name "*.h") &> static_analysis/cppcheck.txt
continue-on-error: true
- name: Upload Cppcheck Results
uses: actions/upload-artifact@v3
with:
name: cppcheck_results
path: static_analysis/cppcheck.txt
clang-tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create static_analysis directory
run: mkdir -p static_analysis
- name: Install Dependencies
run: sudo apt-get install -y build-essential cmake
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Generate compile_commands.json
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1
- name: Run Clang-Tidy
run: |
sudo apt-get install -y clang-tidy
find lwlog/src/ -name "*.cpp" -o -name "*.h" | xargs clang-tidy -p=build/compile_commands.json &> static_analysis/clang-tidy.txt
continue-on-error: true
- name: Upload Clang-Tidy Results
uses: actions/upload-artifact@v3
with:
name: clangtidy_results
path: static_analysis/clang-tidy.txt
sonar-scanner:
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GCC
run: sudo apt-get install -y gcc g++
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v3
- name: Create Build Environment
run: cmake -E make_directory ${{ runner.workspace }}/build
- name: Configure GCC Build
working-directory: ${{ runner.workspace }}/build
run: |
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $GITHUB_WORKSPACE
- name: Build with GCC (with build-wrapper)
working-directory: ${{ runner.workspace }}/build
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build . --config ${{ env.BUILD_TYPE }}
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.compile-commands="${{ runner.workspace }}/build/compile_commands.json"