Skip to content

Commit

Permalink
allows benchmark results to be commented securely even from forks
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Apr 30, 2021
1 parent ae3f7dc commit c74a047
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

jobs:
benchmark:
performance-tracking:
runs-on: ubuntu-latest
steps:
# setup
Expand All @@ -16,7 +16,7 @@ jobs:
- name: install dependencies
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'

# benchmark
# run the benchmark suite
- name: run benchmarks
run: |
julia -e '
Expand All @@ -25,9 +25,8 @@ jobs:
BenchmarkCI.displayjudgement()
'
# generate result markdown
# generate and record the benchmark result as markdown
- name: generate benchmark result
id: generate-result-markdown
run: |
body=$(julia -e '
using BenchmarkCI
Expand All @@ -42,27 +41,14 @@ jobs:
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
echo $body > ./benchmark-result.artifact
# check if the previous comment exists
- name: find comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: JET Benchmark Result
# record the pull request number
- name: record pull request number
run: echo ${{ github.event.pull_request.number }} > ./pull-request-number.artifact

# create/update comment
- name: create comment
if: ${{ steps.fc.outputs.comment-id == 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.generate-result-markdown.outputs.body }}
- name: update comment
if: ${{ steps.fc.outputs.comment-id != 0 }}
uses: peter-evans/create-or-update-comment@v1
# save as artifacts (performance tracking (comment) workflow will use it)
- uses: actions/upload-artifact@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: ${{ steps.generate-result-markdown.outputs.body }}
name: perforamance-tracking
path: ./*.artifact

0 comments on commit c74a047

Please sign in to comment.