1
1
name : Trigger Jenkins Tests
2
2
on :
3
- pull_request :
4
- types : [opened, reopened, edited, synchronize ]
3
+ issue_comment :
4
+ types : [created ]
5
5
6
6
permissions :
7
7
pull-requests : write
8
+ statuses : write
9
+ actions : read
8
10
jobs :
11
+ read_codeowners :
12
+ name : Check Commenter
13
+ runs-on : generic-runner
14
+ if : ${{ contains(github.event.comment.body, '/run-gaudi-tests') && github.event.issue.pull_request }}
15
+ outputs :
16
+ pr_number : ${{ steps.extract_pr.outputs.pr_number }}
17
+ pr_branch : ${{ steps.extract_pr.outputs.pr_branch }}
18
+ pr_target_branch : ${{ steps.extract_pr.outputs.pr_target_branch }}
19
+ pr_sha : ${{ steps.extract_pr.outputs.pr_sha }}
20
+ steps :
21
+ - name : ' Checkout Repository'
22
+ uses : actions/checkout@v4
23
+ with :
24
+ ref : habana_main
25
+ fetch-depth : 0
26
+ token : ${{ secrets.GH_PAT }}
27
+ - name : Parse Comment
28
+ run : |
29
+ MAINTAINERS=$(grep -E '^[^#]' .github/CODEOWNERS | tr -d '@*')
30
+ COMMENTER=${{ github.event.comment.user.login }}
31
+ echo "Maintainers are: ${MAINTAINERS}"
32
+ echo "Commenter Is: ${COMMENTER}"
33
+ if ! echo "$MAINTAINERS" | grep -q "$COMMENTER"; then
34
+ echo "❌ User $COMMENTER is not authorized to trigger tests."
35
+ exit 1
36
+ fi
37
+ - name : Extract PR Number
38
+ id : extract_pr
39
+ run : |
40
+ PR_NUMBER="${{ github.event.issue.number }}"
41
+ echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
42
+ # It will work only on open PR's
43
+ random_string=$(tr -dc 'a-z0-9' </dev/urandom | head -c 10)
44
+ pr_temp_branch=$(echo "pr-${PR_NUMBER}-${random_string}")
45
+ git fetch origin pull/${PR_NUMBER}/merge
46
+ git checkout -b $pr_temp_branch FETCH_HEAD
47
+ git push origin $pr_temp_branch
48
+ echo "pr_branch=$pr_temp_branch" >> "$GITHUB_OUTPUT"
49
+ echo "Parsing The Base Branch"
50
+ target_branch=$(curl -sH "Authorization: token ${{ secrets.GH_PAT }}" https://api.github.com/repos/${{github.repository}}/pulls/${PR_NUMBER} | jq -r '.base.ref')
51
+ echo "pr_target_branch=$target_branch" >> "$GITHUB_OUTPUT"
52
+ pr_sha=$(curl -sH "Authorization: token ${{ secrets.GH_PAT }}" https://api.github.com/repos/${{github.repository}}/pulls/${PR_NUMBER} | jq -r '.head.sha')
53
+ echo "pr_sha=$pr_sha" >> $GITHUB_OUTPUT
9
54
DependencyReview :
10
55
name : Dependency Review
11
56
runs-on : ubuntu-latest
57
+ needs : [read_codeowners]
12
58
steps :
13
- - name : ' Checkout Repository'
59
+ - name : Checkout Repository
14
60
uses : actions/checkout@v4
61
+ with :
62
+ ref : ${{ needs.read_codeowners.outputs.pr_branch }}
63
+ token : ${{ secrets.GH_PAT }}
15
64
- name : ' Dependency Review'
16
65
uses : actions/dependency-review-action@v4
17
66
with :
18
67
fail-on-severity : high
19
68
CodeQLScan :
20
69
name : CodeQL Scan
21
70
runs-on : ubuntu-latest
71
+ needs : [read_codeowners]
22
72
steps :
23
- - name : Checkout repository
24
- uses : actions/checkout@v4
73
+ - name : Checkout Repository
74
+ uses : actions/checkout@v4
75
+ with :
76
+ ref : ${{ needs.read_codeowners.outputs.pr_branch }}
77
+ token : ${{ secrets.GH_PAT }}
25
78
- name : Initialize CodeQL
26
79
uses : github/codeql-action/init@v3
27
80
with :
@@ -35,12 +88,15 @@ jobs:
35
88
CalculateJobs :
36
89
runs-on : generic-runner
37
90
name : Calculate Tests To Trigger
38
- needs : [DependencyReview,CodeQLScan]
91
+ needs : [DependencyReview,CodeQLScan,read_codeowners ]
39
92
outputs :
40
93
tests_list : ${{ steps.tests.outputs.tests_list }}
41
94
steps :
42
- - name : Checkout
95
+ - name : Checkout Repository
43
96
uses : actions/checkout@v4
97
+ with :
98
+ ref : ${{ needs.read_codeowners.outputs.pr_branch }}
99
+ token : ${{ secrets.GH_PAT }}
44
100
- name : Install YQ
45
101
run : |
46
102
wget https://github.com/mikefarah/yq/releases/download/v4.14.1/yq_linux_amd64.tar.gz -O - |\
@@ -50,9 +106,10 @@ jobs:
50
106
run : |
51
107
test_list=$(yq -oj e .jenkins/test_config.yaml | jq -c "[.stages[].steps[]]")
52
108
echo "tests_list=${test_list}" >> "$GITHUB_OUTPUT"
109
+
53
110
TestRun :
54
111
name : Test / ${{matrix.tests.name}}
55
- needs : [CalculateJobs]
112
+ needs : [CalculateJobs,read_codeowners ]
56
113
runs-on : generic-runner
57
114
strategy :
58
115
fail-fast : false
@@ -64,6 +121,73 @@ jobs:
64
121
POD_TEMPLATE : ${{ secrets.POD_TEMPLATE }}
65
122
TEST_COMMAND : ${{ matrix.tests.command }}
66
123
steps :
124
+ - name : Get Job ID
125
+ uses : actions/github-script@v7
126
+ id : fetch_job_id
127
+ with :
128
+ script : |
129
+ async function getJobIdWithRetry(retries = 5, delay = 5000) {
130
+ const run_id = context.runId;
131
+ const matrix_test_name = process.env.MATRIX_TEST_NAME;
132
+
133
+ console.log(`Searching for job: Test / ${matrix_test_name} in run: ${run_id}`);
134
+
135
+ for (let i = 0; i < retries; i++) {
136
+ console.log(`Attempt ${i + 1}...`);
137
+
138
+ const response = await github.rest.actions.listJobsForWorkflowRun({
139
+ owner: context.repo.owner,
140
+ repo: context.repo.repo,
141
+ run_id: run_id
142
+ });
143
+
144
+ console.log("All Jobs:", response.data.jobs.map(j => j.name));
145
+
146
+ // Match job with correct naming convention
147
+ const job = response.data.jobs.find(j =>
148
+ j.name.trim() === `Test / ${matrix_test_name}`
149
+ );
150
+
151
+ if (job) {
152
+ console.log(`Found Job ID: ${job.id}`);
153
+ return job.id;
154
+ }
155
+
156
+ console.log(`Job not found, retrying in ${delay / 1000} seconds...`);
157
+ await new Promise(res => setTimeout(res, delay));
158
+ }
159
+
160
+ throw new Error(`Job ID not found after ${retries} attempts`);
161
+ }
162
+
163
+ const job_id = await getJobIdWithRetry();
164
+ core.setOutput("job_id", job_id);
165
+ env :
166
+ MATRIX_TEST_NAME : ${{ matrix.tests.name }}
167
+ - name : Get Job URL
168
+ id : job_url
169
+ run : |
170
+ url=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ steps.fetch_job_id.outputs.job_id }}")
171
+ echo "url=$url" >> $GITHUB_OUTPUT
172
+
173
+ - name : Create Commit Status(Pending)
174
+ uses : actions/github-script@v7
175
+ env :
176
+ GIT_SHA : ${{ needs.read_codeowners.outputs.pr_sha }}
177
+ TARGET_URL : ${{ steps.job_url.outputs.url }}
178
+ JOB_NAME : ${{matrix.tests.name}}
179
+ with :
180
+ script : |
181
+ await github.rest.repos.createCommitStatus({
182
+ owner: context.repo.owner,
183
+ repo: context.repo.repo,
184
+ sha: process.env.GIT_SHA,
185
+ state: 'pending',
186
+ description: `Running ${process.env.JOB_NAME}`,
187
+ target_url: process.env.TARGET_URL,
188
+ context: `Test / ${process.env.JOB_NAME}`
189
+ });
190
+
67
191
- name : Download Hlctl
68
192
run : |
69
193
curl --show-error --silent ${{ secrets.HLCTL_ADDRESS }} | bash &> /dev/null
72
196
${{ secrets.HLCTL_COMMAND }} &> /dev/null
73
197
- name : Create Pod Template
74
198
env :
75
- TARGET_BRANCH : ${{ github.base_ref }}
199
+ TARGET_BRANCH : ${{ needs.read_codeowners.outputs.pr_target_branch }}
76
200
RELEASED_SYNAPSE_VERSION : ${{ vars.RELEASED_SYNAPSE_VERSION }}
77
- BASE_BRANCH : ${{github.head_ref }}
201
+ BASE_BRANCH : ${{ needs.read_codeowners.outputs.pr_branch }}
78
202
run : |
79
203
if [[ $TARGET_BRANCH == "habana_main" ]]; then
80
204
synapse_version=${RELEASED_SYNAPSE_VERSION#v}
@@ -99,14 +223,101 @@ jobs:
99
223
echo "Pod Template Created"
100
224
- name : Run Test
101
225
run : |
102
- converted_test_name=$(echo ${{ matrix.tests.name }} | tr "_" "-")
103
- if [[ ${#converted_test_name} -ge 33 ]];then
104
- converted_test_name=${converted_test_name:12}
105
- fi
226
+ random_string=$(tr -dc 'a-z0-9' </dev/urandom | head -c 10)
106
227
hlctl create containers \
107
228
--file=pod.yml \
108
229
--flavor=${{ matrix.tests.flavor}} \
109
- --name="vllm-fork-${{github.event.number}}-${converted_test_name }" \
230
+ --name="vllm-fork-${{github.event.issue. number}}-${random_string }" \
110
231
--namespace="framework" \
111
232
--retry \
112
- --shm=10240
233
+ --shm=10240
234
+ - name : Create Commit Status(Failure)
235
+ uses : actions/github-script@v7
236
+ if : failure()
237
+ env :
238
+ GIT_SHA : ${{ needs.read_codeowners.outputs.pr_sha }}
239
+ TARGET_URL : ${{ steps.job_url.outputs.url }}
240
+ JOB_NAME : ${{matrix.tests.name}}
241
+ with :
242
+ script : |
243
+ await github.rest.repos.createCommitStatus({
244
+ owner: context.repo.owner,
245
+ repo: context.repo.repo,
246
+ sha: process.env.GIT_SHA,
247
+ state: 'failure',
248
+ description: `${process.env.JOB_NAME} Test Failed!`,
249
+ target_url: process.env.TARGET_URL,
250
+ context: `Test / ${process.env.JOB_NAME}`
251
+ });
252
+ - name : Create Commit Status(Success)
253
+ uses : actions/github-script@v7
254
+ if : success()
255
+ env :
256
+ GIT_SHA : ${{ needs.read_codeowners.outputs.pr_sha }}
257
+ TARGET_URL : ${{ steps.job_url.outputs.url }}
258
+ JOB_NAME : ${{matrix.tests.name}}
259
+ with :
260
+ script : |
261
+ await github.rest.repos.createCommitStatus({
262
+ owner: context.repo.owner,
263
+ repo: context.repo.repo,
264
+ sha: process.env.GIT_SHA,
265
+ state: 'success',
266
+ description: `${process.env.JOB_NAME} Test Has Finished Successfully`,
267
+ target_url: process.env.TARGET_URL,
268
+ context: `Test / ${process.env.JOB_NAME}`
269
+ });
270
+ Summarize :
271
+ name : Summarize Test Results
272
+ runs-on : generic-runner
273
+ needs : [TestRun,read_codeowners]
274
+ if : always()
275
+ steps :
276
+ - name : Checkout Repository
277
+ uses : actions/checkout@v4
278
+ with :
279
+ fetch-depth : 0
280
+ token : ${{ secrets.GH_PAT }}
281
+ - name : Delete Temp Branch
282
+ run : |
283
+ git push origin --delete ${{ needs.read_codeowners.outputs.pr_branch }}
284
+ - name : Check Test Results
285
+ run : |
286
+ test_result="${{ needs.TestRun.result }}"
287
+ echo "Test Finished with status ${test_result}"
288
+ if [[ "${test_result}" != "success" ]]; then
289
+ exit 1
290
+ fi
291
+ - name : Create Commit Status(Success)
292
+ uses : actions/github-script@v7
293
+ if : success()
294
+ env :
295
+ GIT_SHA : ${{ needs.read_codeowners.outputs.pr_sha }}
296
+ with :
297
+ script : |
298
+ await github.rest.repos.createCommitStatus({
299
+ owner: context.repo.owner,
300
+ repo: context.repo.repo,
301
+ sha: process.env.GIT_SHA,
302
+ state: 'success',
303
+ description: 'All Tests Passed Successfully!',
304
+ context: 'Summarize Test Results'
305
+ });
306
+ - name : Create Commit Status(Failure)
307
+ uses : actions/github-script@v7
308
+ if : failure()
309
+ env :
310
+ GIT_SHA : ${{ needs.read_codeowners.outputs.pr_sha }}
311
+ with :
312
+ script : |
313
+ await github.rest.repos.createCommitStatus({
314
+ owner: context.repo.owner,
315
+ repo: context.repo.repo,
316
+ sha: process.env.GIT_SHA,
317
+ state: 'failure',
318
+ description: 'Test Failure! Check Jobs To See Why',
319
+ context: 'Summarize Test Results'
320
+ });
321
+
322
+
323
+
0 commit comments