-
Notifications
You must be signed in to change notification settings - Fork 39
Allows to trigger on labelling and clean-up the process #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
96efe9e
Allows to trigger on comment and on labelling
theogf 1538fdb
Remove previous runs and fix typo
theogf 7511f87
This should work?
theogf 84a5574
Godamm parenthesis!
theogf 2b8f76a
Update benchmark.yml
theogf a48f728
Update benchmark.yml
theogf 9b63115
New try?
theogf 7d3f5ea
Merge branch 'master' into tgf/benchmark_trigger
theogf 9f412c1
Use created instead of opened
theogf 08c5422
Inplace comment
theogf da6863f
Remove comment workflow
theogf 0ee73fa
Correct naming
theogf c8fbd92
Missing the most important part
theogf db342c8
Add the whole workflow from JET.jl
theogf 08c52d8
Apply suggestions from code review
theogf 6ee340e
Update benchmark.yml
theogf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Credit to @aviastek, where this code comes from in JET.jl | ||
|
||
# To workaroud https://github.com/actions/first-interaction/issues/10 in a secure way, | ||
# we take the following steps to generate and comment a performance benchmark result: | ||
# 1. first "performance tracking" workflow will generate the benchmark results in an unprivileged environment triggered on `pull_request` event | ||
# 2. then this "performance tracking (comment)" workflow will show the result to us as a PR comment in a privileged environment | ||
# Note that this workflow can only be modifed by getting checked-in to the default branch | ||
# and thus is secure even though this workflow is granted with write permissions, etc. | ||
# xref: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
|
||
name: Post Benchmark Comments | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- performance tracking | ||
types: | ||
- completed | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
if: > | ||
${{ github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# restore records from the artifacts | ||
- uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: benchmark.yml | ||
name: Benchmarking | ||
workflow_conclusion: success | ||
- name: output benchmark result | ||
id: output-result-markdown | ||
run: | | ||
echo ::set-output name=body::$(cat ./benchmark-result.artifact) | ||
- name: output pull request number | ||
id: output-pull-request-number | ||
run: | | ||
echo ::set-output name=body::$(cat ./pull-request-number.artifact) | ||
# check if the previous comment exists | ||
- name: find comment | ||
uses: peter-evans/find-comment@v1 | ||
id: fc | ||
with: | ||
issue-number: ${{ steps.output-pull-request-number.outputs.body }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: Kernel Benchmark Result | ||
|
||
theogf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# create/update comment | ||
- name: create comment | ||
if: ${{ steps.fc.outputs.comment-id == 0 }} | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
issue-number: ${{ steps.output-pull-request-number.outputs.body }} | ||
body: ${{ steps.output-result-markdown.outputs.body }} | ||
- name: update comment | ||
if: ${{ steps.fc.outputs.comment-id != 0 }} | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
body: ${{ steps.output-result-markdown.outputs.body }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,58 @@ name: Run benchmarks | |
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, labeled] | ||
|
||
concurrency: | ||
# Skip intermediate builds: always. | ||
# Cancel intermediate builds: only if it is a pull request build. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
|
||
jobs: | ||
Benchmark: | ||
Benchmarking: | ||
runs-on: ubuntu-latest | ||
if: contains(github.event.pull_request.labels.*.name, 'performance critical') | ||
env: | ||
JULIA_DEBUG: BenchmarkCI | ||
steps: | ||
# setup | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: 1.6 | ||
- name: Install dependencies | ||
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI"' | ||
- name: Run benchmarks | ||
run: julia -e "using BenchmarkCI; BenchmarkCI.judge()" | ||
- name: Post results | ||
run: julia -e "using BenchmarkCI; BenchmarkCI.postjudge()" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
version: 'nightly' | ||
theogf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- uses: julia-actions/julia-buildpkg@latest | ||
- name: install dependencies | ||
run: julia -e 'using Pkg; pkg"add PkgBenchmark [email protected]"' | ||
|
||
theogf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# run the benchmark suite | ||
- name: run benchmarks | ||
run: | | ||
julia -e ' | ||
using BenchmarkCI | ||
BenchmarkCI.judge() | ||
BenchmarkCI.displayjudgement() | ||
' | ||
theogf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# generate and record the benchmark result as markdown | ||
- name: generate benchmark result | ||
run: | | ||
body=$(julia -e ' | ||
using BenchmarkCI | ||
let | ||
judgement = BenchmarkCI._loadjudge(BenchmarkCI.DEFAULT_WORKSPACE) | ||
title = "Kernel 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 | ||
theogf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# record the pull request number | ||
- name: record pull request number | ||
run: echo ${{ github.event.pull_request.number }} > ./pull-request-number.artifact | ||
|
||
theogf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# save as artifacts (performance tracking (comment) workflow will use it) | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Benchmarking | ||
path: ./*.artifact |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.