diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..2a5b957 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,55 @@ +name: SonarCloud + +on: + pull_request: + branches: + - develop + push: + branches: + - develop + +jobs: + sonarcloud: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Rust with Clippy + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + - name: Install grcov + run: cargo install grcov + + - name: Run tests with coverage instrumentation + working-directory: backend + run: | + CARGO_INCREMENTAL=0 \ + RUSTFLAGS="-Cinstrument-coverage" \ + LLVM_PROFILE_FILE="coverage-%p-%m.profraw" \ + cargo test --all --verbose + + - name: Generate coverage report (lcov) + working-directory: backend + run: | + grcov . \ + --binary-path ./target/debug/ \ + -s . -t lcov \ + --branch --ignore-not-existing \ + -o coverage.lcov + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@v2 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: > + -Dsonar.projectBaseDir=backend + -Dsonar.projectKey=zzaekkii_challenge-to-do + -Dsonar.organization=zzaekkii + -Dsonar.javascript.lcov.reportPaths=coverage.lcov