Skip to content

Bump actions/upload-artifact from 4.3.3 to 4.3.4 (#195) #648

Bump actions/upload-artifact from 4.3.3 to 4.3.4 (#195)

Bump actions/upload-artifact from 4.3.3 to 4.3.4 (#195) #648

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
WRAPPER_OUT: build_wrapper_output_directory
CLANG_VERSION: 18
BUILD_DIR: build
COVERAGE: "./coverage.txt"
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: True
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@6871f53176ad61624f978536bbf089c574dc19a2 # v8.0.1
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
- name: Install Dependencies (LLVM)
uses: paulhuggett/install-llvm@ad897b4b1cf03f54c1218ec6d97a23ff4b10b870 # v1.0
with:
version: ${{ env.CLANG_VERSION }}
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@e25edaefff1e076daf6517d462ed86f8c99fec70 # v3.0.0
- name: CMake Configure
run: |
mkdir "$BUILD_DIR"
cmake -G Ninja \
-S . \
-B "$BUILD_DIR" \
-D ICUBABY_COVERAGE=Yes \
-D "CMAKE_C_COMPILER=clang-$CLANG_VERSION" \
-D "CMAKE_CXX_COMPILER=clang++-$CLANG_VERSION"
- name: Build
run: |
build-wrapper-linux-x86-64 \
--out-dir "$WRAPPER_OUT" \
cmake --build "$BUILD_DIR" --config Release
- name: Run Test Tools
run: |
set -v
TESTS="\
tests/iconv/iconv-test \
tests/ranges/ranges \
tests/demo8/demo8 \
tests/exhaust/icubaby-exhaust-test \
tests/performance/performance \
unittests/icubaby-unittests"
for f in $TESTS; do
P="$BUILD_DIR/$f"
LLVM_PROFILE_FILE="$P.profraw" $P
done
- name: Index the Raw Profiles
run: |
find "$BUILD_DIR" -name \*.profraw -print0 |
xargs -0 \
"llvm-profdata-$CLANG_VERSION" \
merge \
-o "$BUILD_DIR/merged.profdata" \
-sparse
- name: Collect Coverage
run: |
{ \
find "$BUILD_DIR" -name CMakeFiles -prune -type f -or -type f -perm -u=x -print0 | \
xargs -0 -n 1 "llvm-cov-$CLANG_VERSION" show --instr-profile build/merged.profdata
} > "$COVERAGE"
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
echo "Running on branch: ${{ steps.branch-names.outputs.current_branch }}"
echo "Base branch: ${{ steps.branch-names.outputs.base_ref_branch }}"
sonar-scanner \
-X \
--define sonar.branch.name="${{ steps.branch-names.outputs.current_branch }}" \
--define sonar.branch.target="${{ steps.branch-names.outputs.base_ref_branch }}" \
--define sonar.cfamily.compile-commands="$WRAPPER_OUT/compile_commands.json" \
--define sonar.exclusions="$BUILD_DIR/**/*,docs/**/*" \
--define sonar.host.url="$SONAR_SERVER_URL" \
--define sonar.organization=paulhuggett-github \
--define sonar.projectKey=paulhuggett_icubaby \
--define sonar.projectVersion="$(git rev-parse HEAD)" \
--define sonar.python.version=3.7,3.8,3.9,3.10,3.11 \
--define sonar.sourceEncoding=UTF-8
# Disabled due to exception from Sonar.
#--define sonar.cfamily.llvm-cov.reportPath="$COVERAGE"