Skip to content

Commit

Permalink
add: qodana static code analysis
Browse files Browse the repository at this point in the history
Add JetBrains Qodana Static Analysis Tool.
Not yet on the best way, but using their GH Actions it was not working,
so we had to use another approach to make it work.
  • Loading branch information
Costallat committed Aug 1, 2024
1 parent 165a908 commit 2058c0b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 2 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/analysis-qodana-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Qodana-Action
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Install Linux Dependencies
run: >

Check failure on line 24 in .github/workflows/analysis-qodana-action.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-action.yml#L24

shellcheck reported issue in this script: SC2046:warning:1:66: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-action.yml:24:9: shellcheck reported issue in this script: SC2046:warning:1:66: Quote this to prevent word splitting [shellcheck]
sudo apt-get update && sudo apt-get install ccache
linux-headers-$(uname -r)
- name: CCache
uses: hendrikmuhs/ccache-action@main
with:
max-size: "1G"
key: ccache-qodana

- name: Restore artifacts and install vcpkg
id: vcpkg-step
run: |

Check failure on line 36 in .github/workflows/analysis-qodana-action.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-action.yml#L36

shellcheck reported issue in this script: SC2086:info:3:46: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-action.yml:36:9: shellcheck reported issue in this script: SC2086:info:3:46: Double quote to prevent globbing and word splitting [shellcheck]
vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ')
echo "vcpkg commit ID: $vcpkgCommitId"
echo "VCPKG_GIT_COMMIT_ID=$vcpkgCommitId" >> $GITHUB_ENV
- name: Get vcpkg commit id from vcpkg.json
uses: lukka/run-vcpkg@main
with:
vcpkgGitURL: "https://github.com/microsoft/vcpkg.git"
vcpkgGitCommitId: ${{ env.VCPKG_GIT_COMMIT_ID }}

- name: Get latest CMake and ninja
uses: lukka/get-cmake@main

- name: Run CMake
uses: lukka/run-cmake@main
with:
configurePreset: linux-debug


- name: 'Qodana Scan'
uses: JetBrains/[email protected]
with:
args: --log-level,debug,--compile-commands,./build/linux-debug/compile_commands.json
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
62 changes: 62 additions & 0 deletions .github/workflows/analysis-qodana-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Qodana-Docker
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Install Linux Dependencies
run: >

Check failure on line 24 in .github/workflows/analysis-qodana-docker.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-docker.yml#L24

shellcheck reported issue in this script: SC2046:warning:1:66: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-docker.yml:24:9: shellcheck reported issue in this script: SC2046:warning:1:66: Quote this to prevent word splitting [shellcheck]
sudo apt-get update && sudo apt-get install ccache
linux-headers-$(uname -r)
- name: CCache
uses: hendrikmuhs/ccache-action@main
with:
max-size: "1G"
key: ccache-qodana

- name: Restore artifacts and install vcpkg
id: vcpkg-step
run: |

Check failure on line 36 in .github/workflows/analysis-qodana-docker.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-docker.yml#L36

shellcheck reported issue in this script: SC2086:info:3:46: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-docker.yml:36:9: shellcheck reported issue in this script: SC2086:info:3:46: Double quote to prevent globbing and word splitting [shellcheck]
vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ')
echo "vcpkg commit ID: $vcpkgCommitId"
echo "VCPKG_GIT_COMMIT_ID=$vcpkgCommitId" >> $GITHUB_ENV
- name: Get vcpkg commit id from vcpkg.json
uses: lukka/run-vcpkg@main
with:
vcpkgGitURL: "https://github.com/microsoft/vcpkg.git"
vcpkgGitCommitId: ${{ env.VCPKG_GIT_COMMIT_ID }}

- name: Get latest CMake and ninja
uses: lukka/get-cmake@main

- name: Run CMake
uses: lukka/run-cmake@main
with:
configurePreset: linux-debug

- name: Qodana Scan
run: |

Check failure on line 56 in .github/workflows/analysis-qodana-docker.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-docker.yml#L56

shellcheck reported issue in this script: SC2046:warning:2:4: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-docker.yml:56:9: shellcheck reported issue in this script: SC2046:warning:2:4: Quote this to prevent word splitting [shellcheck]

Check failure on line 56 in .github/workflows/analysis-qodana-docker.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-docker.yml#L56

shellcheck reported issue in this script: SC2046:warning:3:4: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-docker.yml:56:9: shellcheck reported issue in this script: SC2046:warning:3:4: Quote this to prevent word splitting [shellcheck]

Check failure on line 56 in .github/workflows/analysis-qodana-docker.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/analysis-qodana-docker.yml#L56

shellcheck reported issue in this script: SC2046:warning:3:11: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/analysis-qodana-docker.yml:56:9: shellcheck reported issue in this script: SC2046:warning:3:11: Quote this to prevent word splitting [shellcheck]
docker run \
-v $(pwd):/data/project/ \
-v $(pwd):$(pwd) \
-e QODANA_TOKEN="${{ secrets.QODANA_TOKEN }}" \
jetbrains/qodana-clang:2024.1-eap \
--compile-commands ./build/linux-debug/compile_commands.json
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ endif()

set(VCPKG_FEATURE_FLAGS "versions")
set(VCPKG_BUILD_TYPE "release")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


# *****************************************************************************
# Project canary
Expand Down
15 changes: 13 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,19 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"DEBUG_LOG": "ON",
"SPEED_UP_BUILD_UNITY": "OFF",
"ASAN_ENABLED": "ON"
"SPEED_UP_BUILD_UNITY": "OFF"
}
},
{
"name": "linux-debug-asan",
"inherits": "linux-release",
"displayName": "Linux - Debug Build",
"description": "Build Debug Mode With ASAN Enable",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"DEBUG_LOG": "ON",
"ASAN_ENABLED": "ON",
"SPEED_UP_BUILD_UNITY": "OFF"
}
},
{
Expand Down

0 comments on commit 2058c0b

Please sign in to comment.