Skip to content

Commit 0db5440

Browse files
authored
Add back check (#572)
* add release date * update testing * add back check * update checks * update dispatch * add fix
1 parent 81eccc2 commit 0db5440

2 files changed

Lines changed: 150 additions & 6 deletions

File tree

.github/workflows/docker.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ jobs:
3333
if: >-
3434
github.event_name != 'issue_comment' ||
3535
(github.event.issue.pull_request && startsWith(github.event.comment.body, '/test-docker'))
36+
outputs:
37+
head-sha: ${{ steps.get-sha.outputs.sha }}
3638
permissions:
3739
pull-requests: write
40+
statuses: write
3841
steps:
3942
- name: Check permissions
4043
if: github.event_name == 'issue_comment' || github.event_name == 'workflow_dispatch'
@@ -54,6 +57,26 @@ jobs:
5457
env:
5558
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5659

60+
- name: Get PR head SHA
61+
id: get-sha
62+
if: github.event_name == 'issue_comment'
63+
run: |
64+
SHA=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefOid -q .headRefOid)
65+
echo "sha=$SHA" >> $GITHUB_OUTPUT
66+
env:
67+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Set pending status on PR
70+
if: github.event_name == 'issue_comment'
71+
run: |
72+
gh api repos/${{ github.repository }}/statuses/${{ steps.get-sha.outputs.sha }} \
73+
-f state=pending \
74+
-f context="Docker Build" \
75+
-f description="Docker build running..." \
76+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
77+
env:
78+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
5780
build_docker_images:
5881
needs: check
5982
strategy:
@@ -67,6 +90,7 @@ jobs:
6790
packages: write
6891
contents: read
6992
attestations: write
93+
statuses: write
7094
steps:
7195
- name: Free disk space
7296
run: |
@@ -155,3 +179,25 @@ jobs:
155179
run: |
156180
docker image ls -a
157181
shell: bash
182+
183+
- name: Set success status on PR
184+
if: success() && github.event_name == 'issue_comment'
185+
run: |
186+
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
187+
-f state=success \
188+
-f context="Docker Build" \
189+
-f description="Docker build passed" \
190+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
191+
env:
192+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
193+
194+
- name: Set failure status on PR
195+
if: failure() && github.event_name == 'issue_comment'
196+
run: |
197+
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
198+
-f state=failure \
199+
-f context="Docker Build" \
200+
-f description="Docker build failed" \
201+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
202+
env:
203+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-gpu.yml

Lines changed: 104 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,47 @@ on:
66
types: [created]
77
push:
88
branches: [main]
9+
pull_request:
10+
types:
11+
- opened
12+
- synchronize
913
# Cancel the job if new commits are pushed
1014
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre
1115
concurrency:
12-
group: ${{ github.workflow }}-${{ github.event.issue.number || github.ref }}
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }}
1317
cancel-in-progress: true
1418
jobs:
19+
set-pending:
20+
name: GPU Tests Pending
21+
if: github.event_name == 'pull_request'
22+
runs-on: ubuntu-latest
23+
permissions:
24+
statuses: write
25+
steps:
26+
- name: Set pending status on PR
27+
run: |
28+
for context in "CI-Pass" "All Tests Green"; do
29+
gh api repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
30+
-f state=pending \
31+
-f context="$context" \
32+
-f description="Waiting for /test-gpu command..."
33+
done
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
1537
check:
1638
runs-on: ubuntu-latest
17-
# Skip issue_comment unless it's /test-gpu on a PR
39+
# Skip pull_request (handled by set-pending) and issue_comment unless /test-gpu
1840
if: >-
19-
github.event_name != 'issue_comment' ||
20-
(github.event.issue.pull_request && startsWith(github.event.comment.body, '/test-gpu'))
41+
github.event_name != 'pull_request' && (
42+
github.event_name != 'issue_comment' ||
43+
(github.event.issue.pull_request && startsWith(github.event.comment.body, '/test-gpu'))
44+
)
45+
outputs:
46+
head-sha: ${{ steps.get-sha.outputs.sha }}
2147
permissions:
2248
pull-requests: write
49+
statuses: write
2350
steps:
2451
- name: Check permissions
2552
if: github.event_name == 'issue_comment' || github.event_name == 'workflow_dispatch'
@@ -39,6 +66,27 @@ jobs:
3966
env:
4067
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4168

69+
- name: Get PR head SHA
70+
id: get-sha
71+
if: github.event_name == 'issue_comment'
72+
run: |
73+
SHA=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefOid -q .headRefOid)
74+
echo "sha=$SHA" >> $GITHUB_OUTPUT
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Set pending status on PR
79+
if: github.event_name == 'issue_comment'
80+
run: |
81+
for context in "CI-Pass" "All Tests Green"; do
82+
gh api repos/${{ github.repository }}/statuses/${{ steps.get-sha.outputs.sha }} \
83+
-f state=pending \
84+
-f context="$context" \
85+
-f description="GPU tests running..." \
86+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
87+
done
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4290

4391
get-envs:
4492
runs-on: ubuntu-latest
@@ -170,26 +218,76 @@ jobs:
170218

171219
stable-dev-green:
172220
name: CI-Pass
173-
if: always()
221+
if: always() && github.event_name != 'pull_request'
174222
needs:
223+
- check
175224
- get-envs
176225
- test-stable-dev
177226
runs-on: ubuntu-latest
227+
permissions:
228+
statuses: write
178229
steps:
179230
- uses: re-actors/alls-green@release/v1
180231
with:
181232
jobs: ${{ toJSON(needs) }}
182233

234+
- name: Set success status on PR
235+
if: success() && github.event_name == 'issue_comment'
236+
run: |
237+
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
238+
-f state=success \
239+
-f context="CI-Pass" \
240+
-f description="GPU tests passed" \
241+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
242+
env:
243+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244+
245+
- name: Set failure status on PR
246+
if: failure() && github.event_name == 'issue_comment'
247+
run: |
248+
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
249+
-f state=failure \
250+
-f context="CI-Pass" \
251+
-f description="GPU tests failed" \
252+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
253+
env:
254+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
255+
183256
all-green:
184257
name: All Tests Green
185-
if: always()
258+
if: always() && github.event_name != 'pull_request'
186259
needs:
260+
- check
187261
- get-envs
188262
- test-stable-dev
189263
- test-prerelease
190264
runs-on: ubuntu-latest
265+
permissions:
266+
statuses: write
191267
steps:
192268
- uses: re-actors/alls-green@release/v1
193269
with:
194270
allowed-failures: test-prerelease
195271
jobs: ${{ toJSON(needs) }}
272+
273+
- name: Set success status on PR
274+
if: success() && github.event_name == 'issue_comment'
275+
run: |
276+
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
277+
-f state=success \
278+
-f context="All Tests Green" \
279+
-f description="All GPU tests passed" \
280+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
281+
env:
282+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
283+
284+
- name: Set failure status on PR
285+
if: failure() && github.event_name == 'issue_comment'
286+
run: |
287+
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
288+
-f state=failure \
289+
-f context="All Tests Green" \
290+
-f description="GPU tests failed" \
291+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
292+
env:
293+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)