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 ac878f6 commit 7273cfb
Showing 1 changed file with 38 additions and 50 deletions.
88 changes: 38 additions & 50 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,53 @@ on:
pull_request:

jobs:
benchmark:
performance-tracking:
runs-on: ubuntu-latest
steps:
# setup
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: 'nightly'
- uses: julia-actions/julia-buildpkg@latest
- name: install dependencies
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'
# - uses: julia-actions/setup-julia@latest
# with:
# version: 'nightly'
# - uses: julia-actions/julia-buildpkg@latest
# - name: install dependencies
# run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI@0.1"'

# benchmark
- name: run benchmarks
# run: |
# julia -e '
# using BenchmarkCI
# BenchmarkCI.judge()
# BenchmarkCI.displayjudgement()
# '
run: |
julia -e '
using BenchmarkCI
BenchmarkCI.judge()
BenchmarkCI.displayjudgement()
'
echo "hi there, stranger" > ./benchmark-result.artifact
# generate result markdown
- name: generate benchmark result
id: generate-result-markdown
run: |
body=$(julia -e '
using BenchmarkCI
# # generate result markdown
# - name: generate benchmark result
# run: |
# body=$(julia -e '
# using BenchmarkCI
#
# let
# judgement = BenchmarkCI._loadjudge(BenchmarkCI.DEFAULT_WORKSPACE)
# title = "JET Benchmark Result"
# ciresult = BenchmarkCI.CIResult(; judgement, title)
# BenchmarkCI.printcommentmd(stdout::IO, ciresult)
# end
# ')
# body="${body//'%'/'%25'}"
# body="${body//$'\n'/'%0A'}"
# body="${body//$'\r'/'%0D'}"
# echo $body > ./benchmark-result.artifact

let
judgement = BenchmarkCI._loadjudge(BenchmarkCI.DEFAULT_WORKSPACE)
title = "JET Benchmark Result"
ciresult = BenchmarkCI.CIResult(; judgement, title)
BenchmarkCI.printcommentmd(stdout::IO, ciresult)
end
')
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
# record pull request number
- name: record pull request number
run: echo ${{ github.event.pull_request.number }} > ./pull-request-number.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

# 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
# record to artifacts
- 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 7273cfb

Please sign in to comment.