|
4 | 4 | workflows: [ "Tests" ] |
5 | 5 | types: |
6 | 6 | - completed |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + cancel-in-progress: true |
7 | 10 | jobs: |
8 | | - sonarqube: |
9 | | - name: SonarQube |
10 | | - runs-on: ubuntu-latest |
11 | | - if: github.event.workflow_run.conclusion == 'success' |
12 | | - steps: |
13 | | - - uses: actions/checkout@v2 |
14 | | - with: |
15 | | - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
16 | | - |
17 | | - # There's a 'download artifact' action, but it hasn't been updated for the workflow_run action |
18 | | - # (https://github.com/actions/download-artifact/issues/60) so instead we get this mess: |
19 | | - - name: Download Coverage Report |
20 | | - |
21 | | - with: |
22 | | - script: | |
23 | | - const artifacts = await github.actions.listWorkflowRunArtifacts({ |
24 | | - owner: context.repo.owner, |
25 | | - repo: context.repo.repo, |
26 | | - run_id: ${{ github.event.workflow_run.id }}, |
27 | | - }); |
28 | | - const matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
29 | | - return artifact.name == "coverage" |
30 | | - })[0]; |
31 | | - const download = await github.actions.downloadArtifact({ |
32 | | - owner: context.repo.owner, |
33 | | - repo: context.repo.repo, |
34 | | - artifact_id: matchArtifact.id, |
35 | | - archive_format: 'zip', |
36 | | - }); |
37 | | - const fs = require('fs'); |
38 | | - fs.writeFileSync('${{github.workspace}}/coverage.zip', Buffer.from(download.data)); |
| 11 | + prdetails: |
| 12 | + name: ℹ️ PR Details |
| 13 | + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' |
| 14 | + uses: matrix-org/matrix-js-sdk/.github/workflows/pr_details.yml@develop |
| 15 | + with: |
| 16 | + owner: ${{ github.event.workflow_run.head_repository.owner.login }} |
| 17 | + branch: ${{ github.event.workflow_run.head_branch }} |
39 | 18 |
|
40 | | - - name: Extract Coverage Report |
41 | | - run: unzip -d coverage coverage.zip && rm coverage.zip |
42 | | - |
43 | | - - name: SonarCloud Scan |
44 | | - uses: SonarSource/sonarcloud-github-action@master |
45 | | - env: |
46 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
47 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 19 | + sonarqube: |
| 20 | + name: 🩻 SonarQube |
| 21 | + needs: prdetails |
| 22 | + # Only wait for prdetails if it isn't skipped |
| 23 | + if: | |
| 24 | + always() && |
| 25 | + (needs.prdetails.result == 'success' || needs.prdetails.result == 'skipped') && |
| 26 | + github.event.workflow_run.conclusion == 'success' |
| 27 | + uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop |
| 28 | + with: |
| 29 | + repo: ${{ github.event.workflow_run.head_repository.full_name }} |
| 30 | + pr_id: ${{ needs.prdetails.outputs.pr_id }} |
| 31 | + head_branch: ${{ needs.prdetails.outputs.head_branch || github.event.workflow_run.head_branch }} |
| 32 | + base_branch: ${{ needs.prdetails.outputs.base_branch }} |
| 33 | + revision: ${{ github.event.workflow_run.head_sha }} |
| 34 | + coverage_workflow_name: tests.yml |
| 35 | + coverage_run_id: ${{ github.event.workflow_run.id }} |
| 36 | + secrets: |
| 37 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
0 commit comments