-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (76 loc) · 2.66 KB
/
profiler.yml
File metadata and controls
92 lines (76 loc) · 2.66 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Performance Benchmark
on:
pull_request:
branches: ["**"]
paths:
- "src/*"
workflow_dispatch:
jobs:
benchmark:
name: Run Benchmark
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
src/layout-engine/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('src/layout-engine/src/lib.rs') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup mise
uses: jdx/mise-action@v2
with:
cache: true
- name: Install toolchains
run: mise install
- name: Install dependencies
run: mise exec -- bun install --frozen-lockfile
- name: Build Binary
run: mise run build:ffi
- name: Run Limit Test
run: |
mise run profiler:limit | tee benchmark_result.txt
- name: Extract Report
id: extract_report
run: |
REPORT=$(sed -n '/Performance Limits Report/,$p' benchmark_result.txt)
echo "REPORT_CONTENT<<EOF" >> $GITHUB_ENV
echo "$REPORT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment Benchmark Result
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const report = process.env.REPORT_CONTENT;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Performance Limits Report');
});
const body = `### 🚀 Performance Benchmark Result\n\n\`\`\`text\n${report}\n\`\`\`\n\n<details><summary>Run Details</summary>\nTriggered by commit: ${context.sha}</details>`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}