Skip to content

Commit

Permalink
chore: adidng sonarcloud
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <[email protected]>
  • Loading branch information
Freyskeyd committed Apr 30, 2024
1 parent 934a739 commit 90383e0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,54 @@ jobs:
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ${{ steps.coverage.outputs.report }}

sonarcloud:
name: SonarCloud and Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.77.1
components: clippy rustfmt llvm-tools-preview

- uses: taiki-e/install-action@grcov
- uses: taiki-e/install-action@protoc

- name: Install cargo-sonar and run Clippy
run: |
cargo install cargo-sonar
cargo clippy --message-format json > my-clippy-report.json
cargo sonar --clippy --clippy-path my-clippy-report.json
- name: Build with coverage
env:
RUST_LOG: info
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "codecov-instrumentation-%p-%m.profraw"
run: cargo build

- name: Run grcov
run: |
grcov . --binary-path target/debug/ -s . \
-t lcov \
--branch \
--ignore-not-existing \
--ignore '../**' \
--ignore '/*' \
-o coverage.lcov
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.externalIssuesReportPaths=sonar-issues.json
-Dcommunity.rust.lcov.reportPaths=lcov.info
13 changes: 13 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sonar.projectKey=Freyskeyd_chekov
sonar.organization=freyskeyd

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=chekov
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

0 comments on commit 90383e0

Please sign in to comment.