diff --git a/.github/workflows/sast-sonarcloud.yml b/.github/workflows/sast-sonarcloud.yml new file mode 100644 index 0000000..b3f2c94 --- /dev/null +++ b/.github/workflows/sast-sonarcloud.yml @@ -0,0 +1,45 @@ +name: SAST com SonarCloud + +on: + push: + branches: [main] + pull_request: + +jobs: + sonarcloud: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests with coverage + run: | + poetry run pytest --cov=src --cov-report=xml --cov-report=term + continue-on-error: true + + - name: SonarCloud Scan + uses: SonarSource/sonarqube-scan-action@v6.0.0 + with: + args: > + -Dsonar.projectKey=${{ secrets.SONAR_PROJECT }} + -Dsonar.organization=${{ secrets.SONAR_ORG }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..0c23aef --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,3 @@ +sonar.sources=src +sonar.exclusions=**/*test*.py,**/conftest.py +sonar.python.version=3.12