-
Notifications
You must be signed in to change notification settings - Fork 27
154 lines (136 loc) · 4.77 KB
/
Copy pathmemory-benchmark.yml
File metadata and controls
154 lines (136 loc) · 4.77 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Memory benchmark
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: memory-benchmark-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
compare:
name: Compare base and PR memory
runs-on: macos-14
timeout-minutes: 15
permissions:
contents: read
env:
PI_VERSION: 0.82.1
BUN_VERSION: 1.3.11
NODE_VERSION: 22.19.0
MEMORY_BENCHMARK_RUNS: 6
MEMORY_BENCHMARK_WARMUP_MS: 2500
MEMORY_BENCHMARK_SAMPLES: 12
MEMORY_BENCHMARK_INTERVAL_MS: 100
steps:
- name: Check out benchmark implementation
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
path: benchmark
persist-credentials: false
- name: Check out base revision
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
persist-credentials: false
- name: Check out PR revision
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
path: head
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: |
base/package-lock.json
head/package-lock.json
- uses: oven-sh/setup-bun@v2.2.0
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install base dependencies
working-directory: base
run: npm ci --ignore-scripts
- name: Install PR dependencies
working-directory: head
run: npm ci --ignore-scripts
- name: Install pinned pi host
run: |
npm install \
--prefix pi-host \
--ignore-scripts \
--no-save \
"@earendil-works/pi-coding-agent@$PI_VERSION"
- name: Compare memory usage
env:
MEMORY_BENCHMARK_BASE_PATH: ${{ github.workspace }}/base
MEMORY_BENCHMARK_HEAD_PATH: ${{ github.workspace }}/head
MEMORY_BENCHMARK_PI_CLI: ${{ github.workspace }}/pi-host/node_modules/@earendil-works/pi-coding-agent/dist/cli.js
MEMORY_BENCHMARK_BASE_SHA: ${{ github.event.pull_request.base.sha }}
MEMORY_BENCHMARK_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
MEMORY_BENCHMARK_PI_VERSION: ${{ env.PI_VERSION }}
MEMORY_BENCHMARK_OUTPUT: ${{ github.workspace }}/memory-benchmark.md
MEMORY_BENCHMARK_JSON_OUTPUT: ${{ github.workspace }}/memory-benchmark.json
run: bun benchmark/.github/scripts/memory-benchmark.mjs
- name: Add benchmark to job summary
if: always() && hashFiles('memory-benchmark.md') != ''
run: cat memory-benchmark.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload benchmark report
if: always() && hashFiles('memory-benchmark.md') != ''
uses: actions/upload-artifact@v7
with:
name: memory-benchmark-report
path: |
memory-benchmark.md
memory-benchmark.json
retention-days: 30
comment:
name: Update PR comment
needs: compare
if: >-
always() &&
needs.compare.result == 'success' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
pull-requests: write
steps:
- name: Download benchmark report
uses: actions/download-artifact@v8
with:
name: memory-benchmark-report
- name: Update sticky PR comment
uses: actions/github-script@v9
env:
REPORT_PATH: memory-benchmark.md
with:
script: |
const fs = require("node:fs")
const marker = "<!-- pi-commandcode-memory-benchmark -->"
const report = fs.readFileSync(process.env.REPORT_PATH, "utf8")
const body = `${marker}\n${report}`
const { owner, repo } = context.repo
const issue_number = context.issue.number
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
})
const previous = comments.find(
(comment) => comment.user?.type === "Bot" && comment.body?.includes(marker),
)
if (previous) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: previous.id,
body,
})
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body })
}