Skip to content

♻️Refactoring: Static analysis #434

♻️Refactoring: Static analysis

♻️Refactoring: Static analysis #434

name: SonarCloud analysis
on:
push:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
jobs:
Analysis:
runs-on: macos-13
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Brewing ...
run: |
brew update
brew upgrade || true
brew link --overwrite python
brew install pkg-config m4 libtool automake autoconf
brew install coreutils
brew install qt
brew link --force qt
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Build 3rd-party sources
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DAPPLE_FAT_ARCH=OFF -DBUILD_DEPENDENCIES=ON -H. -Bbuild_sonar ${{github.workspace}}
cmake --build build_sonar
cd build_sonar
gls -Q | grep -v EPs | xargs rm -rf
cd ..
- name: Run build-wrapper
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DAPPLE_FAT_ARCH=OFF -H. -Bbuild_sonar ${{github.workspace}}
build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build_sonar
find build_sonar -type f
- name: Run tests
run: |
test_execs=($(find . -type f -name "tests_*" | grep '\.app/Contents/MacOS/tests_'))
echo "^^ ${test_execs[@]} ^^"
i=0
for test_exec in ${test_execs[@]}
do
i=$((i+1))
chmod 755 $test_exec
LLVM_PROFILE_FILE="$i.profraw" $test_exec
done
xcrun llvm-profdata merge -sparse *.profraw -o voo_tests.profdata
cov_arguments=""
for test_exec in ${test_execs[@]}
do
cov_arguments="$cov_arguments -object $test_exec"
done
xcrun llvm-cov show --show-branches=count -instr-profile=voo_tests.profdata $cov_arguments > coverage.txt
- name: Analyze with SonarCloud
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.cfamily.llvm-cov.reportPath=coverage.txt