From 29da532955ddc6127bd25262804940f9fb94de2a Mon Sep 17 00:00:00 2001 From: Edgar Date: Sat, 26 Nov 2022 17:25:53 +0100 Subject: [PATCH] :tada: Added sonarcloud scan --- .github/workflows/sonarcloud.yml | 56 ++++++++++++++++++++++++++++++++ sonar-project.properties | 16 +++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000000..1eb1611008 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,56 @@ +name: sonarcloud scan +on: + push: + branches: + - master + - sonarcloud + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: sonarcloud scan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install sonar-scanner and build-wrapper + uses: sonarsource/sonarcloud-github-c-cpp@v1 + id: sonarscan + + - name: Cache conan + uses: actions/cache@v3 + with: + key: conan-ubuntu-${{ hashFiles('conanfile.py') }} + path: ~/.conan2/ + + - name: Install dependencies + run: | + curl "https://raw.githubusercontent.com/AnotherFoxGuy/ci-scripts/main/install-conan.sh" | sudo bash + sudo apt-get update + wget -nv https://cdn.anotherfoxguy.com/sonar-scanner/ror -O run-sonar-scanner + sudo chmod 777 run-sonar-scanner + + - name: Configure + run: | + conan profile detect --force + echo "tools.system.package_manager:mode = install" > ~/.conan2/global.conf + echo "tools.system.package_manager:sudo = True" >> ~/.conan2/global.conf + conan remote add ror-conan https://git.anotherfoxguy.com/api/packages/rorbot/conan -f + conan install . -s build_type=Release -b missing -pr:b=default + cmake --preset conan-release -DCMAKE_INSTALL_PREFIX=redist -DCREATE_CONTENT_FOLDER=ON + shell: bash + + - name: Run build-wrapper + run: build-wrapper-linux-x86-64 --out-dir bw-output make -j4 + + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_SCANNER_EXE: ${{ steps.sonarscan.outputs.sonar-scanner-binary }} + run: ./run-sonar-scanner + + - name: Clean Conan pkgs + run: conan cache clean "*" -sbd + shell: bash diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..6393afa59d --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,16 @@ +sonar.host.url=https://sonarcloud.io +sonar.projectKey=rigs-of-rods +sonar.organization=anotherfoxguy-github + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=rigs-of-rods +sonar.projectVersion=2022.04 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=source + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 + +sonar.cfamily.threads=2 +sonar.cfamily.build-wrapper-output=bw-output \ No newline at end of file