Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: SonarCloud Analysis

permissions:
contents: read

on:
workflow_dispatch:
push:
pull_request:

jobs:
sonarcloud:
runs-on: 'ubuntu-latest'
container:
image: 'ghcr.io/llvm/ci-ubuntu-22.04:latest'
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/checkout@v4
with:
fetch-depth: 1
# necessary for install sonar-scanner
- name: Install unzip
run: |
apt update
apt install unzip
- name: Install sonar-scanner
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
# A full build of llvm, clang, lld, and lldb takes about 250MB
# of ccache space. There's not much reason to have more than this,
# because we usually won't need to save cache entries from older
# builds. Also, there is an overall 10GB cache limit, and each
# run creates a new cache entry so we want to ensure that we have
# enough cache space for all the tests to run at once and still
# fit under the 10 GB limit.
# Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
max-size: 2G
key: clang-build-sonar
variant: sccache
- name: Config CMake
shell: bash
id: config-llvm
run: |
builddir="$PWD/build"
mkdir -p $builddir
echo "llvm-builddir=$builddir" >> "$GITHUB_OUTPUT"
cmake -G Ninja \
-B "$builddir" \
-S llvm \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_ENABLE_PROJECTS="clang;lldb;libclc" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLDB_INCLUDE_TESTS=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang
- name: Minimal Build
shell: bash
env:
LLVM_BUILDDIR: ${{ steps.config-llvm.outputs.llvm-builddir }}
run: |
ninja -v -C "$LLVM_BUILDDIR" \
ClangAttrDocTable \
Opcodes \
clangAnalysisFlowSensitiveResources \
clangBasic \
ClangOpenCLBuiltinsImpl
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
LLVM_BUILDDIR: ${{ steps.config-llvm.outputs.llvm-builddir }}
run: |
sonar-scanner --define sonar.cfamily.compile-commands="$LLVM_BUILDDIR/compile_commands.json"
11 changes: 11 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.projectKey=necto_llvm-project
sonar.organization=necto
sonar.sources=clang/lib

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=llvm-project
#sonar.projectVersion=1.0


# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8