Skip to content

Commit

Permalink
let sonarcloud takes automated tests into account and report coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Oct 20, 2021
1 parent a10ffb1 commit 7a6bc83
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
14 changes: 7 additions & 7 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ 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
commands:
- 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
commands:
- 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
Expand Down Expand Up @@ -47,23 +47,23 @@ 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
commands:
- 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
commands:
- 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
Expand All @@ -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
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}"
3 changes: 3 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7a6bc83

Please sign in to comment.