Skip to content

Commit 4f8864e

Browse files
committed
github-action-bot: use URL for benchmark report instead of embedding it into comment
Currently benchmark report is posted directly to comment, but because of terminal color codes it look unreadable. Sadly, github doesn't provide any mechanism to add colors to the comment text (even in code blocks). The best solution I can think of is to link to GH own logs to show benchmark report
1 parent f0fda8b commit 4f8864e

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

.github/workflows/cmd-run-benchmark.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,30 @@ jobs:
3232

3333
- name: Run Benchmark
3434
run: |
35-
cat <<EOF >> replyMessage.txt
36-
<details>
37-
<summary> Benchmark output </summary>
38-
EOF
39-
npm run benchmark -- --revs HEAD BASE | tee -a replyMessage.txt
40-
cat <<EOF >> replyMessage.txt
41-
</details>
42-
EOF
35+
npm run benchmark -- --revs HEAD BASE
36+
37+
- name: Create replyMessage
38+
uses: actions/github-script@v5
39+
with:
40+
script: |
41+
const fs = require('fs');
42+
43+
// GH doesn't expose job's id so we need to get it through API, see
44+
// https://github.community/t/job-id-is-string-in-github-job-but-integer-in-actions-api/139060
45+
const result = await github.rest.actions.listJobsForWorkflowRun({
46+
...context.repo,
47+
run_id: context.runId,
48+
filter: 'latest',
49+
})
50+
51+
const currentJob = result.data.jobs.find(
52+
(job) => job.name === 'cmd-run-benchmark / Run benchmark',
53+
);
54+
55+
fs.writeFileSync(
56+
'./replyMessage.txt',
57+
`Please, see benchmark results here: ${currentJob.html_url}#step:6:1`,
58+
);
4359
4460
- name: Upload replyMessage
4561
uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)