-
Notifications
You must be signed in to change notification settings - Fork 87
86 lines (75 loc) · 3.01 KB
/
bench_upload_for_pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Benchmark upload
#
# This workflow runs after every benchmark, to upload the report to S3.
#
# It is its own workflow, because PRs can contain malicious code and run in a context with secrets..
#
# See also https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
#
on:
workflow_run:
workflows: ["Benchmarks"]
types:
- completed
jobs:
upload:
name: Upload benchmark report
runs-on: warp-ubuntu-latest-x64-16x
if: github.event.workflow_run.conclusion == 'success'
steps:
# https://github.com/actions/download-artifact
- uses: actions/download-artifact@v4
with:
name: benchmark-report.zip
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Extract report
run: |
unzip benchmark-report.zip
ls -alh benchmark-report/
- name: Prepare variables
id: prepare
run: |
cat benchmark-report/vars.txt
source benchmark-report/vars.txt
S3_UPLOAD_DIR="benchmark/${HEAD_SHA_SHORT}-${BASE_SHA_SHORT}"
echo "S3_UPLOAD_DIR=${S3_UPLOAD_DIR}" >> "$GITHUB_OUTPUT"
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
# Upload S3 (using https://github.com/shallwefootball/upload-s3-action)
- name: Upload to S3
uses: shallwefootball/s3-upload-action@master
id: S3
with:
aws_key_id: ${{secrets.AWS_KEY_ID}}
aws_secret_access_key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: flashbots-rbuilder-ci-stats
source_dir: benchmark-report
destination_dir: ${{ steps.prepare.outputs.S3_UPLOAD_DIR }}
#
# POST SUMMARY (to PR comment and CI job summary)
#
- name: Add summary to CI job summary
run: |
BENCH_URL="https://flashbots-rbuilder-ci-stats.s3.us-east-2.amazonaws.com/${{steps.S3.outputs.object_key}}/report/index.html"
sed -i "s|__BENCH_URL__|${BENCH_URL}|" benchmark-report/benchmark-pr-comment.md
cat benchmark-report/benchmark-pr-comment.md
cat benchmark-report/benchmark-pr-comment.md >> $GITHUB_STEP_SUMMARY
cat benchmark-report/benchmark-summary.md >> $GITHUB_STEP_SUMMARY
# https://github.com/peter-evans/find-comment
- name: Find previous PR comment
if: steps.prepare.outputs.PR_NUMBER != ''
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ steps.prepare.outputs.PR_NUMBER }}
comment-author: 'github-actions[bot]'
body-includes: Benchmark results
# https://github.com/peter-evans/create-or-update-comment
- name: Create or update PR comment
if: steps.prepare.outputs.PR_NUMBER != ''
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.prepare.outputs.PR_NUMBER }}
edit-mode: replace
body-path: benchmark-report/benchmark-pr-comment.md