refactor: make BranchProtectionOoptions.requiredStatusCheckContexts optional
Signed-off-by: Chris Trombley <ctrombley@gmail.com>
This commit is contained in:
committed by
Chris Trombley
parent
9818112d12
commit
8d624a7fd3
@@ -2,4 +2,5 @@
|
||||
'@backstage/plugin-scaffolder-backend': minor
|
||||
---
|
||||
|
||||
Update the github:publish action to allow passing required status checks by name.
|
||||
Update the `github:publish` action to allow passing required status check
|
||||
contexts before merging to the main branch.
|
||||
|
||||
@@ -132,7 +132,7 @@ type BranchProtectionOptions = {
|
||||
repoName: string;
|
||||
logger: Logger;
|
||||
requireCodeOwnerReviews: boolean;
|
||||
requiredStatusChecks: string[];
|
||||
requiredStatusCheckContexts?: string[];
|
||||
defaultBranch?: string;
|
||||
};
|
||||
|
||||
@@ -142,7 +142,7 @@ export const enableBranchProtectionOnDefaultRepoBranch = async ({
|
||||
owner,
|
||||
logger,
|
||||
requireCodeOwnerReviews,
|
||||
requiredStatusChecks = [],
|
||||
requiredStatusCheckContexts = [],
|
||||
defaultBranch = 'master',
|
||||
}: BranchProtectionOptions): Promise<void> => {
|
||||
const tryOnce = async () => {
|
||||
@@ -163,7 +163,7 @@ export const enableBranchProtectionOnDefaultRepoBranch = async ({
|
||||
branch: defaultBranch,
|
||||
required_status_checks: {
|
||||
strict: true,
|
||||
contexts: requiredStatusChecks,
|
||||
contexts: requiredStatusCheckContexts,
|
||||
},
|
||||
restrictions: null,
|
||||
enforce_admins: true,
|
||||
|
||||
@@ -625,7 +625,7 @@ describe('publish:github', () => {
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusChecks: [],
|
||||
requiredStatusCheckContexts: [],
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
@@ -643,7 +643,7 @@ describe('publish:github', () => {
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
requireCodeOwnerReviews: true,
|
||||
requiredStatusChecks: [],
|
||||
requiredStatusCheckContexts: [],
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
@@ -661,11 +661,11 @@ describe('publish:github', () => {
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusChecks: [],
|
||||
requiredStatusCheckContexts: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('should call enableBranchProtectionOnDefaultRepoBranch with the correct values of requireStatusChecks', async () => {
|
||||
it('should call enableBranchProtectionOnDefaultRepoBranch with the correct values of requiredStatusCheckContexts', async () => {
|
||||
mockOctokit.rest.users.getByUsername.mockResolvedValue({
|
||||
data: { type: 'User' },
|
||||
});
|
||||
@@ -685,14 +685,14 @@ describe('publish:github', () => {
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusChecks: [],
|
||||
requiredStatusCheckContexts: [],
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
requiredStatusChecks: ['statusCheck'],
|
||||
requiredStatusCheckContexts: ['statusCheck'],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -703,14 +703,14 @@ describe('publish:github', () => {
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusChecks: ['statusCheck'],
|
||||
requiredStatusCheckContexts: ['statusCheck'],
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
requiredStatusChecks: [],
|
||||
requiredStatusCheckContexts: [],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -721,7 +721,7 @@ describe('publish:github', () => {
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusChecks: [],
|
||||
requiredStatusCheckContexts: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ export function createPublishGithubAction(options: {
|
||||
allowMergeCommit?: boolean;
|
||||
sourcePath?: string;
|
||||
requireCodeOwnerReviews?: boolean;
|
||||
requiredStatusChecks?: string[];
|
||||
requiredStatusCheckContexts?: string[];
|
||||
repoVisibility?: 'private' | 'internal' | 'public';
|
||||
collaborators?: Array<{
|
||||
username: string;
|
||||
@@ -89,8 +89,8 @@ export function createPublishGithubAction(options: {
|
||||
'Require an approved review in PR including files with a designated Code Owner',
|
||||
type: 'boolean',
|
||||
},
|
||||
requiredStatusChecks: {
|
||||
title: 'Required Status Checks',
|
||||
requiredStatusCheckContexts: {
|
||||
title: 'Required Status Check Contexts',
|
||||
description:
|
||||
'The list of status checks to require in order to merge into this branch',
|
||||
type: 'array',
|
||||
@@ -188,7 +188,7 @@ export function createPublishGithubAction(options: {
|
||||
description,
|
||||
access,
|
||||
requireCodeOwnerReviews = false,
|
||||
requiredStatusChecks = [],
|
||||
requiredStatusCheckContexts = [],
|
||||
repoVisibility = 'private',
|
||||
defaultBranch = 'master',
|
||||
deleteBranchOnMerge = false,
|
||||
@@ -328,7 +328,7 @@ export function createPublishGithubAction(options: {
|
||||
logger: ctx.logger,
|
||||
defaultBranch,
|
||||
requireCodeOwnerReviews,
|
||||
requiredStatusChecks,
|
||||
requiredStatusCheckContexts,
|
||||
});
|
||||
} catch (e) {
|
||||
assertError(e);
|
||||
|
||||
Reference in New Issue
Block a user