Skip to content

Commit

Permalink
👷 Configure test coverage for SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
ff137 committed Dec 11, 2024
1 parent c87fbad commit 2c04b4f
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2c04b4f

Please sign in to comment.