From 90383e0b6b4fd7470237968ebb48be594038ff62 Mon Sep 17 00:00:00 2001 From: Simon Paitrault Date: Tue, 30 Apr 2024 15:16:06 +0200 Subject: [PATCH] chore: adidng sonarcloud Signed-off-by: Simon Paitrault --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++++ sonar-project.properties | 13 ++++++++++ 2 files changed, 64 insertions(+) create mode 100644 sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a2d7bf0..affe09c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..cc8e8eb4 --- /dev/null +++ b/sonar-project.properties @@ -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