Skip to content

Commit 90383e0

Browse files
committed
chore: adidng sonarcloud
Signed-off-by: Simon Paitrault <[email protected]>
1 parent 934a739 commit 90383e0

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.github/workflows/ci.yml

+51
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,54 @@ jobs:
124124
with:
125125
github-token: ${{ secrets.github_token }}
126126
path-to-lcov: ${{ steps.coverage.outputs.report }}
127+
128+
sonarcloud:
129+
name: SonarCloud and Linter
130+
runs-on: ubuntu-latest
131+
steps:
132+
- uses: actions/checkout@v4
133+
with:
134+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
135+
136+
- name: Install toolchain
137+
uses: dtolnay/rust-toolchain@stable
138+
with:
139+
toolchain: 1.77.1
140+
components: clippy rustfmt llvm-tools-preview
141+
142+
- uses: taiki-e/install-action@grcov
143+
- uses: taiki-e/install-action@protoc
144+
145+
- name: Install cargo-sonar and run Clippy
146+
run: |
147+
cargo install cargo-sonar
148+
cargo clippy --message-format json > my-clippy-report.json
149+
cargo sonar --clippy --clippy-path my-clippy-report.json
150+
151+
- name: Build with coverage
152+
env:
153+
RUST_LOG: info
154+
RUSTFLAGS: "-Cinstrument-coverage"
155+
RUSTDOCFLAGS: "-Cinstrument-coverage"
156+
LLVM_PROFILE_FILE: "codecov-instrumentation-%p-%m.profraw"
157+
run: cargo build
158+
159+
- name: Run grcov
160+
run: |
161+
grcov . --binary-path target/debug/ -s . \
162+
-t lcov \
163+
--branch \
164+
--ignore-not-existing \
165+
--ignore '../**' \
166+
--ignore '/*' \
167+
-o coverage.lcov
168+
169+
- name: SonarCloud Scan
170+
uses: SonarSource/sonarcloud-github-action@master
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
173+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
174+
with:
175+
args: >
176+
-Dsonar.externalIssuesReportPaths=sonar-issues.json
177+
-Dcommunity.rust.lcov.reportPaths=lcov.info

sonar-project.properties

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
sonar.projectKey=Freyskeyd_chekov
2+
sonar.organization=freyskeyd
3+
4+
# This is the name and version displayed in the SonarCloud UI.
5+
#sonar.projectName=chekov
6+
#sonar.projectVersion=1.0
7+
8+
9+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
10+
#sonar.sources=.
11+
12+
# Encoding of the source code. Default is default system encoding
13+
#sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)