Skip to content

Commit

Permalink
github-action-bot: use URL for benchmark report instead of embedding …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
IvanGoncharov committed May 25, 2022
1 parent f0fda8b commit 4f8864e
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/cmd-run-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,30 @@ jobs:

- name: Run Benchmark
run: |
cat <<EOF >> replyMessage.txt
<details>
<summary> Benchmark output </summary>
EOF
npm run benchmark -- --revs HEAD BASE | tee -a replyMessage.txt
cat <<EOF >> replyMessage.txt
</details>
EOF
npm run benchmark -- --revs HEAD BASE
- name: Create replyMessage
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
// GH doesn't expose job's id so we need to get it through API, see
// https://github.community/t/job-id-is-string-in-github-job-but-integer-in-actions-api/139060
const result = await github.rest.actions.listJobsForWorkflowRun({
...context.repo,
run_id: context.runId,
filter: 'latest',
})
const currentJob = result.data.jobs.find(
(job) => job.name === 'cmd-run-benchmark / Run benchmark',
);
fs.writeFileSync(
'./replyMessage.txt',
`Please, see benchmark results here: ${currentJob.html_url}#step:6:1`,
);
- name: Upload replyMessage
uses: actions/upload-artifact@v2
Expand Down

0 comments on commit 4f8864e

Please sign in to comment.