Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test Coverage

on:
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Run tests with coverage
run: |
npm run test:coverage > coverage-output.txt 2>&1

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage-output.txt
retention-days: 1

comment:
runs-on: ubuntu-latest
needs: test
permissions:
pull-requests: write

steps:
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-report

- name: Read coverage report
id: coverage
run: |
echo "COVERAGE_REPORT<<EOF" >> $GITHUB_OUTPUT
cat coverage-output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Post coverage comment
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## Test Coverage Report

```
${{ steps.coverage.outputs.COVERAGE_REPORT }}
```

---
*Coverage report generated by GitHub Actions*
Loading