Skip to content

Commit b08f672

Browse files
committed
add pvs-studio analyze to ci
1 parent 55c6d07 commit b08f672

File tree

6 files changed

+76
-4
lines changed

6 files changed

+76
-4
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ jobs:
219219
uses: actions/checkout@v4
220220

221221
- name: Download Artifacts
222-
uses: actions/download-artifact@v4
222+
uses: actions/download-artifact@v5
223223
with:
224224
path: cmake-build
225225
merge-multiple: true

.github/workflows/build_util.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
required: false
2121
default: false
2222
type: boolean
23+
analyze-pvs:
24+
required: false
25+
default: false
26+
type: boolean
2327
os:
2428
required: false
2529
type: string
@@ -68,6 +72,28 @@ jobs:
6872
fi
6973
shell: bash
7074

75+
- name: PVS-Studio analyze
76+
if: ${{ inputs.analyze-pvs }}
77+
run: |
78+
wget -q -O - https://files.pvs-studio.com/etc/pubkey.txt | sudo apt-key add -
79+
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.pvs-studio.com/etc/viva64.list
80+
sudo apt update
81+
sudo apt install pvs-studio
82+
pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
83+
mkdir -p sarif-reports
84+
for build_dir in cmake-build/cmake-build-*; do
85+
BOARD=${build_dir#cmake-build/cmake-build-}
86+
pvs-studio-analyzer analyze -f ${build_dir}/compile_commands.json -j -o ${build_dir}/pvs-report.log --exclude-path hw/mcu/ --exclude-path lib/
87+
plog-converter -t sarif -o sarif-reports/${BOARD}.sarif ${build_dir}/pvs-report.log
88+
done
89+
90+
- name: PVS-Studio upload SARIF
91+
if: ${{ inputs.analyze-pvs }}
92+
uses: github/codeql-action/upload-sarif@v4
93+
with:
94+
sarif_file: sarif-reports/
95+
category: PVS-Studio
96+
7197
- name: Upload Artifacts for Hardware Testing
7298
if: ${{ inputs.upload-artifacts }}
7399
uses: actions/upload-artifact@v4
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Static Analysis
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
jobs:
10+
# SonarQube:
11+
# name: Build and analyze
12+
# runs-on: ubuntu-latest
13+
# env:
14+
# BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
15+
# steps:
16+
# - uses: actions/checkout@v4
17+
# with:
18+
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
19+
# - name: Install Build Wrapper
20+
# uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
21+
# - name: Run Build Wrapper
22+
# run: |
23+
# build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset ${{ env.BOARD }} -t ${{ env.EXAMPLE }}
24+
# - name: SonarQube Scan
25+
# uses: SonarSource/sonarqube-scan-action@v6
26+
# env:
27+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
28+
# with:
29+
# args: >
30+
# --define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
31+
PVS-Studio:
32+
uses: ./.github/workflows/build_util.yml
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
board:
37+
- 'stm32h743eval'
38+
with:
39+
build-system: 'cmake'
40+
toolchain: 'arm-gcc'
41+
build-args: '-b${{ matrix.board }}'
42+
one-per-family: true
43+
analyze-pvs: true

examples/device/cdc_msc/src/msc_disk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ enum {
4545
DISK_BLOCK_SIZE = 512
4646
};
4747

48+
static
4849
#ifdef CFG_EXAMPLE_MSC_READONLY
4950
const
5051
#endif
51-
static uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
52+
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
5253
//------------- Block0: Boot Sector -------------//
5354
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
5455
// sector_per_cluster = 1; reserved_sectors = 1;

examples/device/cdc_msc_freertos/src/msc_disk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ enum {
7676
DISK_BLOCK_SIZE = 512
7777
};
7878

79+
static
7980
#ifdef CFG_EXAMPLE_MSC_READONLY
8081
const
8182
#endif
82-
static uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
83+
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
8384
{
8485
//------------- Block0: Boot Sector -------------//
8586
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;

examples/device/dynamic_configuration/src/msc_disk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ enum
4343
DISK_BLOCK_SIZE = 512
4444
};
4545

46+
static
4647
#ifdef CFG_EXAMPLE_MSC_READONLY
4748
const
4849
#endif
49-
static uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
50+
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
5051
{
5152
//------------- Block0: Boot Sector -------------//
5253
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;

0 commit comments

Comments
 (0)