Skip to content

Commit 92b4330

Browse files
workflows: sonarcloud: enable sonarcloud
Enable sonarcloud. Signed-off-by: Giacomo Dematteis <giacomo.dematteis@nordicsemi.no>
1 parent 0995925 commit 92b4330

File tree

2 files changed

+45
-59
lines changed

2 files changed

+45
-59
lines changed

.github/workflows/sonarcloud.yml

+43-57
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Twister native sim (No Sonarcloud yet)
1+
name: Sonarcloud and Twister Native Sim
22
on:
33
push:
44
branches:
@@ -55,65 +55,51 @@ jobs:
5555
apt-get update
5656
apt install -y curl ruby-full
5757
58-
# - name: Install sonar-scanner and build-wrapper
59-
# uses: SonarSource/sonarcloud-github-c-cpp@v3
58+
- name: Install sonar-scanner and build-wrapper
59+
uses: SonarSource/sonarcloud-github-c-cpp@v3
6060

61-
- name: Build and test native sim
61+
- name: Build and test
6262
working-directory: asset-tracker-template
6363
run: |
64-
west twister -T . -C --coverage-platform=native_sim -v --inline-logs --integration
64+
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} west twister -T . -C --coverage-platform=native_sim -v --inline-logs --integration
6565
66-
- name: Results
67-
if: always()
68-
uses: pmeier/pytest-results-action@v0.7.1
69-
with:
70-
path: asset-tracker-template//twister-out/*.xml
71-
summary: true
72-
fail-on-empty: true
73-
title: ATT FW Unittest natvie sim Results
74-
75-
# - name: Build and test
76-
# working-directory: asset-tracker-template
77-
# run: |
78-
# build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} west twister -T . -C --coverage-platform=native_sim -v --inline-logs --integration
79-
80-
# - name: Extract coverage into sonarqube xml format
81-
# working-directory: asset-tracker-template
82-
# run: |
83-
# gcovr twister-out -v --merge-mode-functions=separate --exclude='twister-out|drivers' --sonarqube coverage.xml
66+
- name: Extract coverage into sonarqube xml format
67+
working-directory: asset-tracker-template
68+
run: |
69+
gcovr twister-out -v --merge-mode-functions=separate --exclude='twister-out|drivers' --sonarqube coverage.xml
8470
85-
# - name: Run sonar-scanner on main
86-
# working-directory: asset-tracker-template
87-
# if: github.event_name != 'pull_request'
88-
# env:
89-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
91-
# run: |
92-
# sonar-scanner \
93-
# --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
94-
# --define project.settings=sonar-project.properties \
95-
# --define sonar.coverageReportPaths=coverage.xml \
96-
# --define sonar.inclusions=**/*.c,**/*.h \
97-
# --define sonar.exclusions=tests/,drivers/sensor/*_dummy/
71+
- name: Run sonar-scanner on main
72+
working-directory: asset-tracker-template
73+
if: github.event_name != 'pull_request'
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
77+
run: |
78+
sonar-scanner \
79+
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
80+
--define project.settings=sonar-project.properties \
81+
--define sonar.coverageReportPaths=coverage.xml \
82+
--define sonar.inclusions=**/*.c,**/*.h \
83+
--define sonar.exclusions=tests/,drivers/sensor/*_dummy/
9884
99-
# - name: Run sonar-scanner on PR
100-
# working-directory: asset-tracker-template
101-
# if: github.event_name == 'pull_request'
102-
# env:
103-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
105-
# PR_NUMBER: ${{ github.event.pull_request.number }}
106-
# PR_BRANCH: ${{ github.event.pull_request.head.ref }}
107-
# BASE_REF: ${{ github.event.pull_request.base.ref }}
108-
# HEAD_SHA: ${{ github.event.pull_request.head.sha }}
109-
# run: |
110-
# sonar-scanner \
111-
# --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
112-
# --define project.settings=sonar-project.properties \
113-
# --define sonar.coverageReportPaths=coverage.xml \
114-
# --define sonar.inclusions=**/*.c,**/*.h \
115-
# --define sonar.exclusions=tests/,drivers/sensor/*_dummy/ \
116-
# --define sonar.scm.revision=${{ env.HEAD_SHA }} \
117-
# --define sonar.pullrequest.key=${{ env.PR_NUMBER }} \
118-
# --define sonar.pullrequest.branch=${{ env.PR_BRANCH }} \
119-
# --define sonar.pullrequest.base=${{ env.BASE_REF }}
85+
- name: Run sonar-scanner on PR
86+
working-directory: asset-tracker-template
87+
if: github.event_name == 'pull_request'
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
91+
PR_NUMBER: ${{ github.event.pull_request.number }}
92+
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
93+
BASE_REF: ${{ github.event.pull_request.base.ref }}
94+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
95+
run: |
96+
sonar-scanner \
97+
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
98+
--define project.settings=sonar-project.properties \
99+
--define sonar.coverageReportPaths=coverage.xml \
100+
--define sonar.inclusions=**/*.c,**/*.h \
101+
--define sonar.exclusions=tests/,drivers/sensor/*_dummy/ \
102+
--define sonar.scm.revision=${{ env.HEAD_SHA }} \
103+
--define sonar.pullrequest.key=${{ env.PR_NUMBER }} \
104+
--define sonar.pullrequest.branch=${{ env.PR_BRANCH }} \
105+
--define sonar.pullrequest.base=${{ env.BASE_REF }}

sonar-project.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sonar.projectKey=asset-tracker-template_firmware
2-
sonar.organization=asset-tracker-template-firmware
1+
sonar.projectKey=NordicSemiconductor_Asset-Tracker-Template
2+
sonar.organization=nordicsemiconductor-1
33
sonar.host.url=https://sonarcloud.io

0 commit comments

Comments
 (0)