Skip to content

Commit 88e6e52

Browse files
fix(committer): update committer benchmark comment
1 parent 43a88a2 commit 88e6e52

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

.github/workflows/committer_ci.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,36 @@ jobs:
103103

104104
- run: echo BENCHES_RESULT=$(cat bench_new.txt) >> $GITHUB_ENV
105105

106-
# Post comment in case of performance regression or improvement.
107106
- run: npm install fs
108-
- if: contains(env.BENCHES_RESULT, 'regressed') || contains(env.BENCHES_RESULT, 'improved')
109-
uses: actions/github-script@v6
107+
108+
# Comment with a link to the workflow (or update existing comment on rerun).
109+
- name: Find Comment
110+
if: github.event_name == 'pull_request'
111+
uses: starkware-libs/find-comment@v3
112+
id: find-benchmark-comment
113+
with:
114+
token: ${{ secrets.GITHUB_TOKEN }}
115+
issue-number: ${{ github.event.pull_request.number }}
116+
comment-author: 'github-actions[bot]'
117+
body-includes: Benchmark movements
118+
119+
- name: Create comment
120+
# If the PR number is found and the comment is not found, create a new comment.
121+
if: github.event_name == 'pull_request'
122+
&& steps.find-benchmark-comment.outputs.comment-id == ''
123+
uses: starkware-libs/create-or-update-comment@v4
124+
with:
125+
token: ${{ secrets.GITHUB_TOKEN }}
126+
issue-number: ${{ github.event.pull_request.number }}
127+
body: ${{ env.BENCHES_RESULT }}
128+
129+
- name: Update comment
130+
# If the PR number is found and the comment exists, update it.
131+
if: github.event_name == 'pull_request'
132+
&& steps.find-benchmark-comment.outputs.comment-id != ''
133+
uses: starkware-libs/create-or-update-comment@v4
110134
with:
111-
script: |
112-
const fs = require('fs')
113-
github.rest.issues.createComment({
114-
issue_number: context.issue.number,
115-
owner: context.repo.owner,
116-
repo: context.repo.repo,
117-
body: fs.readFileSync('bench_new.txt', 'utf8'),
118-
path: 'Commits'
119-
})
135+
token: ${{ secrets.GITHUB_TOKEN }}
136+
comment-id: ${{ steps.find-benchmark-comment.outputs.comment-id }}
137+
edit-mode: replace
138+
body: ${{ env.BENCHES_RESULT }}

crates/starknet_committer_and_os_cli/benches/bench_split_and_prepare_post.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cat ${benchmarks_list} |
1313
done
1414

1515
# Prepare the results for posting comment.
16-
echo "Benchmark movements:" > ${benchmark_results}
16+
echo "Benchmark movements: " > ${benchmark_results}
1717
cat ${benchmarks_list} |
1818
while read line; do
1919
if grep -q "regressed" ${line}.txt; then
@@ -24,3 +24,6 @@ cat ${benchmarks_list} |
2424
cat ${line}.txt >> ${benchmark_results};
2525
fi;
2626
done
27+
if ! (grep -q "regressed" ${benchmark_results} || grep -q "improved" ${benchmark_results}); then
28+
echo "No performance regressions found." >> ${benchmark_results};
29+
fi

0 commit comments

Comments
 (0)