Skip to content

Commit

Permalink
(CI) Try sonarcloud config from https://github.com/sonarsource-cfamil…
Browse files Browse the repository at this point in the history
  • Loading branch information
kdesnos committed Oct 4, 2021
1 parent b8f15e6 commit 8d757e2
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,36 +196,59 @@ jobs:
Analyze-Sonar:
runs-on: ubuntu-latest
#needs: [Build-Ubuntu, Build-MacOS-clang, Build-Windows-MSVC]
env:
SONAR_SCANNER_VERSION: 4.6.1.2450 # Find the latest version in the "Linux" link on this page:
# https://sonarcloud.io/documentation/analysis/scan/sonarscanner/
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: bw-output # Directory where build-wrapper output will be placed
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Install
run: |
sudo apt install doxygen gcovr
- name: Download Sonarcloud
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
curl -L -O https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -o build-wrapper-linux-x86.zip
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
- name: Build
run: |
cd bin
cmake .. -DCMAKE_BUILD_TYPE=Debug
cd ..
build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output cmake --build bin/ --target runTests
cmake -S . -B bin -DCMAKE_BUILD_TYPE=Debug
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build bin/ --target runTests
- name: Run Tests
run: |
cd bin
./bin/runTests
gcovr -r .. -s --sonarqube=sonarqube.xml
sed 's/ branchesToCover=\"[0-9]\+\" coveredBranches=\"[0-9]\+\"/ /g' sonarqube.xml > sonarqubecleaned.xml # Remove condition coverage info from report, only line coverage interests us.
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-X
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.BOT_DEPLOY_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"

0 comments on commit 8d757e2

Please sign in to comment.