Skip to content

Commit

Permalink
fix label checker (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
AyodeAwe authored May 22, 2024
1 parent dfe0a9d commit 5649d62
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/plugins/LabelChecker/label_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { OpsBotPlugin } from "../../plugin";
import { createSetCommitStatus, isGPUTesterPR } from "../../shared";
import { createSetCommitStatus, isRapidsBotPR } from "../../shared";
import { PRContext } from "../../types";

export class LabelChecker extends OpsBotPlugin {
Expand Down Expand Up @@ -51,9 +51,9 @@ export class LabelChecker extends OpsBotPlugin {
await new Promise((res) => setTimeout(res, 2000));
}

if (isGPUTesterPR(context.payload.pull_request)) {
if (isRapidsBotPR(context.payload.pull_request)) {
return await setCommitStatus(
"No labels necessary for GPUTester PRs",
"No labels necessary for rapids-bot PRs",
"success"
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export const isGPUTesterPR = (
return pullRequest.user?.login.toLowerCase() === "gputester";
};

export const isRapidsBotPR = (
pullRequest: Pick<PullsGetResponseData, "user">
): boolean => {
return pullRequest.user?.login.toLowerCase() === "rapids-bot";
};

/**
* Returns true if the payload associated with the provided context
* is from a GitHub Pull Request (as opposed to a GitHub Issue).
Expand Down
6 changes: 3 additions & 3 deletions test/label_checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ describe("Label Checker", () => {
);
});

test("correct labels - GPUTester PR", async () => {
test("correct labels - rapids-bot PR", async () => {
const context = makePRContext({
title: "[gpuCI] Forward-merge branch-0.18 to branch-0.19 [skip ci]",
user: "GPUtester",
user: "rapids-bot",
});
await new LabelChecker(context).checkLabels();
expect(mockCreateCommitStatus).toBeCalledTimes(2);
Expand All @@ -232,7 +232,7 @@ describe("Label Checker", () => {
);
expect(mockCreateCommitStatus.mock.calls[1][0].state).toBe("success");
expect(mockCreateCommitStatus.mock.calls[1][0].description).toBe(
"No labels necessary for GPUTester PRs"
"No labels necessary for rapids-bot PRs"
);
expect(mockCreateCommitStatus.mock.calls[1][0].target_url).toBe(
"https://docs.rapids.ai/resources/label-checker/"
Expand Down

0 comments on commit 5649d62

Please sign in to comment.