@@ -33,12 +33,27 @@ concurrency:
3333 cancel-in-progress : true
3434
3535jobs :
36- # Gate: only run for `issue_comment` events when the comment is on a PR,
37- # starts with `/benchmark`, is not from a bot, and the commenter is a
38- # repo OWNER/MEMBER/COLLABORATOR. For schedule and workflow_dispatch this
39- # job is skipped and the benchmark job runs unconditionally.
36+ # Gate for `issue_comment` events. The job is *skipped* (not failed) for
37+ # anything that isn't a real `/benchmark` request — bot comments,
38+ # comments on plain issues, and comments that don't start with the
39+ # slash-command. This is what keeps unrelated activity (SonarQube
40+ # quality-gate replies, etc.) from littering the Actions tab with red
41+ # failed runs.
42+ #
43+ # Only an actual `/benchmark` attempt by someone without write access
44+ # makes the job run and fail loudly (with a -1 reaction on the
45+ # comment) — that's intentional feedback for an unauthorized trigger.
46+ #
47+ # For `schedule` and `workflow_dispatch` events the job-level `if` is
48+ # false → trigger-check is skipped → the `jmh` job's `if` allows it
49+ # to run.
4050 trigger-check :
41- if : github.event_name == 'issue_comment'
51+ if : |
52+ github.event_name == 'issue_comment' &&
53+ github.event.issue.pull_request != null &&
54+ github.event.sender.type != 'Bot' &&
55+ github.event.comment.user.type != 'Bot' &&
56+ startsWith(github.event.comment.body, '/benchmark')
4257 name : " Check /benchmark trigger"
4358 runs-on : ubuntu-latest
4459 permissions :
@@ -48,31 +63,20 @@ jobs:
4863 pr_number : ${{ steps.resolve.outputs.pr_number }}
4964 threshold : ${{ steps.resolve.outputs.threshold }}
5065 steps :
51- - name : Validate comment
52- id : validate
53- if : |
54- github.event.issue.pull_request != null &&
55- github.event.sender.type != 'Bot' &&
56- startsWith(github.event.comment.body, '/benchmark') &&
57- contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
58- run : echo "ok=true" >> $GITHUB_OUTPUT
59- # Note: we deliberately use `startsWith` (not `contains`) so the
60- # instruction comment posted by the PR-open bot, which mentions
61- # `/benchmark` mid-sentence, does not re-trigger this workflow.
66+ - name : Check commenter is a collaborator
67+ id : auth
68+ if : contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
69+ run : echo "ok=true" >> "$GITHUB_OUTPUT"
6270
6371 - name : Reject unauthorized trigger
64- if : steps.validate .outputs.ok != 'true'
72+ if : steps.auth .outputs.ok != 'true'
6573 env :
6674 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6775 run : |
68- # If it looks like a /benchmark attempt by someone without
69- # permission, leave a -1 reaction so they get feedback.
70- if [[ "${{ github.event.issue.pull_request != null }}" == "true" ]] \
71- && [[ "${{ startsWith(github.event.comment.body, '/benchmark') }}" == "true" ]]; then
72- gh api -X POST \
73- "repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
74- -f content='-1' || true
75- fi
76+ gh api -X POST \
77+ "repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
78+ -f content='-1' || true
79+ echo "::error::User ${{ github.event.comment.user.login }} (author_association=${{ github.event.comment.author_association }}) is not allowed to run /benchmark."
7680 exit 1
7781
7882 - name : Acknowledge trigger
@@ -98,10 +102,19 @@ jobs:
98102
99103 jmh :
100104 needs : [trigger-check]
105+ # For `issue_comment` we require trigger-check to have *succeeded*
106+ # (a real `/benchmark` from a collaborator). For every other event
107+ # (`schedule`, `workflow_dispatch`) the trigger-check job is
108+ # filtered out by its job-level `if`, so we require `skipped`.
109+ # Without this split, bot comments that skip trigger-check would
110+ # erroneously satisfy the `success || skipped` fan-in.
101111 if : |
102112 always() &&
103113 startsWith(github.repository, 'ClickHouse/') &&
104- (needs.trigger-check.result == 'success' || needs.trigger-check.result == 'skipped')
114+ (
115+ (github.event_name == 'issue_comment' && needs.trigger-check.result == 'success') ||
116+ (github.event_name != 'issue_comment' && needs.trigger-check.result == 'skipped')
117+ )
105118 name : " Mininal JMH Benchmarks"
106119 runs-on : " ubuntu-latest"
107120 timeout-minutes : 30
0 commit comments