Skip to content

Upload Coverage to Teamscale #669

Upload Coverage to Teamscale

Upload Coverage to Teamscale #669

name: Upload Coverage to Teamscale
permissions:
actions: read
# This is a separate workflow from pull_request.yml because it needs to run with access
# to the secrets
on:
workflow_run:
workflows: [Pull Request]
types:
- completed
jobs:
upload_coverage:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
# This checks out the latest commit on main, not teh PRs head
# This is needed to get the teamscale-upload action
- name: Checkout sources
uses: actions/[email protected]
- name: 'Download artifact'
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "coverage-report"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
const path = require('path');
const temp = '${{ runner.temp }}/artifacts';
if (!fs.existsSync(temp)){
fs.mkdirSync(temp);
}
fs.writeFileSync(path.join(temp, 'coverage-report.zip'), Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip "${{ runner.temp }}/artifacts/coverage-report.zip" -d "${{ runner.temp }}/artifacts"
- name: 'Upload coverage'
uses: ./actions/teamscale-upload
with:
partition: 'CI Tests'
revision: ${{ github.event.workflow_run.head_sha }}
files: "${{ runner.temp}}/artifacts/codeCoverageReport.xml"
teamscaleKey: ${{ secrets.TEAMSCALE_ACCESS_KEY }}