From 2c04b4f9f4f4862629156f08f526bae554b93153 Mon Sep 17 00:00:00 2001 From: ff137 Date: Wed, 11 Dec 2024 13:23:18 +0200 Subject: [PATCH] :construction_worker: Configure test coverage for SonarCloud --- .github/workflows/sonarcloud.yml | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 008895b72..d53a3d20f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -43,25 +43,37 @@ jobs: runs-on: ubuntu-latest steps: - - name: Analyze with SonarCloud + # Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 # Required for proper blame data in SonarCloud + + # Setup Python + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.12" + # Install dependencies + - name: Install dependencies with Poetry + run: mise run poetry:install + + # Run tests and generate coverage report + - name: Run Tests with Coverage + run: | + pytest --cov --cov-report=xml --ignore=app/tests/e2e/ --ignore=trustregistry/tests/e2e/ + + # Analyze with SonarCloud + - name: Analyze with SonarCloud uses: SonarSource/sonarqube-scan-action@v4.1.0 env: GITHUB_TOKEN: ${{ github.token }} # Needed to get PR information SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) with: - # Additional arguments for the sonarcloud scanner - args: - # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) - # mandatory + # Additional arguments for the SonarCloud scanner + args: > -Dsonar.projectKey=didx-xyz_aries-cloudapi-python -Dsonar.organization=didx-xyz -Dsonar.coverage.exclusions=**/tests/** - # Comma-separated paths to directories containing main source files. - #-Dsonar.sources= # optional, default is project base directory - # When you need the analysis to take place in a directory other than the one from which it was launched - #-Dsonar.projectBaseDir= # optional, default is . - # Comma-separated paths to directories containing test source files. - #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ - # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. - #-Dsonar.verbose= # optional, default is false + -Dsonar.python.coverage.reportPaths=coverage.xml