Skip to content

NLightning Combined Coverage Report (PR) #150

NLightning Combined Coverage Report (PR)

NLightning Combined Coverage Report (PR) #150

name: NLightning Combined Coverage Report (PR)
on:
workflow_run:
workflows: [ "NLightning .NET Build & Tests (PR)" ]
types:
- completed
jobs:
combined-report:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
steps:
- uses: actions/checkout@v4
- name: Wait for all workflows to complete
run: |
REQUIRED_WORKFLOWS=(
"NLightning .NET Build & Tests (PR)"
"NLightning.Native .NET Build & Tests (PR)"
"NLightning.Wasm .NET Build & Tests (PR)"
)
echo "Waiting for all workflows to complete for commit ${{ github.event.workflow_run.head_sha }}"
# Set timeout to 5 minutes (300 seconds)
TIMEOUT=300
ELAPSED=0
SLEEP_INTERVAL=30
while [ $ELAPSED -lt $TIMEOUT ]; do
all_complete=true
for workflow in "${REQUIRED_WORKFLOWS[@]}"; do
# Get the latest run for this workflow and commit
run_data=$(gh api repos/${{ github.repository }}/actions/runs \
--jq ".workflow_runs[] | select(.head_sha==\"${{ github.event.workflow_run.head_sha }}\" and .name==\"$workflow\") | {status: .status, conclusion: .conclusion}" \
| head -1)
run_status=$(echo "$run_data" | jq -r '.status')
run_conclusion=$(echo "$run_data" | jq -r '.conclusion')
echo "Workflow '$workflow': status=$run_status, conclusion=$run_conclusion"
if [ "$run_status" != "completed" ]; then
all_complete=false
break
fi
done
if [ "$all_complete" = true ]; then
echo "✅ All workflows completed!"
exit 0
else
echo "⏳ Still waiting for workflows to complete... (${ELAPSED}s/${TIMEOUT}s)"
sleep $SLEEP_INTERVAL
ELAPSED=$((ELAPSED + SLEEP_INTERVAL))
fi
done
echo "❌ Timeout reached after ${TIMEOUT} seconds. Not all workflows completed in time."
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Download Standard Coverage
uses: dawidd6/action-download-artifact@v3
with:
workflow: pr.yml
name: coverage
path: coverage-reports/standard
- name: Download Native Coverage
uses: dawidd6/action-download-artifact@v3
with:
workflow: pr.native.yml
name: coverage.Native
path: coverage-reports/native
- name: Download WASM Coverage
uses: dawidd6/action-download-artifact@v3
with:
workflow: pr.wasm.yml
name: coverage.Wasm
path: coverage-reports/wasm
- name: List All Downloaded Files
run: find coverage-reports -type f | sort
- name: Combine All Coverage Reports
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4
with:
reports: "coverage-reports/**/Cobertura.xml"
targetdir: "${{ github.workspace }}/combined-report"
reporttypes: "Cobertura"
verbosity: "Info"
title: "Combined Code Coverage"
tag: "${{ github.run_number }}_${{ github.run_id }}"
toolpath: "reportgeneratortool"
assemblyfilters: "+*;-NLightning.Infrastructure.Blazor;-NLightning.BlazorTestApp"
- name: Generate Combined Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: combined-report/Cobertura.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: '50 75'
- name: Find PR Number
id: pr-number
uses: potiuk/get-workflow-origin@v1_5
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
- name: Add Combined Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: steps.pr-number.outputs.pullRequestNumber != ''
with:
recreate: true
path: code-coverage-results.md
number: ${{ steps.pr-number.outputs.pullRequestNumber }}
message: |
## Combined Coverage Report (All Configurations)
$(cat code-coverage-results.md)
_Report generated from Standard, Native, and WASM test runs_
- name: Download Standard Test Results
uses: dawidd6/action-download-artifact@v3
with:
workflow: pr.yml
name: test-results
path: test-results/standard
- name: Download Native Test Results
uses: dawidd6/action-download-artifact@v3
with:
workflow: pr.native.yml
name: test-results.Native
path: test-results/native
- name: Download WASM Test Results
uses: dawidd6/action-download-artifact@v3
with:
workflow: pr.wasm.yml
name: test-results.Wasm
path: test-results/wasm
- name: List All Downloaded Files
run: find test-results -type f | sort
- name: Publish Combined Test Results
uses: EnricoMi/publish-unit-test-result-action@v2.16.1
if: always()
with:
trx_files: "${{ github.workspace }}/test-results/**/*.trx"
deduplicate_classes_by_file_name: true
comment_title: "Combined Test Results"
check_name: "Combined Test Results"
commit: ${{ steps.pr-number.outputs.sourceHeadSha }}