@@ -124,3 +124,54 @@ jobs:
124
124
with :
125
125
github-token : ${{ secrets.github_token }}
126
126
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
0 commit comments