When we want to use the base runners they do not have git Install devscripts for debian images that will make packages
82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
name: "SonarCloud Analysis"
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
secrets:
|
|
SONAR_TOKEN:
|
|
required: true
|
|
|
|
jobs:
|
|
sonarcloud-analysis:
|
|
if: ${{ vars.SONAR_SCANNER_ENABLED }}
|
|
|
|
runs-on: ubuntu-latest
|
|
container: deskflow/deskflow:debian-13-amd64
|
|
timeout-minutes: 20
|
|
|
|
env:
|
|
SONAR_SCANNER_VERSION: 6.1.0.4477
|
|
SONAR_SCANNER_OPTS: -server
|
|
SONAR_SCANNER_URL_BASE: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli
|
|
CPU_CORE_COUNT: ${{ vars.SONAR_SCANNER_CPU_COUNT || 4 }}
|
|
|
|
steps:
|
|
- name: Install container dependencies
|
|
run: |
|
|
apt update -qqq > /dev/null
|
|
apt install -qqq git curl unzip gcovr > /dev/null
|
|
|
|
- name: Fancy Checkout
|
|
uses: sithlord48/fancy-checkout@v1.0.0
|
|
|
|
- name: Install project dependencies
|
|
uses: ./.github/actions/install-dependencies
|
|
with:
|
|
like: "debian"
|
|
|
|
- name: Install sonar-scanner and build-wrapper
|
|
uses: sonarsource/sonarcloud-github-c-cpp@v3
|
|
|
|
- name: Configure
|
|
run: |
|
|
cmake -B build \
|
|
-G "Ninja" \
|
|
-DCMAKE_BUILD_TYPE="Debug" \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
|
-DENABLE_COVERAGE=ON
|
|
|
|
- name: Build
|
|
run: |
|
|
build-wrapper-linux-x86-64 --out-dir bw-output cmake --build build -j${CPU_CORE_COUNT}
|
|
|
|
- name: Unit tests coverage
|
|
env:
|
|
QT_QPA_PLATFORM: offscreen
|
|
run: cmake --build build --target coverage-unittests
|
|
|
|
- name: Integration tests coverage
|
|
env:
|
|
QT_QPA_PLATFORM: offscreen
|
|
run: cmake --build build --target coverage-integtests
|
|
|
|
- name: Get coverage report paths
|
|
id: coverage-paths
|
|
run: |
|
|
unittests=$(find build -name coverage-unittests.xml)
|
|
integtests=$(find build -name coverage-integtests.xml)
|
|
paths="${unittests}${integtests:+,$integtests}"
|
|
if [ -z "$paths" ]; then
|
|
echo "Error: No coverage files found"
|
|
exit 1
|
|
fi
|
|
echo "csv=$paths" >> $GITHUB_OUTPUT
|
|
|
|
- name: Run SonarScanner
|
|
run: |
|
|
export PATH=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64/bin:$PATH
|
|
sonar-scanner \
|
|
-Dsonar.coverageReportPaths=${{ steps.coverage-paths.outputs.csv }} \
|
|
-Dsonar.cfamily.threads=${{ env.CPU_CORE_COUNT }}
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|