Skip to content

Commit 5d8d98c

Browse files
committed
[libc++] Report the results of the benchmarking job back through a comment
1 parent aa32b6f commit 5d8d98c

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

.github/workflows/libcxx-run-benchmarks.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name: Benchmark libc++
1111

1212
permissions:
13-
contents: read # Default everything to read-only
13+
contents: read
1414

1515
on:
1616
issue_comment:
@@ -24,6 +24,9 @@ env:
2424

2525
jobs:
2626
run-benchmarks:
27+
permissions:
28+
pull-requests: write
29+
2730
if: >-
2831
github.event.issue.pull_request &&
2932
contains(github.event.comment.body, '/libcxx-bot benchmark')
@@ -40,6 +43,7 @@ jobs:
4043
python3 -m venv .venv
4144
source .venv/bin/activate
4245
python -m pip install pygithub
46+
4347
cat <<EOF | python >> ${GITHUB_OUTPUT}
4448
import github
4549
repo = github.Github("${{ github.token }}").get_repo("${{ github.repository }}")
@@ -59,18 +63,47 @@ jobs:
5963

6064
- name: Run baseline
6165
run: |
62-
source .venv/bin/activate
63-
python -m pip install -r repo/libcxx/utils/requirements.txt
64-
baseline_commit=$(git -C repo merge-base ${{ steps.vars.outputs.pr_base }} ${{ steps.vars.outputs.pr_head }})
65-
./repo/libcxx/utils/test-at-commit --git-repo repo --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
66+
source .venv/bin/activate && cd repo
67+
python -m pip install -r libcxx/utils/requirements.txt
68+
baseline_commit=$(git merge-base ${{ steps.vars.outputs.pr_base }} ${{ steps.vars.outputs.pr_head }})
69+
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
6670
6771
- name: Run candidate
6872
run: |
69-
source .venv/bin/activate
70-
./repo/libcxx/utils/test-at-commit --git-repo repo --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
73+
source .venv/bin/activate && cd repo
74+
./libcxx/utils/test-at-commit --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
7175
7276
- name: Compare baseline and candidate runs
7377
run: |
74-
source .venv/bin/activate
75-
./repo/libcxx/utils/compare-benchmarks <(./repo/libcxx/utils/consolidate-benchmarks build/baseline) \
76-
<(./repo/libcxx/utils/consolidate-benchmarks build/candidate)
78+
source .venv/bin/activate && cd repo
79+
./libcxx/utils/compare-benchmarks <(./libcxx/utils/consolidate-benchmarks build/baseline) \
80+
<(./libcxx/utils/consolidate-benchmarks build/candidate) > results.txt
81+
82+
- name: Update comment with results
83+
run: |
84+
source .venv/bin/activate && cd repo
85+
cat <<EOF | python
86+
import github
87+
repo = github.Github("${{ github.token }}").get_repo("${{ github.repository }}")
88+
pr = repo.get_pull(${{ github.event.issue.number }})
89+
comment = pr.get_issue_comment(${{ github.event.comment.id }})
90+
with open('results.txt', 'r') as f:
91+
benchmark_results = f.read()
92+
93+
new_comment_text = f"""
94+
{comment.body}
95+
96+
<details>
97+
<summary>
98+
Benchmark results:
99+
</summary>
100+
101+
\`\`\`
102+
{benchmark_results}
103+
\`\`\`
104+
105+
</details>
106+
"""
107+
108+
comment.edit(new_comment_text)
109+
EOF

0 commit comments

Comments
 (0)