-
Notifications
You must be signed in to change notification settings - Fork 157
58 lines (53 loc) · 2.13 KB
/
publish-pr-coverage-results.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Publish Code Coverage Results
on:
workflow_run:
workflows: ["Receive Pull Request"]
types:
- completed
jobs:
publish-test-results:
name: Publish Code Coverage Results
runs-on: ubuntu-latest
# the build-and-test job might be skipped, we don't need to run this job then
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: 'Download artifact'
uses: actions/[email protected]
with:
script: |
var artifacts = await github.rest.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-reports"
})[0];
var download = await github.rest.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-reports.zip', Buffer.from(download.data));
- run: |
unzip coverage-reports.zip
rm coverage-reports.zip
- name: Set Coverage Report Paths
id: coverage-paths
run: |
readarray -d '' coveragePathArray < <(find . -name "coverage.cobertura.xml" -print0)
coveragePaths=$(printf ",%s" "${coveragePathArray[@]}")
echo "::set-output name=COVERAGE_REPORT_PATHS::$coveragePaths"
- name: Publish Code Coverage Results
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ steps.coverage-paths.outputs.COVERAGE_REPORT_PATHS }}