|
| 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 | + |
| 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