From bef6e5ec508afa1afccee80db060015c596dcbb4 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Tue, 18 Jun 2024 11:00:01 +0200 Subject: [PATCH] chore(ci): always create perf-related comment; fail perf CI when a slowdown >2% is caught. Signed-off-by: Federico Di Pierro --- .github/workflows/perf.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index 55ddc42c6d..9d2023a36e 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -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 @@ -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 @@ -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