From b9005ce7a9f30db6b21ec1b51ee163e3d3cf555d Mon Sep 17 00:00:00 2001 From: Leonardo Merza Date: Tue, 16 Jan 2024 13:20:32 -0500 Subject: [PATCH] add code coverage --- .github/workflows/sonar.yaml | 25 ++- coverage.xml | 292 +++++++++++++++++++++++++++++++++++ requirements.txt | 2 +- sonar-project.properties | 1 + 4 files changed, 314 insertions(+), 6 deletions(-) create mode 100644 coverage.xml diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index f7c88b0..272a588 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -7,21 +7,36 @@ on: branches: - master - jobs: build: - name: Build + name: Test SonarQube runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install coverage + + - name: Run tests with coverage + run: | + coverage run --source=index -m unittest discover + coverage xml + - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - # If you wish to fail your job when the Quality Gate is red, uncomment the - # following lines. This would typically be used to fail a deployment. + + # Uncomment to fail the job when the Quality Gate is red # - uses: sonarsource/sonarqube-quality-gate-action@master # timeout-minutes: 5 # env: diff --git a/coverage.xml b/coverage.xml new file mode 100644 index 0000000..818680f --- /dev/null +++ b/coverage.xml @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/requirements.txt b/requirements.txt index 29f9710..a7fe3e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ paho_mqtt==1.6.1 requests==2.31.0 PyYAML==6.0.1 -Pillow==9.1.1 +Pillow==9.1.1 \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 3839b2b..209ce7d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1 +1,2 @@ sonar.projectKey=ljmerza_frigate_plate_recognizer_AY0TaejvJwHTSS6ZO76Q +sonar.python.coverage.reportPaths=coverage.xml