@@ -11,7 +11,7 @@ permissions:
11
11
jobs :
12
12
reply-to-benchmark :
13
13
if : |
14
- github.event.comment.body == '@benchmark' &&
14
+ startsWith( github.event.comment.body, '@benchmark') &&
15
15
github.event.issue.pull_request &&
16
16
(
17
17
github.event.comment.user.login == 'tchaton' ||
24
24
runs-on : ubuntu-latest
25
25
steps :
26
26
- uses : actions/checkout@v4
27
+ - name : Extract make args
28
+ id : extract
29
+ uses : actions/github-script@v7
30
+ with :
31
+ script : |
32
+ const fullComment = context.payload.comment.body;
33
+ const parts = fullComment.trim().split(/\s+/);
34
+ const makeargs = parts.slice(1).join(' '); // remove "@benchmark" and keep rest
35
+ core.setOutput("make_args", makeargs);
36
+
27
37
- name : Reply to PR comment and save ID
28
38
id : comment
29
39
uses : actions/github-script@v7
35
45
const username = context.payload.comment.user.login;
36
46
const prNumber = context.payload.issue.number;
37
47
48
+ const pr = await github.rest.pulls.get({
49
+ owner: context.repo.owner,
50
+ repo: context.repo.repo,
51
+ pull_number: context.payload.issue.number,
52
+ });
53
+ const branch = pr.data.head.ref;
54
+
38
55
// Replace placeholders
39
56
const reply = replyTemplate
40
57
.replace(/{{username}}/g, username)
@@ -49,12 +66,19 @@ jobs:
49
66
50
67
core.setOutput("comment_id", response.data.id);
51
68
core.setOutput("prNumber", prNumber);
69
+ core.setOutput("branch", branch);
52
70
core.setOutput("username", username);
53
71
54
72
- name : run python
55
73
run : |
56
74
pip install -U lightning-sdk
57
- python .github/benchmark/benchmark.py --pr ${{ steps.comment.outputs.prNumber }}
75
+ echo '"pr number: ${{ steps.comment.outputs.prNumber }}"; "branch: ${{ steps.comment.outputs.branch }}"'
76
+ echo "make-args: ${{steps.extract.outputs.make_args}}"
77
+ python .github/benchmark/benchmark.py \
78
+ --pr "${{ steps.comment.outputs.prNumber }}" \
79
+ --branch "${{ steps.comment.outputs.branch }}" \
80
+ --make-args "${{ steps.extract.outputs.make_args }}" \
81
+ 2> error.txt || true
58
82
env : # the following values are parsed from the repository secrets
59
83
LIGHTNING_USER_ID : ${{ secrets.LIGHTNING_USER_ID }}
60
84
LIGHTNING_API_KEY : ${{ secrets.LIGHTNING_API_KEY }}
@@ -67,11 +91,19 @@ jobs:
67
91
with :
68
92
script : |
69
93
const fs = require('fs');
70
- const path = 'result.md';
71
- const reply = fs.readFileSync(path, 'utf8');
72
-
73
94
const comment_id = Number(process.env.COMMENT_ID);
74
- const updated_body = `Hi @${process.env.USERNAME}!\n\n- Benchmarking output:\n\n${reply}\n\n\ncc: @tchaton @deependujha @bhimrazy`;
95
+
96
+ let reply = '';
97
+ if (fs.existsSync('result.md')) {
98
+ reply = fs.readFileSync('result.md', 'utf8');
99
+ } else if (fs.existsSync('error.txt') && fs.readFileSync('error.txt', 'utf8').trim().length > 0) {
100
+ const err = fs.readFileSync('error.txt', 'utf8');
101
+ reply = `❌ **Benchmark failed**\n\n\`\`\`\n${err}\n\`\`\``;
102
+ } else {
103
+ reply = '❌ Benchmark completed, but can\'t find `result.md` and `error.txt` file. Something went wrong.';
104
+ }
105
+
106
+ const updated_body = `Hi @${process.env.USERNAME}!\n\n${reply}\n\ncc: @tchaton @deependujha @bhimrazy`;
75
107
76
108
await github.rest.issues.updateComment({
77
109
owner: context.repo.owner,
0 commit comments