diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..9ae7570 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,49 @@ +name: SonarQube analysis + +on: + push: + branches: [ "main", "test" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + pull-requests: read + contents: read + +jobs: + Analysis: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Disable shallow clones for better analysis + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install coverage pytest vcrpy + + - name: Run tests with coverage + run: | + coverage run test_main.py + coverage xml + + - name: Analyze with SonarQube + uses: SonarSource/sonarqube-scan-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.projectKey=GabrielPalmar_HiveBox-Project + -Dsonar.organization=gabrielpalmar + -Dsonar.sources=. + -Dsonar.exclusions=**/*test*/**,**/fixtures/**,**/__pycache__/**,**/venv/**,**/.git/** \ No newline at end of file