diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index b20417902..694697b94 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -54,6 +54,29 @@ jobs: # Disable shallow clones for better analysis fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + + - name: Install Python Test Dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r internal/tests/pytests/requirements.txt + + - name: Run Pytests + run: coverage run -m pytest internal/tests/pytests + env: + METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output + + - name: Output coverage report + run: coverage report -m + if: always() + + - name: Generate XML coverage report + run: coverage xml + if: always() + - name: Get branch name id: get_branch_name run: echo branch_name=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index 02f74d786..1504a3f16 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -4,7 +4,8 @@ sonar.projectName=METplus sonar.projectVersion=SONAR_PROJECT_VERSION sonar.branch.name=SONAR_BRANCH_NAME sonar.sources=docs,internal,manage_externals,metplus,parm,produtil,ush -sonar.coverage.exclusions=internal/tests/** +sonar.coverage.exclusions=internal/tests/**,parm/**,internal/scripts/**,manage_externals/**,docs/**,produtil/**,ush/**,metplus/wrappers/cyclone_plotter_wrapper.py +sonar.python.coverage.reportPaths=coverage.xml sonar.sourceEncoding=UTF-8 # SonarQube server