Skip to content

Commit f37aad3

Browse files
fix(ci): update committer benchmark comment
1 parent 07c1313 commit f37aad3

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

.github/workflows/committer_ci.yml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,34 @@ jobs:
103103

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

106-
# Post comment in case of performance regression or improvement.
107-
- run: npm install fs
108-
- if: contains(env.BENCHES_RESULT, 'regressed') || contains(env.BENCHES_RESULT, 'improved')
109-
uses: actions/github-script@v6
106+
# Comment with a link to the workflow (or update existing comment on rerun).
107+
- name: Find Comment
108+
if: github.event_name == 'pull_request'
109+
uses: starkware-libs/find-comment@v3
110+
id: find-benchmark-comment
110111
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-
})
112+
token: ${{ secrets.GITHUB_TOKEN }}
113+
issue-number: ${{ github.event.pull_request.number }}
114+
comment-author: 'github-actions[bot]'
115+
body-includes: Benchmark movements
116+
117+
- name: Create comment
118+
# If the PR number is found and the comment is not found, create a new comment.
119+
if: github.event_name == 'pull_request'
120+
&& steps.find-benchmark-comment.outputs.comment-id == ''
121+
uses: starkware-libs/create-or-update-comment@v4
122+
with:
123+
token: ${{ secrets.GITHUB_TOKEN }}
124+
issue-number: ${{ github.event.pull_request.number }}
125+
body: ${{ env.BENCHES_RESULT }}
126+
127+
- name: Update comment
128+
# If the PR number is found and the comment exists, update it.
129+
if: github.event_name == 'pull_request'
130+
&& steps.find-benchmark-comment.outputs.comment-id != ''
131+
uses: starkware-libs/create-or-update-comment@v4
132+
with:
133+
token: ${{ secrets.GITHUB_TOKEN }}
134+
comment-id: ${{ steps.find-benchmark-comment.outputs.comment-id }}
135+
edit-mode: replace
136+
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 major performance changes detected." >> ${benchmark_results};
29+
fi

0 commit comments

Comments
 (0)