Skip to content

Commit fd40c51

Browse files
Add ciflow/rocm label only for non-pytorch/pytorch PRs (#7801)
* Since we added [ROCm testing to trunk.yml in pytorch/pytorch](pytorch/pytorch#170294), we get ROCm testing for `default` and `distributed` config in trunk.yml, hence no need to automatically add `ciflow/rocm-mi300` or `ciflow/rocm-mi355`. Users can still add these labels manually if they want continuous ROCm testing on their pytorch/pytorch PR. That being said, this same logic is useful on ecosystem repos to trigger ROCm CI via the `ciflow/rocm` label if any PR mentions ROCm. Hence limit the autolabeling to any non-pytorch/pytorch repos. * Also, update the ROCm regex pattern to avoid PRs such as [this](meta-pytorch/monarch#3467) resulting in a `ciflow/rocm` label being applied ### Test plan: Added a new test to check that `ciflow/rocm` label is added for a non-pytorch/pytorch repo: https://github.com/pytorch/test-infra/pull/7801/changes#diff-ed658674d71aaaa8b69a1f1e50e3c5caac25b56874edf448de868bc0918e31d0R138 Job: https://github.com/pytorch/test-infra/actions/runs/24690936818/job/72212348607?pr=7801 ``` INFO (event): id: "2" labels: [] title: "Issue regarding ROCm" filesChanged: [] INFO (event): loadConfig id: "2" key: "zhouzhuojie/gha-ci-playground" INFO (event): Adding label(s) module: rocm,ciflow/rocm to pull request zhouzhuojie/gha-ci-playground#31 id: "2" ```
1 parent a4783dd commit fd40c51

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

torchci/lib/bot/autoLabelBot.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const IssueAndPRRegexToLabel: [RegExp, string][] = [
2323
const PrTitleRegexToLabel: [RegExp, string][] = [
2424
[/reland/gi, "ci-no-td"],
2525
[/revert/gi, "ci-no-td"],
26-
[/rocm/gi, "ciflow/rocm-mi300"],
2726
...IssueAndPRRegexToLabel,
2827
];
2928

@@ -492,6 +491,11 @@ function myBot(app: Probot): void {
492491
context.log({ labels, title, filesChanged });
493492

494493
var labelsToAdd = getLabelsToAddFromPrTitle(title);
494+
// Apply ciflow/rocm label on non-pytorch/pytorch PRs to trigger ROCm CI
495+
// pytorch/pytorch PRs already run ROCm CI as part of trunk workflow
496+
if (!isPyTorchPyTorch(owner, repo) && title.match(/\brocm\b/gi)) {
497+
labelsToAdd.push("ciflow/rocm");
498+
}
495499

496500
// only categorize for release notes for prs in pytorch/pytorch
497501
if (isPyTorchPyTorch(owner, repo)) {

torchci/test/autoLabelBot.test.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe("auto-label-bot", () => {
118118
.reply(200)
119119
.post("/repos/zhouzhuojie/gha-ci-playground/issues/31/labels", (body) => {
120120
expect(body).toMatchObject({
121-
labels: ["ciflow/rocm-mi300", "module: rocm"],
121+
labels: ["module: rocm"],
122122
});
123123
return true;
124124
})
@@ -135,6 +135,48 @@ describe("auto-label-bot", () => {
135135
handleScope(checkLabelsScope);
136136
});
137137

138+
test("add ciflow/rocm label when non pytorch/pytorch PR title contains ROCm", async () => {
139+
// Reset mock to return false for isPyTorchPyTorch
140+
jest.restoreAllMocks();
141+
const mock = jest.spyOn(botUtils, "isPyTorchPyTorch");
142+
mock.mockReturnValue(false);
143+
const mockbotSupportedOrg = jest.spyOn(
144+
botUtils,
145+
"isPyTorchbotSupportedOrg"
146+
);
147+
mockbotSupportedOrg.mockReturnValue(true);
148+
149+
nock("https://api.github.com")
150+
.post("/app/installations/2/access_tokens")
151+
.reply(200, { token: "test" });
152+
153+
const payload = requireDeepCopy("./fixtures/pull_request.opened")[
154+
"payload"
155+
];
156+
payload["pull_request"]["title"] = "Issue regarding ROCm";
157+
payload["pull_request"]["labels"] = [];
158+
159+
const scope = nock("https://api.github.com")
160+
.get("/repos/zhouzhuojie/gha-ci-playground/pulls/31/files?per_page=100")
161+
.reply(200)
162+
.post("/repos/zhouzhuojie/gha-ci-playground/issues/31/labels", (body) => {
163+
expect(body).toMatchObject({
164+
labels: ["module: rocm", "ciflow/rocm"],
165+
});
166+
return true;
167+
})
168+
.reply(200);
169+
// Check-labels will post a comment since rocm labels are not required labels
170+
const checkLabelsScope = mockCheckLabelsComment(
171+
"zhouzhuojie/gha-ci-playground",
172+
31
173+
);
174+
175+
await probot.receive({ name: "pull_request", payload: payload, id: "2" });
176+
177+
scope.done();
178+
});
179+
138180
test("add ci-no-td label when PR title contains Reland", async () => {
139181
nock("https://api.github.com")
140182
.post("/app/installations/2/access_tokens")

0 commit comments

Comments
 (0)