Skip to content

PR code coverage (publish) #30330

PR code coverage (publish)

PR code coverage (publish) #30330

name: PR code coverage (publish)
on:
workflow_run:
workflows: [ "PR code coverage (generate)" ]
types: [ "completed" ]
jobs:
# This job downloads the artifacts generated by the code-cover-gen job and
# uploads them to a GCS bucket, from where Reviewable can access them.
#
# Note that this workflow is not required for a PR to merge; a failure simply
# means that there won't be coverage data visible in Reviewable.
code-cover-publish:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: 'Download artifact'
uses: actions/[email protected]
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 == "cover"
})[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}}/cover.zip', Buffer.from(download.data));
- run: |
mkdir -p cover
unzip cover.zip -d cover
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.CODECOVER_SERVICE_ACCOUNT_KEY }}'
- name: 'Upload to GCS'
uses: 'google-github-actions/upload-cloud-storage@v1'
with:
path: 'cover'
glob: '**/cover-*.json'
parent: false
destination: 'crl-codecover-public/pr-cockroach/'
process_gcloudignore: false