Skip to content

Commit f0a2258

Browse files
committed
Test simple coverage report in PR
1 parent 1e72696 commit f0a2258

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ jobs:
4040

4141
- run: yarn
4242

43-
- run: yarn test:ci
43+
- run: yarn test:ci --coverage
44+
45+
# Upload coverage as artifact for the comment workflow
46+
- uses: actions/upload-artifact@v4
47+
if: always()
48+
with:
49+
name: coverage-report
50+
path: coverage/
51+
retention-days: 1
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Coverage Comment
2+
3+
on:
4+
workflow_run:
5+
workflows: ["ci"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment:
11+
runs-on: ubuntu-22.04
12+
if: github.event.workflow_run.event == 'pull_request'
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
# Download coverage from the CI workflow
21+
- uses: actions/download-artifact@v4
22+
with:
23+
name: coverage-report
24+
path: coverage
25+
run-id: ${{ github.event.workflow_run.id }}
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Coverage Report
29+
uses: davelosert/vitest-coverage-report-action@v2
30+
with:
31+
json-summary-path: ./coverage/coverage-summary.json
32+
json-final-path: ./coverage/coverage-final.json
33+
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}

vitest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export default defineConfig({
1616
fileParallelism: true,
1717
coverage: {
1818
provider: "v8",
19+
reporter: ["text", "json-summary", "json", "html"],
20+
reportsDirectory: "./coverage",
21+
reportOnFailure: true,
1922
},
2023
},
2124
resolve: {

0 commit comments

Comments
 (0)