Skip to content

Commit 32f85dd

Browse files
committed
add workflow for sonarcube
1 parent 87d2f03 commit 32f85dd

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/sonarcube.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
env:
13+
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18+
- name: Install Build Wrapper
19+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4
20+
- name: Run Build Wrapper
21+
run: |
22+
mkdir build
23+
cmake -S . -B build
24+
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release
25+
- name: SonarQube Scan
26+
uses: SonarSource/sonarqube-scan-action@v4
27+
env:
28+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
29+
with:
30+
args: >
31+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ else()
2222
add_definitions(-Wpedantic -fno-omit-frame-pointer)
2323
endif()
2424

25+
# create compile_commands.json
26+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
27+
2528

2629
#---- project configuration ----
2730
option(BTCPP_SHARED_LIBS "Build shared libraries" ON)

0 commit comments

Comments
 (0)