Run code analysis #115
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 Sonar analysis | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
required: true | |
type: string | |
description: Branch to analyze | |
jobs: | |
code_analysis: | |
runs-on: [ARM64] | |
defaults: | |
run: | |
working-directory: cpp | |
env: | |
SONAR_SERVER_URL: "https://sonarcloud.io" | |
SONAR_PROJECT_KEY: "uweseimet_scsi2pi" | |
SONAR_ORGANIZATION: "uweseimet-org" | |
SCAN_HOST: ${{ secrets.SCAN_HOST }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: uweseimet/scsi2pi | |
ref: ${{ inputs.branch }} | |
fetch-depth: 0 | |
- name: Compile | |
run: | | |
make -j $(nproc) EXTRA_FLAGS="-fprofile-instr-generate -fcoverage-mapping" CXX=clang++ DEBUG=1 DATABASE=1 test && | |
sed -e '1s/^/[\n/' -e '$s/,$/\n]/' obj/*.o.json > compile_commands.json | |
- name: Generate coverage data | |
run: | | |
llvm-profdata merge default.profraw > coverage.dat && | |
llvm-cov show --show-branches=count --instr-profile coverage.dat bin/s2p_test > coverage.txt && | |
rm default.profraw coverage.dat | |
- name: Run sonar-scanner | |
run: | | |
scp compile_commands.json coverage.txt $SCAN_HOST:analysis/scsi2pi/cpp && | |
ssh $SCAN_HOST bin/analyze ${{ inputs.branch }} |