From 5c2b36bcaf3469b701b529b72f4c2987f985c410 Mon Sep 17 00:00:00 2001 From: Russell Bunch Date: Wed, 19 Apr 2023 09:22:25 -0500 Subject: [PATCH] Fixes #165 - sonarcloud coverage Generate `coverage.xml` and upload it to SonarCloud to fix the missing coverage notice in SonarCloud's comments. --- .github/workflows/tests.yml | 14 +++++++++++++- .gitignore | 2 +- noxfile.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 12c733c52..717e81c50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,4 +46,16 @@ jobs: run: | pip install .[ci] nox -e tests - nox -e cover + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.organization="${GITHUB_REPOSITORY%/*}" + -Dsonar.projectKey="${GITHUB_REPOSITORY#*/}" + -Dsonar.python.coverage.reportPaths=coverage.xml + -Dsonar.sources=canu/,network_modeling + -Dsonar.test.exclusions=tests/** + -Dsonar.tests=tests/ diff --git a/.gitignore b/.gitignore index 27b7b41bc..09d1aae3e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ build_version pip-log.txt # Unit test / coverage reports -.coverage +*coverage* .nox .tox .cache diff --git a/noxfile.py b/noxfile.py index ea5e1aeed..94280d07b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -56,7 +56,7 @@ def tests(session): session.run( "pytest", "--log-level=ERROR", - "--cov-report=", + "--cov-report=xml", f"--cov-fail-under={COVERAGE_FAIL}", "--cov=canu", "--cov=tests",