From 7532f0a4d67aa3bb2bf3e960584342b2f3f90c9a Mon Sep 17 00:00:00 2001 From: Andrei Pashkin Date: Mon, 4 Jan 2021 00:37:23 +0300 Subject: [PATCH] Introduce SonarLint. #5 --- .github/workflows/main.yml | 44 ++++++++++++++++++++++++++++++++++++++ sonar-project.properties | 6 ++++++ 2 files changed, 50 insertions(+) create mode 100644 sonar-project.properties diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 807c16b..fe665e7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,9 @@ on: branches: [ master ] workflow_dispatch: +env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + jobs: black-check: runs-on: ubuntu-18.04 @@ -99,3 +102,44 @@ jobs: deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main - run: cmake . - run: make clang-format-check + sonarlint: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.8-dev' + - uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Cache C++ third-party dependencies + uses: actions/cache@v2 + with: + path: ${{ github.workspace }}/thirdparty + key: ${{ runner.os }}-thirdparty-${{ hashFiles('FetchDependencies.cmake') }} + - name: Install CMake 3.19 + run: sudo snap install cmake --channel=3.19/stable --classic + - name: Install SonarScanner + env: + SONAR_HOME: ${{ secrets.SONAR_TOKEN }} + SONAR_SCANNER_VERSION: 4.4.0.2170 + run: | + mkdir -p ~/.sonar/ + export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux + wget -O ~/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip + unzip -o ~/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + export PATH=$SONAR_SCANNER_HOME/bin:$PATH + + wget -O ~/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip + unzip -o ~/.sonar/build-wrapper-linux-x86.zip -d ~/.sonar/ + echo "PATH=~/.sonar/build-wrapper-linux-x86:$PATH" >> $GITHUB_ENV + echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV + - name: Run CMake + run: cmake . + - name: Run Build Wrapper + run: build-wrapper-linux-x86-64 --out-dir bw-output cmake --build . + - name: Run SonarScanner + run: + sonar-scanner + -Dsonar.cfamily.build-wrapper-output=bw-output + -Dsonar.projectVersion="$(python scripts/write_version.py -P)" diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..6842a6a --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectName=Gauge +sonar.organization=andreipashkin-github +sonar.projectVersion=0.0.2 +sonar.projectKey=GAUGE +sonar.sources=./src/cpp,./src/py +sonar.host.url=https://sonarcloud.io