From 787e02181a9904778aa9215405667cfe2ebc5209 Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Fri, 2 Sep 2022 22:09:47 +0200 Subject: [PATCH] Run PVS-Studio static analyzer as part of CI/CD --- .github/workflows/main.yml | 48 ++++++++++++++++++++++++++++++++++++-- UEFITool/CMakeLists.txt | 5 ++-- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 471d626..28a6aa1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -192,13 +192,13 @@ jobs: JOB_TYPE: COVERITY HAS_QT: 1 if: github.repository_owner == 'LongSoft' && github.event_name != 'pull_request' - name: Coverity + name: Coverity Static Analysis runs-on: ubuntu-latest steps: - name: Install Qt uses: jurplel/install-qt-action@v3 with: - version: '6.2.4' + version: '6.3.1' host: 'linux' target: 'desktop' @@ -215,3 +215,47 @@ jobs: COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} COVERITY_SCAN_EMAIL: ${{ secrets.COVERITY_SCAN_EMAIL }} COVERITY_BUILD_COMMAND: ./unixbuild.sh --build + + analyze_pvs_studio: + if: github.repository_owner == 'LongSoft' && github.event_name != 'pull_request' + name: PVS-Studio Static Analysis + runs-on: ubuntu-latest + steps: + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: '6.3.1' + host: 'linux' + target: 'desktop' + + - name: Check out + uses: actions/checkout@v2 + + - name: Install PVS-Studio + run: | + wget -q -O - https://files.pvs-studio.com/etc/pubkey.txt \ + | sudo apt-key add - + sudo wget -O /etc/apt/sources.list.d/viva64.list \ + https://files.pvs-studio.com/etc/viva64.list + sudo apt update + sudo apt install pvs-studio + pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }} + + - name: Build + run: | + cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=On -B build UEFITool + cmake --build build -j + + - name: Analyze + run: | + pvs-studio-analyzer analyze -f build/compile_commands.json -j + + - name: Convert report + run: | + plog-converter -t sarif -o pvs-report.sarif PVS-Studio.log + + - name: Publish report + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: pvs-report.sarif + category: PVS-Studio \ No newline at end of file diff --git a/UEFITool/CMakeLists.txt b/UEFITool/CMakeLists.txt index 7878d8e..3f5f068 100644 --- a/UEFITool/CMakeLists.txt +++ b/UEFITool/CMakeLists.txt @@ -139,7 +139,7 @@ ADD_DEFINITIONS( SET_SOURCE_FILES_PROPERTIES(icons/uefitool.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") -ADD_EXECUTABLE(UEFITool ${PROJECT_HEADERS} ${PROJECT_FORMS} ${PROJECT_SOURCES}) +ADD_EXECUTABLE(UEFITool ${PROJECT_HEADERS} ${PROJECT_FORMS} ${PROJECT_SOURCES}) TARGET_INCLUDE_DIRECTORIES(UEFITool PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") @@ -148,4 +148,5 @@ TARGET_LINK_LIBRARIES(UEFITool PRIVATE Qt6::Widgets) SET_TARGET_PROPERTIES(UEFITool PROPERTIES WIN32_EXECUTABLE ON MACOSX_BUNDLE ON - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/Info.plist") \ No newline at end of file + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/Info.plist" +)