Skip to content

Commit

Permalink
Allow repo default branch to be non-versioned (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleFromNVIDIA authored Jan 12, 2024
1 parent 7c62237 commit d09a1b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/plugins/BranchChecker/check_pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ export const checkPR = async function (
pr: PRContext["payload"]["pull_request"] | PullsListResponseData[0]
) {
const prBaseBranch = pr.base.ref;
const repoDefaultBranchVersion = getVersionFromBranch(
pr.base.repo.default_branch
);
const errDescription = "Base branch is not under active development";
const setCommitStatus = createSetCommitStatus(context.octokit, {
context: "Branch Checker",
Expand All @@ -50,10 +47,20 @@ export const checkPR = async function (
return await setCommitStatus("Automated GPUTester PR detected", "success");
}

if (pr.base.repo.default_branch == prBaseBranch) {
return await setCommitStatus(
"Base branch is under active development",
"success"
);
}

if (!isVersionedBranch(prBaseBranch)) {
return await setCommitStatus(errDescription, "failure");
}

const repoDefaultBranchVersion = getVersionFromBranch(
pr.base.repo.default_branch
);
const prBaseBranchVersion = getVersionFromBranch(prBaseBranch);

if (await isActiveBranch(repoDefaultBranchVersion, prBaseBranchVersion)) {
Expand Down
14 changes: 14 additions & 0 deletions test/branch_checker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ describe("Branch Checker", () => {
"Base branch is not under active development"
);
});

test("non-versioned default branch", async() => {
const context = makePRContext({
baseRef: "non-versioned-branch",
baseDefaultBranch: "non-versioned-branch",
});
await new PRBranchChecker(context).checkPR();
expect(mockCreateCommitStatus).toBeCalledTimes(2);
expect(mockCreateCommitStatus.mock.calls[0][0].state).toBe("pending");
expect(mockCreateCommitStatus.mock.calls[1][0].state).toBe("success");
expect(mockCreateCommitStatus.mock.calls[1][0].description).toBe(
"Base branch is under active development"
);
});
});

describe("Repository Event", () => {
Expand Down

0 comments on commit d09a1b9

Please sign in to comment.