@@ -2,20 +2,47 @@ name: Benchmark a pull request
2
2
3
3
on :
4
4
pull_request :
5
+ types : [opened, synchronize, edited] # Triggers on PR updates
5
6
6
7
concurrency :
7
- # Skip intermediate builds: always.
8
8
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
10
10
11
11
permissions :
12
12
pull-requests : write
13
13
actions : write
14
14
contents : read
15
15
16
16
jobs :
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
+
17
43
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
19
46
runs-on : ubuntu-latest
20
47
steps :
21
48
- uses : actions/checkout@v4
@@ -30,12 +57,15 @@ jobs:
30
57
working-directory : benchmark
31
58
run : |
32
59
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
34
62
echo '' >> body.md
35
63
echo '```' >> body.md
36
64
cat comparison.txt >> body.md
37
65
echo '```' >> body.md
38
66
echo '' >> body.md
67
+ echo '</details>' >> body.md
68
+ echo '' >> body.md
39
69
- name : Upload plot
40
70
uses : actions/upload-artifact@v4
41
71
id : artifact-upload-step
0 commit comments