Skip to content

Commit

Permalink
Add static-analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Nov 7, 2023
1 parent 7242535 commit 52d7a26
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ jobs:
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml

static-analysis:
needs: [ pre-commit ]
uses: ./.github/workflows/step_static-analysis.yaml
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

pass:
needs: [ pre-commit, tests ]
needs: [ pre-commit, tests, static-analysis ]
runs-on: ubuntu-latest
steps:
- name: Check all CI jobs
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/step_static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: static-analysis
on:
workflow_call:
secrets:
SONAR_TOKEN:
required: true
jobs:
sonar-cloud:
name: Analyze with SonarCloud
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v4
- name: Set up Python for gcovr
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: install gcovr
run: |
pip install gcovr
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Run cmake/ctest with sonar build-wrapper
run: |
cmake --preset gcc-ci --fresh -G "Unix Makefiles"
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build --preset gcc-ci
ctest --preset gcc-ci
gcovr --sonarqube > coverage.xml
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define sonar.coverageReportPaths=coverage.xml
5 changes: 5 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonar.projectKey=LecrisUT_CMake-Template
sonar.organization=lecris

sonar.projectName="CMake Template"
sonar.coverage.exclusions=test/**

0 comments on commit 52d7a26

Please sign in to comment.