-
-
Notifications
You must be signed in to change notification settings - Fork 63
176 lines (153 loc) · 6.05 KB
/
resolution-time.yml
File metadata and controls
176 lines (153 loc) · 6.05 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Resolution time benchmark
on:
pull_request:
jobs:
resolution-time:
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.27.0
run_install: false
- name: Checkout PR branch
uses: actions/checkout@v4
with:
path: pr-branch
- name: Checkout target branch
uses: actions/checkout@v4
with:
path: target-branch
ref: ${{ github.base_ref }}
- name: Checkout latest release
uses: actions/checkout@v4
with:
path: release-branch
ref: release
- name: Copy resolution-time app to release checkout
run: |
if [ ! -d release-branch/apps/resolution-time ]; then
cp -r target-branch/apps/resolution-time release-branch/apps/resolution-time
echo "Copied resolution-time app from target branch to release checkout"
else
echo "resolution-time app already exists in release checkout"
fi
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24.x
cache: 'pnpm'
cache-dependency-path: |
pr-branch/pnpm-lock.yaml
target-branch/pnpm-lock.yaml
release-branch/pnpm-lock.yaml
- name: Install dependencies (PR branch)
working-directory: pr-branch
run: pnpm install --frozen-lockfile
- name: Install dependencies (target branch)
working-directory: target-branch
run: pnpm install --frozen-lockfile
- name: Install dependencies (release branch)
working-directory: release-branch
run: pnpm install --no-frozen-lockfile
- name: Run benchmark (PR branch)
working-directory: pr-branch
run: pnpm --filter resolution-time resolution-time
- name: Run benchmark (target branch)
working-directory: target-branch
run: pnpm --filter resolution-time resolution-time
- name: Run benchmark (release branch)
working-directory: release-branch
run: pnpm --filter resolution-time resolution-time
- name: Generate chart (random)
run: |
node pr-branch/apps/resolution-time/generateChart.ts \
--input "PR:pr-branch/apps/resolution-time/results-random.json" \
--input "main:target-branch/apps/resolution-time/results-random.json" \
--input "release:release-branch/apps/resolution-time/results-random.json" \
--title "Random Branching" \
--xAxisTitle "max depth" \
--yAxisTitle "time (ms)" \
--output chart-random.md
- name: Generate chart (linear)
run: |
node pr-branch/apps/resolution-time/generateChart.ts \
--input "PR:pr-branch/apps/resolution-time/results-linear-recursion.json" \
--input "main:target-branch/apps/resolution-time/results-linear-recursion.json" \
--input "release:release-branch/apps/resolution-time/results-linear-recursion.json" \
--title "Linear Recursion" \
--xAxisTitle "max depth" \
--yAxisTitle "time (ms)" \
--output chart-linear.md
- name: Generate chart (max depth)
run: |
node pr-branch/apps/resolution-time/generateChart.ts \
--input "PR:pr-branch/apps/resolution-time/results-max-depth.json" \
--input "main:target-branch/apps/resolution-time/results-max-depth.json" \
--input "release:release-branch/apps/resolution-time/results-max-depth.json" \
--title "Full Tree" \
--xAxisTitle "max depth" \
--yAxisTitle "time (ms)" \
--output chart-max-depth.md
- name: Prepare comment
run: |
{
echo "## Resolution Time Benchmark"
echo ""
cat chart-random.md
echo ""
cat chart-linear.md
echo ""
cat chart-max-depth.md
} > comparison.md
- name: Comment PR with results
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const comparison = fs.readFileSync('comparison.md', 'utf8');
const botCommentIdentifier = '<!-- resolution-time-bot-comment -->';
async function findBotComment(issueNumber) {
if (!issueNumber) return null;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
});
return comments.data.find((comment) =>
comment.body.includes(botCommentIdentifier)
);
}
async function createOrUpdateComment(issueNumber) {
if (!issueNumber) {
console.log('No issue number provided. Cannot post or update comment.');
return;
}
const existingComment = await findBotComment(issueNumber);
if (existingComment) {
await github.rest.issues.updateComment({
...context.repo,
comment_id: existingComment.id,
body: botCommentIdentifier + '\n' + comparison,
});
} else {
await github.rest.issues.createComment({
...context.repo,
issue_number: issueNumber,
body: botCommentIdentifier + '\n' + comparison,
});
}
}
const issueNumber = context.issue.number;
if (!issueNumber) {
console.log('No issue number found in context. Skipping comment.');
} else {
await createOrUpdateComment(issueNumber);
}
await core.summary
.addRaw(comparison)
.write();