Skip to content

Commit

Permalink
chore(ci): store PR info before checking threshold to avoid empty com…
Browse files Browse the repository at this point in the history
…ments.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed Jun 21, 2024
1 parent cfab3de commit 5902d14
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,54 +42,48 @@ jobs:
path: perf_*_diff.txt
if-no-files-found: error

# Check will fail if there is any function slowed down >=3% (relative).
# But we will always comment with the perf diff from master
- name: Check >= 3% threshold - unit tests
id: compare_tests
run: |
echo "diff=perf_tests_diff.txt" >> $GITHUB_OUTPUT
awk '{if (substr($2,RSTART+RLENGTH)+0 >= 3) print }' perf_tests_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
exit 1
fi
# Check will fail if there is any function slowed down >=10% (relative).
# Larger threshold since scap file perf seems much more unstable.
# But we will always comment with the perf diff from master
- name: Check >= 10% threshold - scap file
id: compare_scap
if: always() # Even if unit tests threshold check failed
run: |
echo "diff=perf_scap_diff.txt" >> $GITHUB_OUTPUT
awk '{if (substr($2,RSTART+RLENGTH)+0 >= 10) print }' perf_scap_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
exit 1
fi
- name: Save PR info
if: always()
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
touch ./pr/COMMENT
echo "# Perf diff from master - unit tests" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
head -n10 "${{ steps.compare_tests.outputs.diff }}" >> ./pr/COMMENT
head -n10 "perf_tests_diff.txt" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
echo "" >> ./pr/COMMENT
echo "# Perf diff from master - scap file" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
head -n10 "${{ steps.compare_scap.outputs.diff }}" >> ./pr/COMMENT
head -n10 "perf_scap_diff.txt" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
echo Uploading PR info...
cat ./pr/COMMENT
echo ""
- name: Upload PR info as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: pr
path: pr/
retention-days: 1
if-no-files-found: warn

# Check will fail if there is any function slowed down >=3% (relative).
# But we will always comment with the perf diff from master
- name: Check >= 3% threshold - unit tests
run: |
awk '{if (substr($2,RSTART+RLENGTH)+0 >= 3) print }' perf_tests_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
exit 1
fi
# Check will fail if there is any function slowed down >=10% (relative).
# Larger threshold since scap file perf seems much more unstable.
# But we will always comment with the perf diff from master
- name: Check >= 10% threshold - scap file
if: always() # Even if unit tests threshold check failed
run: |
awk '{if (substr($2,RSTART+RLENGTH)+0 >= 10) print }' perf_scap_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
exit 1
fi

0 comments on commit 5902d14

Please sign in to comment.