Skip to content
21 changes: 19 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
workflow_run:
workflows: ["Integration Tests", "Unit Tests"]
types: [completed]
# Also allow manual triggering for debugging
workflow_dispatch:

jobs:
finalize:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_sha == github.sha }}
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
# Needed for listWorkflowRunsForRepo and safe defaults for token scope
permissions:
actions: read
Expand All @@ -23,10 +25,13 @@ jobs:
uses: actions/github-script@v7
with:
script: |
// For manual dispatch, use the current SHA, otherwise use the triggering workflow's SHA
const targetSha = context.payload.workflow_run?.head_sha || context.sha;

const workflows = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: context.payload.workflow_run.head_sha,
head_sha: targetSha,
status: 'completed',
per_page: 100
});
Expand All @@ -37,6 +42,12 @@ jobs:
)
);

// Debug information
core.info(`Found ${workflows.data.workflow_runs.length} workflow runs for SHA ${targetSha}`);
workflows.data.workflow_runs.forEach(run => {
core.info(`- ${run.name}: ${run.conclusion} (${run.status})`);
});

core.info(bothComplete ? 'Both workflows completed successfully.' : 'Waiting for other workflow to complete.');
core.setOutput('ready', String(bothComplete));

Expand All @@ -45,3 +56,9 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: "Integration,Unit"
# Pass the original commit SHA and PR context to maintain consistency
git-commit: ${{ github.event.workflow_run.head_sha || github.sha }}
git-branch: ${{ github.event.workflow_run.head_branch || github.ref_name }}
service-number: ${{ github.event.workflow_run.id || github.run_id }}
pull-request: ${{ github.event.workflow_run.pull_requests[0].number || github.event.pull_request.number || '' }}
Loading