@@ -2,20 +2,47 @@ name: Benchmark a pull request
22
33on :
44 pull_request :
5+ types : [opened, synchronize, edited] # Triggers on PR updates
56
67concurrency :
7- # Skip intermediate builds: always.
88 group : ${{ github.workflow }}-${{ github.ref }}
9- cancel-in-progress : true # always cancel old runs on new push
9+ cancel-in-progress : true # Always cancel old runs on new pushes
1010
1111permissions :
1212 pull-requests : write
1313 actions : write
1414 contents : read
1515
1616jobs :
17+ check_skip :
18+ runs-on : ubuntu-latest
19+ outputs :
20+ skip : ${{ steps.check.outputs.skip_benchmark }}
21+ steps :
22+ - name : Fetch latest PR details
23+ id : fetch-pr
24+ run : |
25+ PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
26+ -H "Accept: application/vnd.github.v3+json" \
27+ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}")
28+ PR_TITLE=$(echo "$PR_DATA" | jq -r '.title')
29+ PR_BODY=$(echo "$PR_DATA" | jq -r '.body')
30+ echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
31+ echo "PR_BODY=$PR_BODY" >> $GITHUB_ENV
32+ - name : Check for '[no benchmark]'
33+ id : check
34+ run : |
35+ if [[ "$PR_TITLE" == *"[no benchmark]"* || "$PR_BODY" == *"[no benchmark]"* ]]; then
36+ echo "Benchmarks will be skipped."
37+ echo "skip_benchmark=true" >> $GITHUB_OUTPUT
38+ else
39+ echo "Benchmarks will run."
40+ echo "skip_benchmark=false" >> $GITHUB_OUTPUT
41+ fi
42+
1743 run_benchmarks :
18- if : " !contains(github.event.pull_request.title, '[no benchmark]') && !contains(github.event.pull_request.body, '[no benchmark]')"
44+ needs : check_skip
45+ if : needs.check_skip.outputs.skip == 'false' # Skip the job if '[no benchmark]' is found
1946 runs-on : ubuntu-latest
2047 steps :
2148 - uses : actions/checkout@v4
@@ -30,12 +57,15 @@ jobs:
3057 working-directory : benchmark
3158 run : |
3259 julia --color=yes ./run_benchmarks.jl -t ${{github.event.pull_request.head.ref}} -b ${{github.event.pull_request.base.ref}} --no-data-export --prefix ""
33- echo '### Benchmark Results' > body.md
60+ echo '<details>' > body.md
61+ echo '<summary>Benchmark Results</summary>' >> body.md
3462 echo '' >> body.md
3563 echo '```' >> body.md
3664 cat comparison.txt >> body.md
3765 echo '```' >> body.md
3866 echo '' >> body.md
67+ echo '</details>' >> body.md
68+ echo '' >> body.md
3969 - name : Upload plot
4070 uses : actions/upload-artifact@v4
4171 id : artifact-upload-step
0 commit comments