Skip to content

Release/1.0.4

Release/1.0.4 #129

Workflow file for this run

name: SonarQube
on:
push:
branches:
- main
paths:
- '**/*.cpp'
- '**/*.hpp'
- '**/*.h'
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install Build Wrapper
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5
- name: Build backend tests with coverage
run: |
sudo apt-get update
sudo apt-get install -y libgtest-dev cmake
cd /usr/src/gtest && sudo cmake . && sudo make && sudo cp lib/*.a /usr/lib
cd $GITHUB_WORKSPACE
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} \
g++ -std=gnu++2a -O0 -g --coverage -fprofile-arcs -ftest-coverage \
src/backend/grammar.cpp \
src/backend/grammar_factory.cpp \
src/backend/ll1_parser.cpp \
src/backend/lr0_item.cpp \
src/backend/slr1_parser.cpp \
src/backend/symbol_table.cpp \
src/backend/tests.cpp \
-Isrc/backend \
-lgtest -lgtest_main \
-o test_runner
- name: Run tests and dump XML
run: ./test_runner
- name: Install gcovr & generate SonarQube XML coverage
run: |
sudo apt-get update
sudo apt-get install -y gcovr
gcovr -r . --filter '.*src/backend/.*' --exclude-unreachable-branches --exclude-throw-branches --sonarqube --output coverage.xml
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_KEY }}
with:
args: >
--define sonar.cfamily.build-wrapper-output=${{ env.BUILD_WRAPPER_OUT_DIR }}
--define sonar.coverageReportPaths=coverage.xml
--define sonar.qualitygate.breakBuild=false