Skip to content

Commit cb67b0e

Browse files
committed
more elaborate no-benchmark check in benchmark action
1 parent 141843a commit cb67b0e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/benchmark.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,33 @@ permissions:
1414
contents: read
1515

1616
jobs:
17+
check_skip: # check for "[no benchmark]" in pr body
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=$(gh pr view ${{ github.event.pull_request.number }} --json body,title -q '{body: .body, title: .title}')
26+
echo "PR_TITLE=$(echo $PR_DATA | jq -r '.title')" >> $GITHUB_ENV
27+
echo "PR_BODY=$(echo $PR_DATA | jq -r '.body')" >> $GITHUB_ENV
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Check for '[no benchmark]'
31+
id: check
32+
run: |
33+
if [[ "$PR_TITLE" == *"[no benchmark]"* || "$PR_BODY" == *"[no benchmark]"* ]]; then
34+
echo "Benchmarks will be skipped."
35+
echo "skip_benchmark=true" >> $GITHUB_OUTPUT
36+
else
37+
echo "Benchmarks will run."
38+
echo "skip_benchmark=false" >> $GITHUB_OUTPUT
39+
fi
40+
1741
run_benchmarks:
18-
if: "!contains(github.event.pull_request.title, '[no benchmark]') && !contains(github.event.pull_request.body, '[no benchmark]')"
42+
needs: check_skip
43+
if: needs.check_skip.outputs.skip == 'false' # Skip the job if '[no benchmark]' is found
1944
runs-on: ubuntu-latest
2045
steps:
2146
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)