diff --git a/.github/workflows/merge-develop.yml b/.github/workflows/merge-develop.yml index 2c27b01..dd7c734 100644 --- a/.github/workflows/merge-develop.yml +++ b/.github/workflows/merge-develop.yml @@ -71,30 +71,18 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} thresholdAll: 0.85 - - name: setup java - if: github.actor != 'dependabot[bot]' && (success() || failure()) - uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0 - with: - distribution: "corretto" - java-version: "17" - - - name: provision sonar-scanner - if: github.actor != 'dependabot[bot]' && (success() || failure()) + - name: prepare sonar reports + if: success() || failure() run: | - export SONAR_VERSION="4.7.0.2747" - 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 - if: github.actor != 'dependabot[bot]' && (success() || failure()) - run: | - PATH="$PWD/sonar-scanner/bin:$PATH" - sonar-scanner + - name: sonar scan + if: success() || failure() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1 - name: publish junit reports if: success() || failure() diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b538a52..6eae776 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -101,35 +101,18 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} thresholdAll: 0.85 - - name: setup java - if: success() || failure() - uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0 - with: - distribution: "corretto" - java-version: "17" - - - name: provision sonar-scanner + - name: prepare sonar reports if: success() || failure() run: | - export SONAR_VERSION="4.7.0.2747" - 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 + - name: sonar scan if: success() || failure() - 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 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1 - name: archive reports if: success() || failure() diff --git a/scripts/sonar_tests.py b/scripts/sonar_tests.py index 49abe74..c174d5d 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)