Skip to content

Commit 66560f3

Browse files
authored
Upload coverage data to teamscale (#3519)
After a Pull Request workflow, this will be queued to download the coverage data, and upload it to teamscale. This has to be done as a separate flow from the actual `Pull Request` workflow, because `pull_request` triggers do not have access to secrets, since they run code from the open pull request. This does take advantage of this action: https://github.com/cqse/teamscale-upload-action If the `Pull Request` workflow fails, this will be skipped.
1 parent 74d5ccf commit 66560f3

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Upload Coverage to Teamscale
2+
3+
permissions:
4+
actions: read
5+
6+
on:
7+
workflow_run:
8+
workflows: [Pull Request]
9+
types:
10+
- completed
11+
12+
jobs:
13+
upload_coverage:
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16+
steps:
17+
- name: 'Download artifact'
18+
uses: actions/github-script@v7
19+
with:
20+
script: |
21+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
run_id: context.payload.workflow_run.id,
25+
});
26+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
27+
return artifact.name == "coverage-report"
28+
})[0];
29+
let download = await github.rest.actions.downloadArtifact({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
artifact_id: matchArtifact.id,
33+
archive_format: 'zip',
34+
});
35+
const fs = require('fs');
36+
const path = require('path');
37+
const temp = '${{ runner.temp }}/artifacts';
38+
if (!fs.existsSync(temp)){
39+
fs.mkdirSync(temp);
40+
}
41+
fs.writeFileSync(path.join(temp, 'coverage-report.zip'), Buffer.from(download.data));
42+
43+
- name: 'Unzip artifact'
44+
run: unzip "${{ runner.temp }}/artifacts/coverage-report.zip" -d "${{ runner.temp }}/artifacts"
45+
- name: 'Upload coverage'
46+
uses: 'cqse/[email protected]'
47+
with:
48+
server: 'https://fdb.teamscale.io'
49+
project: 'foundationdb-fdb-record-layer'
50+
user: 'fdb-record-layer-build'
51+
partition: 'CI Tests'
52+
accesskey: ${{ secrets.TEAMSCALE_ACCESS_KEY }}
53+
format: 'JACOCO'
54+
revision: ${{ github.event.workflow_run.head_sha }}
55+
files: "${{ runner.temp}}/artifacts/codeCoverageReport.xml"

0 commit comments

Comments
 (0)