-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (39 loc) 路 1.19 KB
/
Copy pathpr-coverage.yml
File metadata and controls
48 lines (39 loc) 路 1.19 KB
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
name: PR Coverage Test
on:
pull_request:
branches: [ main ]
permissions:
contents: write
pull-requests: write
jobs:
test-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Clean install dependencies
run: |
rm -rf node_modules package-lock.json
npm install --ignore-scripts
npm rebuild
- name: Run tests with coverage
run: npm run test:coverage
- name: Generate coverage badge
run: npm run coverage:badge
- name: Commit and push coverage badge
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add badges/coverage.svg
if ! git diff --staged --quiet; then
git commit -m "Update coverage badge [skip ci]"
git push origin HEAD:${{ github.head_ref }}
fi