Skip to content

Initial support for C++ 20 ranges #111

Initial support for C++ 20 ranges

Initial support for C++ 20 ranges #111

Workflow file for this run

name: SonarCloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
contents: read
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-22.04
env:
SONAR_SERVER_URL: "https://sonarcloud.io"
# Directory where build-wrapper output will be placed
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
CLANG_VERSION: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: 'True'
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang++-${{ env.CLANG_VERSION }} \
cmake \
libc++-${{ env.CLANG_VERSION }}-dev \
libc++abi-${{ env.CLANG_VERSION }}-dev \
ninja-build
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@e4882e1621ad2fb48dddfa48287411bed34789b1 # v2.0.2
- name: Perform build
run: |
mkdir build
cmake -G Ninja \
-S . \
-B build \
-D COVERAGE=Yes \
-D LIBCXX=Yes \
-D CMAKE_C_COMPILER=clang-${{ env.CLANG_VERSION }} \
-D CMAKE_CXX_COMPILER=clang++-${{ env.CLANG_VERSION }}
- name: Build
run: |
build-wrapper-linux-x86-64 \
--out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} \
cmake --build build/ --config Release
- name: Run test tools
run: |
LLVM_PROFILE_FILE="build/icubaby-unittests.profraw" ./build/unittests/icubaby-unittests && \
LLVM_PROFILE_FILE="build/icubaby-exhaust.profraw" ./build/tests/exhaust/icubaby-exhaust-test && \
LLVM_PROFILE_FILE="build/iconv-test.profraw" ./build/tests/iconv/iconv-test && \
LLVM_PROFILE_FILE="build/demo8.profraw" ./build/tests/demo8/demo8
- name: Index the raw profile
run: |
llvm-profdata-${{ env.CLANG_VERSION }} merge -sparse build/*.profraw -o build/merged.profdata
- name: Collect the coverage
run: |
{ \
llvm-cov-${{ env.CLANG_VERSION }} show --instr-profile build/merged.profdata ./build/unittests/icubaby-unittests && \
llvm-cov-${{ env.CLANG_VERSION }} show --instr-profile build/merged.profdata ./build/tests/exhaust/icubaby-exhaust-test && \
llvm-cov-${{ env.CLANG_VERSION }} show --instr-profile build/merged.profdata ./build/tests/iconv/iconv-test && \
llvm-cov-${{ env.CLANG_VERSION }} show --instr-profile build/merged.profdata ./build/tests/demo8/demo8
} > coverage.txt
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-X \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define sonar.cfamily.llvm-cov.reportPath=coverage.txt \
--define sonar.exclusions='build/**/*','docs/**/*' \
--define sonar.host.url="${{ env.SONAR_SERVER_URL }}" \
--define sonar.organization=paulhuggett-github \
--define sonar.projectKey=paulhuggett_icubaby \
--define sonar.projectVersion="$(git rev-parse HEAD)" \
--define sonar.sourceEncoding=UTF-8