Merge pull request #135 from CubbyFlow/lgtm #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ubuntu - SonarCloud | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build-ubuntu: | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.name }} | |
strategy: | |
matrix: | |
include: | |
# Ubuntu 20.04 + gcc-9 | |
- name: "Ubuntu 20.04 + gcc-9" | |
os: ubuntu-20.04 | |
compiler: gcc | |
version: "9" | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Prepare Sonar scanner | |
run: | | |
wget -nv https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.0.2311-linux.zip | |
unzip -q sonar-scanner-cli-4.6.0.2311-linux.zip | |
echo "${PWD}/sonar-scanner-4.6.0.2311-linux/bin/" >> $GITHUB_PATH | |
wget -nv https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip | |
unzip -q build-wrapper-linux-x86.zip | |
echo "${PWD}/build-wrapper-linux-x86" >> $GITHUB_PATH | |
- name: Install packages | |
run: sudo apt-get install -yq gcovr ggcov lcov curl | |
- name: Configure Compiler | |
run: | | |
if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV | |
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV | |
else | |
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV | |
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV | |
fi | |
- name: Configure Build | |
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_COVERAGE=ON -DBUILD_SONARCLOUD=ON .. | |
- name: Build | |
run: cd build && build-wrapper-linux-x86-64 --out-dir ../bw-output make all | |
- name: Run Unit Test | |
run: | | |
cd build | |
lcov --gcov-tool /usr/bin/gcov -c -i -d Tests/UnitTests -o base.info | |
bin/UnitTests | |
lcov --gcov-tool /usr/bin/gcov -c -d Tests/UnitTests -o test.info | |
lcov --gcov-tool /usr/bin/gcov -a base.info -a test.info -o coverage.info | |
lcov --gcov-tool /usr/bin/gcov -r coverage.info '/usr/*' -o coverage.info | |
lcov --gcov-tool /usr/bin/gcov -r coverage.info '*/Examples/*' -o coverage.info | |
lcov --gcov-tool /usr/bin/gcov -r coverage.info '*/Libraries/*' -o coverage.info | |
lcov --gcov-tool /usr/bin/gcov -r coverage.info '*/Tests/*' -o coverage.info | |
lcov --gcov-tool /usr/bin/gcov -l coverage.info | |
- name: SonarCloud Scan | |
run: sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=cubbyflow -Dsonar.login=$SONAR_TOKEN | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |