Skip to content

Commit

Permalink
Introduce SonarLint.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiPashkin committed Jan 3, 2021
1 parent 037b867 commit 8ae4795
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
branches: [ master ]
workflow_dispatch:

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

jobs:
black-check:
runs-on: ubuntu-18.04
Expand Down Expand Up @@ -99,3 +102,82 @@ 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
env:
CXX: /usr/bin/clang-11
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 Pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- name: Cache Tox environments
uses: actions/cache@v2
with:
path: .tox
key: ${{ runner.os }}-tox-${{ hashFiles('tox.ini') }}
- name: Install Tox
run: pip install tox>=3
- name: Cache C++ third-party dependencies
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/thirdparty
key: ${{ runner.os }}-thirdparty-${{ hashFiles('FetchDependencies.cmake') }}
- name: SonarLint cache
uses: actions/cache@v2
with:
path: /home/runner/.sonar/cache
key: ${{ runner.os }}-sonar-${{ hashFiles('sonar-project.properties') }}
- name: Install CMake 3.19
run: sudo snap install cmake --channel=3.19/stable --classic
- name: Install Clang
run: |
sudo apt-get purge -y clang*
sudo sh -c "echo '$CLANG_APT' >> /etc/apt/sources.list"
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y clang-11
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang-11 0
env:
CLANG_APT: |
# i386 not available
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic main
# 10
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main
# 11
deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main
deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main
- 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="$(tox -e write_version -- -P)"
6 changes: 6 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8ae4795

Please sign in to comment.