benchmark-action / benchmark-action/github-action-benchmark

Output a Markdown result directly for custom integrations

Open
#154 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

Hi!

To integrate this action into a tight feedback loop with my devs, I wanted to have a comment on each PR containing the latest run of this action, like a lot of tools do (Codecov, SonarCloud, Vercel, ...). I cannot do that today because this action only allows me to post a comment on each commit which is really not a good DX IMO.

The issue here is that this action does not provide any way of retrieving the Markdown text it would put in the commit comments. More, considering the [Job Summary PR](https://github.com/benchmark-action/github-action-benchmark/pull/138), it is using another textual representation of the results.

It would be really great to have a common Markdown representation of the results: the code will be simpler because only one code _to rule them all_, and anybody wanting to create a custom integration could re-use it directly. This can be done through a custom temporary file containing the Markdown, or an action output directly.

The [create-or-update-comment action](https://github.com/marketplace/actions/create-or-update-comment) by Peter Evans enables to do it with custom content very easily, we could end with something like:

```yaml
- name: Compute benchmark results
uses: benchmark-action/github-action-benchmark@v1
id: benchmark
with:
tool: 'benchmarkjs'
output-file-path: output.txt
external-data-json-path: ./cache/benchmark-data.json
name: Benchmark.js Benchmark
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-alert: true

- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Performance Alert

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.benchmark.outputs.markdown-results }}
edit-mode: replace
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.