Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow repo default branch to be non-versioned #174

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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