Use the official Codacy badges #249
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: Sonar | |
on: | |
push: | |
branches: | |
- main | |
- sonar | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
permissions: | |
contents: read | |
jobs: | |
build-and-scan: | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
env: | |
- { cc: clang, cxx: clang++ } | |
- { cc: gcc, cxx: g++ } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Qt | |
run: | | |
sudo apt-mark hold firefox grub-efi-amd64-signed | |
sudo apt update | |
sudo apt upgrade | |
sudo apt install qtbase5{,-doc}-dev qtconnectivity5-{dev,doc-html} qttools5-dev{,-tools} | |
- name: Install sonar-scanner and build-wrapper | |
uses: SonarSource/sonarcloud-github-c-cpp@v3 | |
- name: Run build-wrapper | |
env: | |
CC: ${{ matrix.env.cc }} | |
CXX: ${{ matrix.env.cxx }} | |
PROJECT_BUILD_ID: ${{ github.run_number }}.linux.x86-64.${{ matrix.env.cc }} | |
run: | | |
cmake -D CMAKE_BUILD_TYPE=Release -S "$GITHUB_WORKSPACE" -B "$RUNNER_TEMP" | |
build-wrapper-linux-x86-64 --out-dir "$RUNNER_TEMP/sonar" cmake --build "$RUNNER_TEMP" --config Release | |
- name: Run sonar-scanner | |
if: github.actor != 'dependabot[bot]' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
sonar-scanner --define project.settings=.sonar.properties \ | |
--define sonar.cfamily.compile-commands="$RUNNER_TEMP/sonar/compile_commands.json" |