Skip to content

Commit 531009c

Browse files
committed
add SonarQube scan
1 parent 6cc445e commit 531009c

File tree

1 file changed

+46
-24
lines changed

1 file changed

+46
-24
lines changed

.github/workflows/static_analysis.yml

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242

4343
- name: Build
4444
run: |
45+
mkdir -p build
4546
cmake examples -B build -G Ninja -DBOARD=${{ matrix.board }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=MinSizeRel
4647
cmake --build build
4748
@@ -117,10 +118,11 @@ jobs:
117118
118119
- name: Analyze
119120
run: |
121+
mkdir -p build
120122
cmake examples -B build -G Ninja -DBOARD=${{ matrix.board }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=MinSizeRel
121123
cmake --build build
122124
pvs-studio-analyzer analyze -f build/compile_commands.json -j --exclude-path hw/mcu/ --exclude-path lib/
123-
plog-converter -t sarif -o pvs-${{ matrix.board }}.sarif PVS-Studio.log
125+
plog-converter -t sarif -o pvs-studio-${{ matrix.board }}.sarif PVS-Studio.log
124126
125127
- name: Upload SARIF
126128
uses: github/codeql-action/upload-sarif@v4
@@ -131,28 +133,48 @@ jobs:
131133
- name: Upload artifact
132134
uses: actions/upload-artifact@v5
133135
with:
134-
name: pvs-${{ matrix.board }}
135-
path: pvs-${{ matrix.board }}.sarif
136+
name: pvs-studio-${{ matrix.board }}
137+
path: pvs-studio-${{ matrix.board }}.sarif
136138

139+
SonarQube:
140+
runs-on: ubuntu-latest
141+
env:
142+
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
143+
strategy:
144+
fail-fast: false
145+
matrix:
146+
board:
147+
- 'metro_m4_express'
148+
steps:
149+
- name: Checkout TinyUSB
150+
uses: actions/checkout@v4
151+
with:
152+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
137153

138-
# SonarQube:
139-
# name: Build and analyze
140-
# runs-on: ubuntu-latest
141-
# env:
142-
# BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
143-
# steps:
144-
# - uses: actions/checkout@v4
145-
# with:
146-
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
147-
# - name: Install Build Wrapper
148-
# uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
149-
# - name: Run Build Wrapper
150-
# run: |
151-
# build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset ${{ env.BOARD }} -t ${{ env.EXAMPLE }}
152-
# - name: SonarQube Scan
153-
# uses: SonarSource/sonarqube-scan-action@v6
154-
# env:
155-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
156-
# with:
157-
# args: >
158-
# --define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
154+
- name: Get Dependencies
155+
uses: ./.github/actions/get_deps
156+
with:
157+
arg: -b${{ matrix.board }}
158+
159+
- name: Setup Toolchain
160+
uses: ./.github/actions/setup_toolchain
161+
with:
162+
toolchain: 'arm-gcc'
163+
164+
- name: Install Build Wrapper
165+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
166+
167+
- name: Run Build Wrapper
168+
run: |
169+
cmake examples -B build -G Ninja -DBOARD=${{ matrix.board }} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=MinSizeRel
170+
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/
171+
172+
- name: SonarQube Scan
173+
uses: SonarSource/sonarqube-scan-action@v6
174+
env:
175+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
176+
SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }}
177+
with:
178+
# Consult https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner/ for more information and options
179+
args: >
180+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

0 commit comments

Comments
 (0)