From e93d3c69c318950762734d366bcc982950273773 Mon Sep 17 00:00:00 2001 From: james-bradley-nhs Date: Wed, 29 Jul 2026 09:01:02 +0100 Subject: [PATCH 1/2] mesh-2925: fix sonar --- .github/workflows/merge-develop.yml | 21 ++++++--------------- .github/workflows/pull-request.yml | 26 ++++++-------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/.github/workflows/merge-develop.yml b/.github/workflows/merge-develop.yml index f723f6a..bd50afe 100644 --- a/.github/workflows/merge-develop.yml +++ b/.github/workflows/merge-develop.yml @@ -56,24 +56,15 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} thresholdAll: 0.70 - - name: setup java - uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0 - with: - distribution: "corretto" - java-version: "17" - - - name: provision sonar-scanner + - name: prepare sonar reports + if: success() || failure() run: | - export SONAR_VERSION="5.0.1.3006" - wget -q --max-redirect=0 "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_VERSION}.zip" -O sonar-scanner.zip - unzip -q ./sonar-scanner.zip - mv ./sonar-scanner-${SONAR_VERSION} ./sonar-scanner + cat sonar-project.properties scripts/sonar_tests.py - - name: run sonar scan - run: | - PATH="$PWD/sonar-scanner/bin:$PATH" - sonar-scanner + - name: sonar scan + if: success() || failure() + uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b89c663..fb688e7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -139,29 +139,15 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} thresholdAll: 0.70 - - name: setup java - uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0 - with: - distribution: "corretto" - java-version: "17" - - - name: provision sonar-scanner + - name: prepare sonar reports + if: success() || failure() run: | - export SONAR_VERSION="5.0.1.3006" - wget -q --max-redirect=0 "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_VERSION}.zip" -O sonar-scanner.zip - unzip -q ./sonar-scanner.zip - mv ./sonar-scanner-${SONAR_VERSION} ./sonar-scanner + cat sonar-project.properties scripts/sonar_tests.py - - name: run sonar scan - run: | - PATH="$PWD/sonar-scanner/bin:$PATH" - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - git checkout "${GITHUB_HEAD_REF}" - sonar-scanner -Dsonar.pullrequest.branch="{{ github.event.pull_request.head.sha }}" -Dsonar.pullrequest.base="{{ github.event.pull_request.base.sha }}" -Dsonar.pullrequest.key="${{ github.event.number }}" - else - sonar-scanner - fi + - name: sonar scan + if: success() || failure() + uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 8a56254e5b3a774355ad75f8b9ca533bb8f034cb Mon Sep 17 00:00:00 2001 From: james-bradley-nhs Date: Wed, 29 Jul 2026 11:17:58 +0100 Subject: [PATCH 2/2] mesh-2925: add guard to sonar tests --- scripts/sonar_tests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/sonar_tests.py b/scripts/sonar_tests.py index c9e3c7c..c5c786f 100755 --- a/scripts/sonar_tests.py +++ b/scripts/sonar_tests.py @@ -99,6 +99,10 @@ def _transform_xunit_results(reports_dir: str, output_sonar: str): src_junit = os.path.join(reports_dir, "junit") out_tests = os.path.join(output_sonar, "tests.xml") + if not os.path.isdir(src_junit): + print("no junit found") + return + dom_out = dom.getDOMImplementation().createDocument(None, "testExecutions", None) dom_out.documentElement.setAttribute("version", "1") all_tests: dict[str, list[dom.Element]] = defaultdict(list)