image: ubuntu:22.04 variables: SONAR_SERVER_URL: https://sonarcloud.io SONAR_SCANNER_VERSION: 4.6.1.2450 BUILD_WRAPPER_OUT_DIR: bw-output # Directory where build-wrapper output will be placed SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task # note that SONAR_TOKEN is transmitted to the environment through Gitlab CI stages: - .pre - build get-sonar-binaries: # this job download and unpacks the build-wrapper and the sonar-scanner # in this example it is done for every build. # This can be optimized by caching the files or better, by including them, in the build docker image. stage: .pre before_script: - DEBIAN_FRONTEND=noninteractive apt-get update - DEBIAN_FRONTEND=noninteractive apt install -y curl zip unzip script: # Download sonar-scanner - curl -sSLo sonar-scanner.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip" - unzip -o sonar-scanner.zip - mv sonar-scanner-${SONAR_SCANNER_VERSION}-linux sonar-scanner # Download build-wrapper - curl -sSLo build-wrapper.zip "${SONAR_SERVER_URL}/static/cpp/build-wrapper-linux-x86.zip" - unzip -o build-wrapper.zip - mv build-wrapper-linux-x86 build-wrapper cache: policy: push key: "${CI_COMMIT_SHORT_SHA}" paths: - build-wrapper/ # to share the build-wrapper between jobs - sonar-scanner/ # to share the sonar-scanner between jobs build: stage: build # install the necessary build tools when needed before_script: - DEBIAN_FRONTEND=noninteractive apt-get update - DEBIAN_FRONTEND=noninteractive apt install -y gcc g++ cmake make curl git flex bison libeigen3-dev uuid-dev libboost-system-dev libboost-program-options-dev libboost-test-dev libboost-timer-dev libboost-chrono-dev libboost-serialization-dev libbliss-dev gcovr zip unzip - git clone --depth 1 --branch 22.12 https://github.com/ths-rwth/carl carl && cd carl - mkdir build && cd build && cmake .. -DUSE_LIBPOLY=OFF - make -j`nproc` carl-common - make -j`nproc` carl-arith - make -j`nproc` carl-logging - make -j`nproc` carl-formula - cd ../.. script: # prepare the build tree - mkdir build && cd build && cmake .. -DHYPRO_CICD=ON && cd .. # run the build inside the build wrapper - build-wrapper/build-wrapper-linux-x86-64 --out-dir "${BUILD_WRAPPER_OUT_DIR}" cmake --build build/ --config Release # execute tests - required to get coverage reports - cd build && make test # collect coverage and write it to coverage.xml, which will be collected by the scanner - gcovr -r ../ --sonarqube ../coverage.xml && cd .. # run the scanner to collect and upload all information on static analysis and coverage - sonar-scanner/bin/sonar-scanner -X --define sonar.host.url="${SONAR_SERVER_URL}" -Dsonar.token="${SONAR_TOKEN}" artifacts: paths: - . exclude: - .git - .git/**/* - build/**/*.o expire_in: 3 days cache: policy: pull-push key: "${CI_COMMIT_SHORT_SHA}" paths: - build-wrapper/ - sonar-scanner/