Run code analysis #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run SonarCloud analysis | |
on: | |
workflow_dispatch: | |
jobs: | |
code_analysis: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: cpp | |
env: | |
PACKAGES: gcovr protobuf-compiler libspdlog-dev libpcap-dev libprotobuf-dev libgmock-dev | |
BUILD_WRAPPER_OUT_DIR: "$HOME/.build_wrapper_out" | |
SONAR_SERVER_URL: "https://sonarcloud.io" | |
SONAR_PROJECT_KEY: "uweseimet_scsi2pi" | |
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Shallow clones should be disabled for a better relevancy of analysis | |
fetch-depth: 0 | |
- name: Install additional packages | |
run: sudo apt install --yes ${{ env.PACKAGES }} | |
- name: Build and run tests | |
run: make -j $(nproc) coverage DEBUG=1 | |
- name: Generate coverage data | |
run: gcovr --sonarqube > coverage.xml | |
- name: Run sonar-scanner | |
uses: sonarsource/sonarcloud-github-action@master | |
with: | |
projectBaseDir: cpp | |
args: > | |
-Dsonar.host.url=${{ env.SONAR_SERVER_URL }} | |
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} | |
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }} | |
-Dsonar.cfamily.build-wrapper-output=${{ env.BUILD_WRAPPER_OUT_DIR }} | |
-Dsonar.coverageReportPaths=coverage.xml | |
-Dsonar.exclusions="obj/**,bin/**,generated/**" | |
-Dsonar.coverage.exclusions="test/**" | |
-Dsonar.cpd.exclusions="test/**" |