Repository navigation
SonarCloud #2552
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SonarCloud | |
| # Controls when the action will run. | |
| # Triggered when the 'build sakura' workflow completes. | |
| on: | |
| workflow_run: | |
| workflows: ['build sakura'] | |
| types: [completed] | |
| permissions: | |
| actions: read | |
| checks: write | |
| contents: read | |
| pull-requests: write | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| sonar: | |
| name: Scan | |
| runs-on: windows-latest | |
| if: github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| fetch-depth: 0 | |
| submodules: true | |
| allow-unsafe-pr-checkout: true | |
| - name: Download sonar-input artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: sonar-input | |
| path: ${{ github.workspace }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| - name: Setup sonar variables | |
| id: sonar-vars | |
| run: | | |
| $meta = Get-Content sonar-metadata.json | ConvertFrom-Json | |
| $projectKey = ('${{ github.repository }}' -replace '/', '_') | |
| echo "project-key=$projectKey" >> $env:GITHUB_OUTPUT | |
| if ($meta.event_name -eq 'pull_request') { | |
| echo "pull-request-key=-Dsonar.pullrequest.key=$($meta.pr_number)" >> $env:GITHUB_OUTPUT | |
| echo "branch-name=-Dsonar.pullrequest.branch=$($meta.pr_head_ref)" >> $env:GITHUB_OUTPUT | |
| echo "branch-base=-Dsonar.pullrequest.base=$($meta.pr_base_ref)" >> $env:GITHUB_OUTPUT | |
| } else { | |
| echo "branch-name=-Dsonar.branch.name=$($meta.ref_name)" >> $env:GITHUB_OUTPUT | |
| } | |
| shell: pwsh | |
| - name: Publish test result | |
| uses: EnricoMi/publish-unit-test-result-action/windows@v2 | |
| with: | |
| commit: ${{ github.event.workflow_run.head_sha }} | |
| event_file: github-event.json | |
| event_name: ${{ github.event.workflow_run.event }} | |
| files: | | |
| *-googletest.xml | |
| - name: Analyze with SonarQube Scan action | |
| uses: SonarSource/sonarqube-scan-action@22918119ff8e1ca75a623e15c8296b6ea4fbe28f # v8.2.1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| LC_ALL: ja_JP.UTF-8 | |
| if: env.SONAR_TOKEN | |
| with: | |
| args: > | |
| -Dsonar.organization=${{ github.repository_owner }} | |
| -Dsonar.projectKey=${{ steps.sonar-vars.outputs.project-key }} | |
| -Dsonar.host.url=https://sonarcloud.io | |
| ${{ steps.sonar-vars.outputs.pull-request-key }} | |
| ${{ steps.sonar-vars.outputs.branch-name }} | |
| ${{ steps.sonar-vars.outputs.branch-base }} | |
| -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json | |
| -Dsonar.cfamily.cppunit.reportPath=*-googletest.xml | |
| -Dsonar.cfamily.cobertura.reportPaths=tests1-coverage.xml | |
| -Dsonar.python.coverage.reportPaths=pytest-coverage.xml | |
| -Dsonar.verbose=true | |
| - name: Upload Sonar CFamily failure reproducer (if present) | |
| if: ${{ always() && hashFiles('sonar-cfamily-reproducer.tar.xz') != '' }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: sonar-cfamily-reproducer-${{ runner.os }}-${{ github.run_id }} | |
| path: sonar-cfamily-reproducer.tar.xz | |
| if-no-files-found: ignore | |
| retention-days: 14 |