Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonarqube added to Test workflow #927

Merged
merged 15 commits into from
Sep 16, 2024
19 changes: 11 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: 'Run unit tests'
id: runtests
run: |
coverage run -m pytest --doctest-modules --doctest-continue-on-failure test/
coverage run -m pytest --doctest-modules --doctest-continue-on-failure test/ --junitxml=test-execution.xml
rc=$?
coverage xml

Expand All @@ -77,11 +77,17 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}

- name: 'Save coverage report as an Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ./coverage.xml

- name: 'Save execution report as an Artifact'
uses: actions/upload-artifact@v4
with:
name: execution-report
path: ./test-execution.xml

- name: 'build web front-end'
run: |
set -eo pipefail
Expand Down Expand Up @@ -121,19 +127,16 @@ jobs:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

# Download the coverage report artifact
- name: 'Download coverage report'
uses: actions/download-artifact@v3
- name: 'Download coverage and execution report'
uses: actions/download-artifact@v4
with:
name: coverage-report
pattern: '*-report'

# Perform the SonarQube scan
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
args: |
-Dsonar.python.coverage.reportPaths=coverage.xml

# Optional: Fail the job if Quality Gate is red
# If you wish to fail your job when the Quality Gate is red, uncomment the
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ build/
test/*.sh
.coverage
coverage.xml
test-execution.xml
temp.json
data-dump.sql
local.py
Expand Down Expand Up @@ -64,3 +65,6 @@ Pulumi*.yaml

# performance profile files
profiles

# sonarqube
.scannerwork/
4 changes: 3 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
sonar.projectKey=populationgenomics_metamist_AZHVO0XpdaNSak8FrtKn
sonar.python.version=3
sonar.python.version=3.11
sonar.python.coverage.reportPaths=coverage.xml
sonar.python.xunit.reportPath=test-execution.xml