github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/.github/workflows/code-cover-publish.yaml (about)

     1  name: PR code coverage (publish)
     2  
     3  on:
     4    workflow_run:
     5      workflows: [ "PR code coverage (generate)" ]
     6      types: [ "completed" ]
     7  
     8  
     9  jobs:
    10    # This job downloads the artifacts genearted by the code-cover-gen job and
    11    # uploads them to a GCS bucket, from where Reviewable can access them.
    12    code-cover-publish:
    13      runs-on: ubuntu-latest
    14      if: >
    15        github.event.workflow_run.event == 'pull_request' &&
    16        github.event.workflow_run.conclusion == 'success'
    17      steps:
    18        - name: 'Download artifact'
    19          uses: actions/github-script@v3.1.0
    20          with:
    21            script: |
    22              var artifacts = await github.actions.listWorkflowRunArtifacts({
    23                 owner: context.repo.owner,
    24                 repo: context.repo.repo,
    25                 run_id: ${{github.event.workflow_run.id }},
    26              });
    27              var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
    28                return artifact.name == "cover"
    29              })[0];
    30              var download = await github.actions.downloadArtifact({
    31                 owner: context.repo.owner,
    32                 repo: context.repo.repo,
    33                 artifact_id: matchArtifact.id,
    34                 archive_format: 'zip',
    35              });
    36              var fs = require('fs');
    37              fs.writeFileSync('${{github.workspace}}/cover.zip', Buffer.from(download.data));
    38  
    39        - run: |
    40            mkdir -p cover
    41            unzip cover.zip -d cover
    42  
    43        - name: 'Authenticate to Google Cloud'
    44          uses: 'google-github-actions/auth@v1'
    45          with:
    46            credentials_json: '${{ secrets.CODECOVER_SERVICE_ACCOUNT_KEY }}'
    47  
    48        - name: 'Upload to GCS'
    49          uses: 'google-github-actions/upload-cloud-storage@v1'
    50          with:
    51            path: 'cover'
    52            glob: '**/cover-*.json'
    53            parent: false
    54            destination: 'crl-codecover-public/pr-pebble/'
    55            process_gcloudignore: false