Skip to content

Run code analysis

Run code analysis #116

Workflow file for this run

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 with coverage data
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: Convert 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
- name: Run sonar-scanner
run: |
scp compile_commands.json coverage.txt $SCAN_HOST:analysis/scsi2pi/cpp &&
rm compile_commands.json default.profraw coverage.dat coverage.txt &&
ssh $SCAN_HOST bin/analyze ${{ inputs.branch }}