Skip to content

Coverage Report

Coverage Report #148

name: Coverage Report
on:
workflow_run:
workflows: ["Test & Coverage"]
types: [completed]
permissions:
contents: read
pull-requests: write
actions: read
jobs:
coverage-comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-report
path: coverage/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Coverage report PR comment
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-path: coverage/coverage-summary.json
json-final-path: coverage/coverage-final.json
vite-config-path: vitest.config.ts
coverage-badge:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-report
path: coverage/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract coverage percentage
id: coverage
run: |
PCT=$(node -e "const s=JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json','utf8')); console.log(s.total.lines.pct)")
echo "pct=$PCT" >> $GITHUB_OUTPUT
- name: Update coverage badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: f245ebf1cf02d5f6e3df389f836a072a
filename: coverage-badge.json
label: coverage
message: ${{ steps.coverage.outputs.pct }}%
valColorRange: ${{ steps.coverage.outputs.pct }}
minColorRange: 50
maxColorRange: 100