Skip to content

Commit 62c142a

Browse files
workflows: add sonarcloud
Add sonarcloud workflow. Signed-off-by: Giacomo Dematteis <giacomo.dematteis@nordicsemi.no>
1 parent a129d3f commit 62c142a

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.github/workflows/sonarcloud.yml

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Twister native sim (No Sonarcloud yet)
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- ".github/workflows/docs-build-and-publish.yml"
8+
- "docs/**"
9+
pull_request:
10+
paths:
11+
- '**/*.c'
12+
- '**/*.h'
13+
- west.yml
14+
- '**/CMakelists.txt'
15+
- '**/Kconfig*'
16+
- '**/prj.conf'
17+
jobs:
18+
build:
19+
name: Build and analyze
20+
runs-on: ubuntu-latest
21+
container: ghcr.io/zephyrproject-rtos/ci:v0.27.4
22+
env:
23+
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
24+
CMAKE_PREFIX_PATH: /opt/toolchains
25+
steps:
26+
- uses: actions/checkout@v4
27+
if: github.event_name == 'pull_request'
28+
with:
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
31+
path: asset-tracker-template
32+
33+
- uses: actions/checkout@v4
34+
if: github.event_name != 'pull_request'
35+
with:
36+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
37+
path: asset-tracker-template
38+
39+
- name: Initialize
40+
working-directory: asset-tracker-template
41+
run: |
42+
west init -l .
43+
west config manifest.group-filter +bsec
44+
west config build.sysbuild True
45+
west update -o=--depth=1 -n
46+
west blobs fetch hal_nordic
47+
48+
- name: Install dependencies
49+
run: |
50+
pip install -r nrf/scripts/requirements-build.txt
51+
apt-get update
52+
apt install -y curl ruby-full
53+
54+
# - name: Install sonar-scanner and build-wrapper
55+
# uses: SonarSource/sonarcloud-github-c-cpp@v3
56+
57+
# - name: Build and test native sim
58+
# working-directory: asset-tracker-template
59+
# run: |
60+
# west twister -T . -C --coverage-platform=native_sim -v --inline-logs --integration
61+
62+
# - name: Build and test
63+
# working-directory: asset-tracker-template
64+
# run: |
65+
# build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} west twister -T . -C --coverage-platform=native_sim -v --inline-logs --integration
66+
67+
# - name: Extract coverage into sonarqube xml format
68+
# working-directory: asset-tracker-template
69+
# run: |
70+
# gcovr twister-out -v --merge-mode-functions=separate --exclude='twister-out|drivers' --sonarqube coverage.xml
71+
72+
# - name: Run sonar-scanner on main
73+
# working-directory: asset-tracker-template
74+
# if: github.event_name != 'pull_request'
75+
# env:
76+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
78+
# run: |
79+
# sonar-scanner \
80+
# --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
81+
# --define project.settings=sonar-project.properties \
82+
# --define sonar.coverageReportPaths=coverage.xml \
83+
# --define sonar.inclusions=**/*.c,**/*.h \
84+
# --define sonar.exclusions=tests/,drivers/sensor/*_dummy/
85+
86+
# - name: Run sonar-scanner on PR
87+
# working-directory: asset-tracker-template
88+
# if: github.event_name == 'pull_request'
89+
# env:
90+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
92+
# PR_NUMBER: ${{ github.event.pull_request.number }}
93+
# PR_BRANCH: ${{ github.event.pull_request.head.ref }}
94+
# BASE_REF: ${{ github.event.pull_request.base.ref }}
95+
# HEAD_SHA: ${{ github.event.pull_request.head.sha }}
96+
# run: |
97+
# sonar-scanner \
98+
# --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
99+
# --define project.settings=sonar-project.properties \
100+
# --define sonar.coverageReportPaths=coverage.xml \
101+
# --define sonar.inclusions=**/*.c,**/*.h \
102+
# --define sonar.exclusions=tests/,drivers/sensor/*_dummy/ \
103+
# --define sonar.scm.revision=${{ env.HEAD_SHA }} \
104+
# --define sonar.pullrequest.key=${{ env.PR_NUMBER }} \
105+
# --define sonar.pullrequest.branch=${{ env.PR_BRANCH }} \
106+
# --define sonar.pullrequest.base=${{ env.BASE_REF }}

0 commit comments

Comments
 (0)