Code Coverage #392
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: Code Coverage | |
on: | |
workflow_run: | |
workflows: ["Tests"] | |
types: | |
- completed | |
jobs: | |
code-climate: | |
name: 'Send coverage report to Code Climate' | |
runs-on: ubuntu-latest | |
if: > | |
${{ github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' && | |
github.actor != 'dependabot[bot]' | |
}} | |
steps: | |
- name: Cloning repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.workflow_run.head_sha }} | |
- name: 'Download artifact' | |
uses: actions/github-script@v3.1.0 | |
with: | |
script: | | |
var artifacts = await github.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "coverage" | |
})[0]; | |
var download = await github.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/coverage.zip', Buffer.from(download.data)); | |
- name: Unzipping artifact | |
run: unzip coverage.zip | |
- name: Send coverage report | |
if: > | |
( | |
success() && | |
github.actor != 'dependabot[bot]' | |
) | |
uses: paambaati/codeclimate-action@v3.0.0 | |
env: | |
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
with: | |
coverageLocations: | | |
${{github.workspace}}/lcov.info:lcov |