Skip to content

Commit

Permalink
chore(ci): always create perf-related comment; fail perf CI when a sl…
Browse files Browse the repository at this point in the history
…owdown >2% is caught.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Jun 18, 2024
1 parent 004c5f1 commit bef6e5e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: perf_report
retention-days: 14 # 14 days because this is the artifact on master; we need to retain it to be able to properly diff it
retention-days: 30 # 30 days because this is the artifact on master; we need to retain it to be able to properly diff it
path: build/perf.data
if-no-files-found: error

Expand All @@ -76,22 +76,25 @@ jobs:
path: perf_diff.txt
if-no-files-found: error

# Check will fail if there is any function slowed down >2%
# But we will always comment with the perf diff from master
- name: Check > 2% threshold
if: github.event_name == 'pull_request'
id: compare
run: |
echo "comment_file=perf_diff.txt" >> $GITHUB_OUTPUT
awk '{if (substr($2,RSTART+RLENGTH)+0 > 2) print }' perf_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
echo "comment_file=perf_diff_above_thresh.txt" >> $GITHUB_OUTPUT
exit 1
fi
- name: Save PR info
if: steps.compare.outputs.comment_file != ''
if: always() && github.event_name == 'pull_request'
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
touch ./pr/COMMENT
echo "# Perf diff from master above 2% slowdown threshold" >> ./pr/COMMENT
echo "# Perf diff from master" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
cat "${{ steps.compare.outputs.comment_file }}" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
Expand All @@ -100,7 +103,7 @@ jobs:
echo ""
- name: Upload PR info as artifact
if: steps.compare.outputs.comment_file != ''
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: pr
Expand Down

0 comments on commit bef6e5e

Please sign in to comment.