let sonarcloud takes automated tests into account and report coverage

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2021-10-18 12:09:22 +02:00 committed by Matthieu Gallien (Rebase PR Action)
parent a10ffb1676
commit 7a6bc830dd
3 changed files with 26 additions and 10 deletions

View file

@ -3,7 +3,7 @@ name: qt-5.15
steps:
- name: cmake
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build
@ -11,7 +11,7 @@ steps:
- cd /drone/build
- cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror ../src
- name: compile
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build
@ -19,7 +19,7 @@ steps:
- cd /drone/build
- make -j$(nproc)
- name: test
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build
@ -47,7 +47,7 @@ name: qt-5.15-clang
steps:
- name: cmake
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build
@ -55,7 +55,7 @@ steps:
- cd /drone/build
- cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Debug -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DECM_ENABLE_SANITIZERS=address -DCMAKE_CXX_FLAGS=-Werror ../src
- name: compile
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build
@ -63,7 +63,7 @@ steps:
- cd /drone/build
- ninja
- name: test
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build
@ -73,7 +73,7 @@ steps:
- chown -R test:test .
- su -c 'ASAN_OPTIONS=detect_leaks=0 xvfb-run ctest --output-on-failure' test
- name: clang-tidy
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-2
image: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
volumes:
- name: build
path: /drone/build

View file

@ -9,7 +9,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
container: ghcr.io/nextcloud/continuous-integration-client:client-5.15-3
container: ghcr.io/nextcloud/continuous-integration-client:client-5.15-4
env:
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
@ -27,11 +27,24 @@ jobs:
- name: Run build-wrapper
run: |
mkdir build
cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Release -DBUILD_UPDATER=ON -DBUILD_TESTING=1
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ninja
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DBUILD_COVERAGE=ON
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j 2
- name: Run tests
run: |
cd build
useradd -m -s /bin/bash test
chown -R test:test .
su -c 'xvfb-run ctest --output-on-failure --output-junit testResult.xml' test
- name: Generate coverage report
run: |
cd build
su -c 'ctest -T Coverage' test
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
cp sonar-project.properties build
cd build
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"

View file

@ -1,9 +1,12 @@
sonar.projectKey=nextcloud_desktop
sonar.organization=nextcloud
sonar.projectBaseDir=..
sonar.sources=src
sonar.exclusions=3rdparty/**
sonar.language=c++
sonar.cfamily.cache.enabled=false
sonar.sourceEncoding=UTF-8
sonar.cfamily.threads=2
sonar.cfamily.gcov.reportsPath=build/Testing/CoverageInfo
sonar.cfamily.cache.enabled=true,
sonar.cfamily.cache.path=/cache/sonarcloud