Setup test reports uploading to SonarCloud

This commit is contained in:
Stefan Ceriu
2022-05-05 09:28:28 +03:00
parent a1a7cd7745
commit 75695504e6
6 changed files with 90 additions and 15 deletions
+48
View File
@@ -0,0 +1,48 @@
name: Sonar
on:
workflow_run:
workflows: [ "Tests" ]
types:
- completed
jobs:
sonar:
name: Sonar
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# Adapted from https://github.com/matrix-org/matrix-js-sdk/blob/develop/.github/workflows/sonarqube.yml
# 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 Test Results
uses: actions/github-script@v3.1.0
with:
script: |
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "test_output"
})[0];
const download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/test_output.zip', Buffer.from(download.data));
- name: Extract test tesults
run: unzip -d fastlane/test_output test_output.zip && rm test_output.zip
- name: SonarCloud scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+9 -3
View File
@@ -1,4 +1,4 @@
name: Unit and UI Tests
name: Tests
on:
push:
@@ -31,5 +31,11 @@ jobs:
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Tests
run: bundle exec fastlane tests
- name: Run tests
run: bundle exec fastlane tests
- name: Upload Test Results
uses: actions/upload-artifact@v2
with:
name: test_output
path: fastlane/test_output