11name : GPU Tests
22
33on :
4+ workflow_dispatch :
5+ issue_comment :
6+ types : [created]
47 push :
58 branches : [main]
6- pull_request :
7- types :
8- - labeled
9- - opened
10- - synchronize
119# Cancel the job if new commits are pushed
1210# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre
1311concurrency :
14- group : ${{ github.workflow }}-${{ github.event.pull_request .number || github.ref }}
12+ group : ${{ github.workflow }}-${{ github.event.issue .number || github.ref }}
1513 cancel-in-progress : true
1614jobs :
1715 check :
1816 runs-on : ubuntu-latest
17+ # Skip issue_comment unless it's /test-gpu on a PR
18+ if : >-
19+ github.event_name != 'issue_comment' ||
20+ (github.event.issue.pull_request && startsWith(github.event.comment.body, '/test-gpu'))
21+ permissions :
22+ pull-requests : write
1923 steps :
20- - uses : flying-sheep/check@v1
21- with :
22- success : ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'run-gpu-ci') }}
24+ - name : Check permissions
25+ if : github.event_name == 'issue_comment' || github.event_name == 'workflow_dispatch'
26+ run : |
27+ PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission --jq '.permission')
28+ if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" ]]; then
29+ echo "::error::Only maintainers or admins can trigger this workflow. Your permission: $PERMISSION"
30+ exit 1
31+ fi
32+ env :
33+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
34+
35+ - name : React to comment
36+ if : github.event_name == 'issue_comment'
37+ run : |
38+ gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content=rocket
39+ env :
40+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41+
2342
2443 get-envs :
2544 runs-on : ubuntu-latest
3251 with :
3352 filter : blob:none
3453 fetch-depth : 0
54+ ref : ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
3555 - uses : astral-sh/setup-uv@v6
3656 with :
3757 enable-cache : false
7898 with :
7999 fetch-depth : 0
80100 filter : blob:none
101+ ref : ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
81102
82103 - uses : astral-sh/setup-uv@v6
83104 with :
@@ -135,6 +156,7 @@ jobs:
135156 with :
136157 fetch-depth : 0
137158 filter : blob:none
159+ ref : ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
138160
139161 - uses : astral-sh/setup-uv@v6
140162 with :
@@ -146,16 +168,6 @@ jobs:
146168 - name : Run tests
147169 run : uvx hatch run ${{ matrix.env.name }}:run -v --color=yes
148170
149- remove-label :
150- name : Remove 'run-gpu-ci' Label
151- runs-on : ubuntu-latest
152- if : ${{ always() && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-gpu-ci') }}
153- steps :
154- - uses : actions-ecosystem/action-remove-labels@v1
155- with :
156- labels : ' run-gpu-ci'
157- github_token : ${{ secrets.GITHUB_TOKEN }}
158-
159171 stable-dev-green :
160172 name : CI-Pass
161173 if : always()
0 commit comments