60 lines
2.1 KiB
YAML
60 lines
2.1 KiB
YAML
name: sonarcloud scan
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- dev
|
|
pull_request:
|
|
types: [ opened, synchronize, reopened ]
|
|
jobs:
|
|
build:
|
|
name: sonarcloud scan
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
SONAR_SCANNER_VERSION: 4.7.0.2747
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 11
|
|
|
|
- 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: |
|
|
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/
|
|
wget -nv https://cdn.anotherfoxguy.com/sonar-scanner/mofilereader -O run-sonar-scanner
|
|
sudo chmod 777 run-sonar-scanner
|
|
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: https://sonarcloud.io/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: Configure
|
|
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TEST=ON -DENABLE_COVERAGE=ON .
|
|
|
|
- name: Run build-wrapper
|
|
run: build-wrapper-linux-x86-64 --out-dir bw-output make -j4
|
|
|
|
- name: Test
|
|
run: ctest --output-on-failure .
|
|
|
|
- name: Generate coverage
|
|
run: make gcov
|
|
|
|
- name: Run sonar-scanner
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SONAR_SCANNER_EXE: /home/runner/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin/sonar-scanner
|
|
run: ./run-sonar-scanner
|