Skip to content

Commit b7d0323

Browse files
committed
update
1 parent 87ed433 commit b7d0323

7 files changed

Lines changed: 18 additions & 24 deletions

File tree

aws/lambda/cross_repo_ci_relay/callback/callback_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def _create_upstream_check_run(
234234
details_url=details_url,
235235
# Store the downstream run_id so a check-run rerequest can re-run
236236
# the failed jobs of that workflow run.
237-
external_id=str(run_id),
237+
external_id=f"{run_id}:{pr_number}" if pr_number else str(run_id),
238238
output=output,
239239
)
240240
logger.info(

aws/lambda/cross_repo_ci_relay/callback/cleanup_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _finalize_timed_out_check_run(
118118
status="completed",
119119
conclusion="timed_out",
120120
details_url=details_url,
121-
external_id=run_id,
121+
external_id=f"{run_id}:{pr_number}" if pr_number else run_id,
122122
output=output,
123123
)
124124
logger.info(

aws/lambda/cross_repo_ci_relay/tests/test_callback_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def test_check_run_external_id_is_run_id(self):
365365
)
366366

367367
kw = self.mock_gh.create_check_run.call_args[1]
368-
self.assertEqual(kw["external_id"], "99999") # run_id from _body
368+
self.assertEqual(kw["external_id"], "99999:42") # run_id:pr_number
369369

370370
def test_in_progress_callback_creates_check_run(self):
371371
self.mock_gh.create_check_run.return_value = 999

aws/lambda/cross_repo_ci_relay/tests/test_event_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def test_scenario2_in_progress_job_creates_in_progress_check_run(self):
191191
self.assertEqual(kw["head_sha"], "abc123")
192192
self.assertEqual(kw["status"], "in_progress")
193193
self.assertIsNone(kw["conclusion"])
194-
self.assertEqual(kw["external_id"], "99999") # run_id
194+
self.assertEqual(kw["external_id"], "99999:42") # run_id:pr_number
195195

196196
def test_scenario2_backfills_every_job_not_just_one(self):
197197
"""Multi-job workflow: a mid-run label backfills a check run for EVERY
@@ -215,7 +215,7 @@ def test_scenario2_backfills_every_job_not_just_one(self):
215215
c.kwargs["external_id"]
216216
for c in self.mock_gh.create_check_run.call_args_list
217217
}
218-
self.assertEqual(external_ids, {"99999"}) # run_id
218+
self.assertEqual(external_ids, {"99999:42"}) # run_id:pr_number
219219

220220
def test_scenario3_completed_job_creates_completed_check_run(self):
221221
"""Scenario 3: label arrives after workflow completed → create completed CR directly."""

aws/lambda/cross_repo_ci_relay/webhook/event_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _handle_pr_labeled(config: RelayConfig, payload: dict) -> dict:
205205
status=job_status,
206206
conclusion=(job_conclusion if job_status == "completed" else None),
207207
details_url=details_url,
208-
external_id=str(run_id),
208+
external_id=f"{run_id}:{pr_number}" if pr_number else str(run_id),
209209
output=gh_helper.build_check_run_output(
210210
job_status,
211211
job_conclusion,
@@ -267,7 +267,7 @@ def _handle_check_run_rerequested(config: RelayConfig, payload: dict) -> dict:
267267
"""
268268
check_run = payload.get("check_run") or {}
269269
name = check_run.get("name", "")
270-
run_id = check_run.get("external_id") or ""
270+
run_id = (check_run.get("external_id") or "").split(":")[0]
271271
downstream_repo = _downstream_repo_from_check_run(name)
272272
if not downstream_repo or not run_id:
273273
return {"ignored": True, "reason": "not a crcr check run"}
@@ -350,7 +350,7 @@ def _handle_check_suite_rerequested(config: RelayConfig, payload: dict) -> dict:
350350
rerun: list[str] = []
351351
for check_run in check_runs:
352352
downstream_repo = _downstream_repo_from_check_run(check_run.get("name", ""))
353-
run_id = check_run.get("external_id") or ""
353+
run_id = (check_run.get("external_id") or "").split(":")[0]
354354
if not downstream_repo or not run_id:
355355
continue
356356
if (downstream_repo, run_id) in seen:

torchci/lib/bot/crcrOncallBot.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ export default function crcrOncallBot(app: Probot): void {
8383
let prNumbers: number[] = [];
8484
if (checkRun.pull_requests && checkRun.pull_requests.length > 0) {
8585
prNumbers = checkRun.pull_requests.map((pr) => pr.number);
86-
} else if (checkRun.output?.summary) {
87-
const match = checkRun.output.summary.match(/for PR (\d+)/);
88-
if (match) {
89-
prNumbers = [parseInt(match[1], 10)];
86+
} else if (checkRun.external_id) {
87+
const parts = checkRun.external_id.split(":");
88+
if (parts.length === 2 && parts[1]) {
89+
prNumbers = [parseInt(parts[1], 10)];
9090
}
9191
}
9292

torchci/test/crcrOncallBot.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,20 @@ L3:
176176
});
177177
});
178178

179-
test("does not comment when output has no PR number", async () => {
180-
// output.summary exists but regex doesn't match (no PR number
181-
// after "for PR"), so the bot returns early without any API call.
179+
test("does not comment when external_id has no PR number", async () => {
180+
// external_id carries bare run_id (no ":" separator) when pr_number
181+
// is unavailable — the bot returns early without any API call.
182182
await probot.receive({
183183
name: "check_run" as any,
184184
payload: checkRunPayload({
185185
pull_requests: [],
186-
output: {
187-
title: "In progress",
188-
summary: "intel/torch-xpu-ops workflow for PR : https://example.com",
189-
},
186+
external_id: "12345",
190187
}) as any,
191188
id: "8",
192189
});
193190
});
194191

195-
test("posts comment when output contains PR number for cross-fork PR", async () => {
192+
test("posts comment when external_id contains PR number for cross-fork PR", async () => {
196193
const scope = nock("https://api.github.com")
197194
.get(`/repos/${OWNER}/${REPO}/issues/${PR_NUMBER}/comments`)
198195
.reply(200, [])
@@ -212,10 +209,7 @@ L3:
212209
name: "check_run" as any,
213210
payload: checkRunPayload({
214211
pull_requests: [], // empty — simulates cross-fork PR
215-
output: {
216-
title: "Failure",
217-
summary: `intel/torch-xpu-ops workflow for PR ${PR_NUMBER}: https://example.com`,
218-
},
212+
external_id: `12345:${PR_NUMBER}`,
219213
}) as any,
220214
id: "10",
221215
});

0 commit comments

Comments
 (0)