Skip to content
60 changes: 26 additions & 34 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,39 @@
name: Coverage

on:
workflow_run:
workflows: ["Integration Tests", "Unit Tests"]
types: [completed]
push:
branches:
- main
paths-ignore:
- '.github/actions/release-please/**'
pull_request:
branches:
- main

permissions:
contents: read
checks: read
actions: read

jobs:
finalize:
coverage:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_sha == github.sha }}
# Needed for listWorkflowRunsForRepo and safe defaults for token scope
permissions:
actions: read
contents: read
statuses: write
# Prevent multiple concurrent finalizers for the same commit
concurrency:
group: coverage-${{ github.event.workflow_run.head_sha }}
cancel-in-progress: true
steps:
- id: check
uses: actions/github-script@v7
- name: Wait for Unit and Integration jobs
uses: kachick/wait-other-jobs@755be1ff093bd2a6a82a24bfc50ef4d9fe491a59 # v3.8.1
with:
script: |
const workflows = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: context.payload.workflow_run.head_sha,
status: 'completed',
per_page: 100
});
const bothComplete = ['Integration Tests', 'Unit Tests'].every(name =>
workflows.data.workflow_runs.some(
run => run.name === name && run.conclusion === 'success'
)
);
core.info(bothComplete ? 'Both workflows completed successfully.' : 'Waiting for other workflow to complete.');
core.setOutput('ready', String(bothComplete));
skip-same-workflow: 'true'
wait-list: |
[
{"workflowFile": "integration-tests.yml"},
{"workflowFile": "unit-tests.yml"}
]
timeout-minutes: 15

- if: ${{ steps.check.outputs.ready == 'true' }}
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
name: Finalize Coveralls parallel build
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: "Integration,Unit"
Loading