-
Notifications
You must be signed in to change notification settings - Fork 2
62 lines (57 loc) · 1.72 KB
/
test-vitest-coverage-action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: "Test"
on:
push:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- ${{ github.head_ref }}
- "main"
permissions:
# Required to checkout the code
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- run: echo "Repo is '${{ github.repository }}', PR repo is ${{github.event.pull_request.head.repo.full_name}}"
- name: "Install Node"
uses: actions/setup-node@v4
with:
node-version: "18.x"
- name: "Install Deps"
run: npm install
- uses: actions/github-script@v7
with:
script: |
console.log(JSON.stringify(context, null, 2))
- name: "Test"
run: npx vitest --coverage.enabled true
- name: "Upload Coverage"
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.branch }}
path: coverage
report-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: "Download Coverage Artifacts"
uses: actions/download-artifact@v4
with:
name: coverage-${{ github.head_ref }}
path: coverage
- uses: actions/download-artifact@v4
with:
name: coverage-main
path: coverage-main
- name: "Echo Ref"
run: echo ${{ github.ref }}
- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@test-automatic-pr
with:
json-summary-compare-path: coverage-main/coverage-summary.json
pr-number: ${{ github.ref == 'refs/heads/main' && '' || 'auto' }}