|
| 1 | +name: Coveralls |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Integration Tests", "Unit Tests"] |
| 6 | + types: [completed] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + finalize: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} |
| 16 | + steps: |
| 17 | + - id: check |
| 18 | + name: Verify all prerequisite workflows succeeded |
| 19 | + uses: actions/github-script@v7 |
| 20 | + with: |
| 21 | + script: | |
| 22 | + const {owner, repo} = context.repo; |
| 23 | + const headSha = context.payload.workflow_run?.head_sha || context.sha; |
| 24 | +
|
| 25 | + const runs = await github.rest.actions.listWorkflowRunsForRepo({ |
| 26 | + owner, |
| 27 | + repo, |
| 28 | + head_sha: headSha, |
| 29 | + status: 'completed', |
| 30 | + per_page: 100 |
| 31 | + }); |
| 32 | +
|
| 33 | + const findRun = (name) => runs.data.workflow_runs.find(r => r.name === name && r.conclusion === 'success'); |
| 34 | + |
| 35 | + const integration = findRun('Integration Tests'); |
| 36 | + const unit = findRun('Unit Tests'); |
| 37 | +
|
| 38 | + const ok = Boolean(unit && integration); |
| 39 | + core.info(ok ? 'All workflows completed successfully.' : 'Waiting for a remaining workflow to complete.'); |
| 40 | +
|
| 41 | + core.setOutput('ready', String(ok)); |
| 42 | + if (ok) { |
| 43 | + core.setOutput('unit_run_id', String(unit.id)); |
| 44 | + core.setOutput('integration_run_id', String(integration.id)); |
| 45 | + } |
| 46 | +
|
| 47 | + - if: ${{ steps.check.outputs.ready == 'true' }} |
| 48 | + name: Download artifacts from Integration Tests run |
| 49 | + uses: actions/download-artifact@v4 |
| 50 | + with: |
| 51 | + name: coverage-integration-clover |
| 52 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + run-id: ${{ steps.check.outputs.integration_run_id }} |
| 54 | + path: integration-coverage |
| 55 | + |
| 56 | + - if: ${{ steps.check.outputs.ready == 'true' }} |
| 57 | + name: Download artifacts from Unit Tests run |
| 58 | + uses: actions/download-artifact@v4 |
| 59 | + with: |
| 60 | + name: coverage-unit-clover |
| 61 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + run-id: ${{ steps.check.outputs.unit_run_id }} |
| 63 | + path: unit-coverage |
| 64 | + |
| 65 | + - if: ${{ steps.check.outputs.ready == 'true' }} |
| 66 | + name: Merge Clover reports |
| 67 | + uses: danielpalme/ReportGenerator-GitHub-Action@v5 |
| 68 | + with: |
| 69 | + reports: | |
| 70 | + unit-coverage/clover.xml; |
| 71 | + integration-coverage/clover.xml |
| 72 | + targetdir: merged-coverage |
| 73 | + reporttypes: Clover |
| 74 | + |
| 75 | + - if: ${{ steps.check.outputs.ready == 'true' }} |
| 76 | + name: Upload merged coverage to Coveralls |
| 77 | + uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2 |
| 78 | + with: |
| 79 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + file: ./merged-coverage/Clover.xml |
| 81 | + fail-on-error: false |
0 commit comments