-
Notifications
You must be signed in to change notification settings - Fork 459
69 lines (59 loc) · 1.91 KB
/
coverage-report.yml
File metadata and controls
69 lines (59 loc) · 1.91 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Regression Tests Coverage Report
on:
pull_request_target:
paths:
- "content/**/examples/**"
- "test/**"
- "!content/landmarks/examples/**"
permissions:
contents: read
issues: write
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: refs/pull/${{ github.event.pull_request.number }}/head
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: npm
- name: Install dependencies
run: npm ci
- name: Run coverage report
run: |
node test/util/report.js >> coverage.log || true
- name: Comment on PR
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const commentBody = fs.readFileSync('coverage.log', 'utf8');
if (commentBody.length === 0) {
return
}
// Get the existing comments.
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
})
// Find any comment already made by the bot.
const botComment = comments.find(comment => comment.user.id === 41898282)
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
body: commentBody
})
}