SonarQube #6451
This file contains 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: SonarQube | |
on: | |
workflow_run: | |
workflows: ["Tests"] | |
types: | |
- completed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} | |
cancel-in-progress: true | |
jobs: | |
# This is a workaround for https://github.com/SonarSource/SonarJS/issues/578 | |
prepare: | |
name: Prepare | |
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'merge_group' | |
runs-on: ubuntu-latest | |
outputs: | |
reportPaths: ${{ steps.extra_args.outputs.reportPaths }} | |
testExecutionReportPaths: ${{ steps.extra_args.outputs.testExecutionReportPaths }} | |
steps: | |
# There's a 'download artifact' action, but it hasn't been updated for the workflow_run action | |
# (https://github.com/actions/download-artifact/issues/60) so instead we get this mess: | |
- name: 📥 Download artifact | |
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2 | |
with: | |
workflow: tests.yaml | |
run_id: ${{ github.event.workflow_run.id }} | |
name: coverage | |
path: coverage | |
- id: extra_args | |
run: | | |
coverage=$(find coverage -type f -name '*lcov.info' | tr '\n' ',' | sed 's/,$//g') | |
echo "reportPaths=$coverage" >> $GITHUB_OUTPUT | |
reports=$(find coverage -type f -name 'jest-sonar-report*.xml' | tr '\n' ',' | sed 's/,$//g') | |
echo "testExecutionReportPaths=$reports" >> $GITHUB_OUTPUT | |
sonarqube: | |
name: 🩻 SonarQube | |
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'merge_group' | |
needs: prepare | |
uses: matrix-org/matrix-js-sdk/.github/workflows/sonarcloud.yml@develop | |
secrets: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
with: | |
extra_args: -Dsonar.javascript.lcov.reportPaths=${{ needs.prepare.outputs.reportPaths }} -Dsonar.testExecutionReportPaths=${{ needs.prepare.outputs.testExecutionReportPaths }} |