From 942d8669791a1c125bb1d1df55d9bde7a5f92785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Thu, 27 Jan 2022 17:50:41 +0100 Subject: [PATCH] Add PVS-Studio to a Github action --- .../workflows/on_PR_linux_special_builds.yml | 63 ++++++++++++++++++- doc/readme-pvs-studio.md | 6 +- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/.github/workflows/on_PR_linux_special_builds.yml b/.github/workflows/on_PR_linux_special_builds.yml index 092f8a4d..740c03b4 100644 --- a/.github/workflows/on_PR_linux_special_builds.yml +++ b/.github/workflows/on_PR_linux_special_builds.yml @@ -150,7 +150,7 @@ jobs: ctest --output-on-failure special_allEnabled: - name: 'Ubuntu 20.04 - GCC - All Options Enabled' + name: 'Ubuntu 20.04 - GCC - All Options Enabled + Documentation' runs-on: ubuntu-latest steps: @@ -196,3 +196,64 @@ jobs: - name: Generate documentation run: | make doc + + special_pvsStudio: + name: 'Ubuntu 20.04 - GCC - Static Analyzer: PVS-Studio' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + # Trying to deal with warning: -> Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0 + + - name: install dependencies + run: | + pip3 install conan==1.43.0 + sudo add-apt-repository ppa:ubuntu-lxc/daily -y + 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-get update -qq + sudo apt-get install -qq pvs-studio + + - name: Conan common config + run: | + conan profile new --detect default + conan profile update settings.compiler.libcxx=libstdc++11 default + + - name: Run Conan + run: | + mkdir build && cd build + conan profile list + conan profile show default + conan install .. -o webready=True --build missing + + - name: Configure + run: | + cd build && \ + cmake -DCMAKE_BUILD_TYPE=Debug \ + -DBUILD_SHARED_LIBS=ON \ + -DEXIV2_ENABLE_PNG=ON \ + -DEXIV2_ENABLE_WEBREADY=ON \ + -DEXIV2_ENABLE_CURL=ON \ + -DEXIV2_BUILD_UNIT_TESTS=ON \ + -DEXIV2_ENABLE_BMFF=ON \ + -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON \ + -DBUILD_WITH_COVERAGE=ON \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + .. \ + + - name: Static Analysis + run: | + pvs-studio-analyzer credentials $PVS_USERNAME $PVS_KEY -o PVS_license.lic + pvs-studio-analyzer analyze -l PVS_license.lic -o pvsStudio.log -j4 + plog-converter -a GA:1,2 -d V1042 -t fullhtml pvsStudio.log -o pvsReportHtml + + - uses: actions/upload-artifact@v2 + with: + name: static_analysis + path: pvsReportHtml + retention-days: 30 + + diff --git a/doc/readme-pvs-studio.md b/doc/readme-pvs-studio.md index 22bc208e..456b6ed6 100644 --- a/doc/readme-pvs-studio.md +++ b/doc/readme-pvs-studio.md @@ -11,7 +11,7 @@ To check a project configured with CMake, such as Exiv2, we need to generate the cd buildXXX cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ... -# Output file: compile_commands.json +# Once the CMake configuration is done, we should obtain a output file 'compile_commands.json' ``` The analysis starts with the following commands: @@ -21,5 +21,5 @@ export PVS_LICENSE=~/.config/PVS-Studio/PVS-Studio.lic pvs-studio-analyzer analyze -l $PVS_LICENSE -o pvsStudio.log -j8 plog-converter -a GA:1,2 -t tasklist pvsStudio.log -o pvsStudio.tasks plog-converter -a GA:1,2 -t fullhtml pvsStudio.log -o pvsReportHtml -log-converter -a GA:1,2 -d V1042 -t fullhtml pvsStudio.log -o pvsReportHtml -``` \ No newline at end of file +plog-converter -a GA:1,2 -d V1042 -t fullhtml pvsStudio.log -o pvsReportHtml +```