Add support for enabling Gitub wiki, issues and projects
Signed-off-by: Kyle Leonhard <kyle.leonhard@snowflake.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Add support for disabling Github repository wiki, issues and projects
|
||||
@@ -225,6 +225,9 @@ export function createGithubRepoCreateAction(options: {
|
||||
}
|
||||
)[]
|
||||
| undefined;
|
||||
hasProjects?: boolean | undefined;
|
||||
hasWiki?: boolean | undefined;
|
||||
hasIssues?: boolean | undefined;
|
||||
token?: string | undefined;
|
||||
topics?: string[] | undefined;
|
||||
}>;
|
||||
@@ -412,6 +415,9 @@ export function createPublishGithubAction(options: {
|
||||
}
|
||||
)[]
|
||||
| undefined;
|
||||
hasProjects?: boolean | undefined;
|
||||
hasWiki?: boolean | undefined;
|
||||
hasIssues?: boolean | undefined;
|
||||
token?: string | undefined;
|
||||
topics?: string[] | undefined;
|
||||
}>;
|
||||
|
||||
+104
@@ -152,6 +152,60 @@ describe('github:repo:create', () => {
|
||||
allow_auto_merge: false,
|
||||
visibility: 'private',
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: true,
|
||||
hasProjects: true,
|
||||
hasIssues: true,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createInOrg,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
org: 'owner',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
visibility: 'private',
|
||||
has_wiki: true,
|
||||
has_projects: true,
|
||||
has_issues: true,
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: false,
|
||||
hasProjects: false,
|
||||
hasIssues: false,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createInOrg,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
org: 'owner',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
visibility: 'private',
|
||||
has_wiki: false,
|
||||
has_projects: false,
|
||||
has_issues: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the githubApis with the correct values for createForAuthenticatedUser', async () => {
|
||||
@@ -217,6 +271,56 @@ describe('github:repo:create', () => {
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: true,
|
||||
hasProjects: true,
|
||||
hasIssues: true,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createForAuthenticatedUser,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
has_wiki: true,
|
||||
has_projects: true,
|
||||
has_issues: true,
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: false,
|
||||
hasProjects: false,
|
||||
hasIssues: false,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createForAuthenticatedUser,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
has_wiki: false,
|
||||
has_projects: false,
|
||||
has_issues: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should add access for the team when it starts with the owner', async () => {
|
||||
|
||||
@@ -76,6 +76,9 @@ export function createGithubRepoCreateAction(options: {
|
||||
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
|
||||
}
|
||||
>;
|
||||
hasProjects?: boolean;
|
||||
hasWiki?: boolean;
|
||||
hasIssues?: boolean;
|
||||
token?: string;
|
||||
topics?: string[];
|
||||
}>({
|
||||
@@ -103,6 +106,9 @@ export function createGithubRepoCreateAction(options: {
|
||||
allowRebaseMerge: inputProps.allowRebaseMerge,
|
||||
allowAutoMerge: inputProps.allowAutoMerge,
|
||||
collaborators: inputProps.collaborators,
|
||||
hasProjects: inputProps.hasProjects,
|
||||
hasWiki: inputProps.hasWiki,
|
||||
hasIssues: inputProps.hasIssues,
|
||||
token: inputProps.token,
|
||||
topics: inputProps.topics,
|
||||
},
|
||||
@@ -128,6 +134,9 @@ export function createGithubRepoCreateAction(options: {
|
||||
allowRebaseMerge = true,
|
||||
allowAutoMerge = false,
|
||||
collaborators,
|
||||
hasProjects = undefined,
|
||||
hasWiki = undefined,
|
||||
hasIssues = undefined,
|
||||
topics,
|
||||
token: providedToken,
|
||||
} = ctx.input;
|
||||
@@ -160,6 +169,9 @@ export function createGithubRepoCreateAction(options: {
|
||||
allowAutoMerge,
|
||||
access,
|
||||
collaborators,
|
||||
hasProjects,
|
||||
hasWiki,
|
||||
hasIssues,
|
||||
topics,
|
||||
ctx.logger,
|
||||
);
|
||||
|
||||
@@ -122,6 +122,9 @@ export async function createGithubRepoWithCollaboratorsAndTopics(
|
||||
}
|
||||
)[]
|
||||
| undefined,
|
||||
hasProjects: boolean | undefined,
|
||||
hasWiki: boolean | undefined,
|
||||
hasIssues: boolean | undefined,
|
||||
topics: string[] | undefined,
|
||||
logger: Logger,
|
||||
) {
|
||||
@@ -144,6 +147,9 @@ export async function createGithubRepoWithCollaboratorsAndTopics(
|
||||
allow_rebase_merge: allowRebaseMerge,
|
||||
allow_auto_merge: allowAutoMerge,
|
||||
homepage: homepage,
|
||||
has_projects: hasProjects,
|
||||
has_wiki: hasWiki,
|
||||
has_issues: hasIssues,
|
||||
})
|
||||
: client.rest.repos.createForAuthenticatedUser({
|
||||
name: repo,
|
||||
@@ -155,6 +161,9 @@ export async function createGithubRepoWithCollaboratorsAndTopics(
|
||||
allow_rebase_merge: allowRebaseMerge,
|
||||
allow_auto_merge: allowAutoMerge,
|
||||
homepage: homepage,
|
||||
has_projects: hasProjects,
|
||||
has_wiki: hasWiki,
|
||||
has_issues: hasIssues,
|
||||
});
|
||||
|
||||
let newRepo;
|
||||
|
||||
@@ -132,6 +132,21 @@ const collaborators = {
|
||||
oneOf: [{ required: ['user'] }, { required: ['team'] }],
|
||||
},
|
||||
};
|
||||
const hasProjects = {
|
||||
title: 'Enable projects',
|
||||
type: 'boolean',
|
||||
description: `Enable projects for the repository. The default value is 'true' unless the organization has disabled repository projects`,
|
||||
};
|
||||
const hasWiki = {
|
||||
title: 'Enable the wiki',
|
||||
type: 'boolean',
|
||||
description: `Enable the wiki for the repository. The default value is 'true'`,
|
||||
};
|
||||
const hasIssues = {
|
||||
title: 'Enable issues',
|
||||
type: 'boolean',
|
||||
description: `Enable issues for the repository. The default value is 'true'`,
|
||||
};
|
||||
const token = {
|
||||
title: 'Authentication Token',
|
||||
type: 'string',
|
||||
@@ -223,6 +238,9 @@ export { dismissStaleReviews };
|
||||
export { requiredStatusCheckContexts };
|
||||
export { requireBranchesToBeUpToDate };
|
||||
export { requiredConversationResolution };
|
||||
export { hasProjects };
|
||||
export { hasIssues };
|
||||
export { hasWiki };
|
||||
export { sourcePath };
|
||||
export { token };
|
||||
export { topics };
|
||||
|
||||
@@ -157,6 +157,60 @@ describe('publish:github', () => {
|
||||
allow_auto_merge: false,
|
||||
visibility: 'private',
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: true,
|
||||
hasProjects: true,
|
||||
hasIssues: true,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createInOrg,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
org: 'owner',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
visibility: 'private',
|
||||
has_wiki: true,
|
||||
has_projects: true,
|
||||
has_issues: true,
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: false,
|
||||
hasProjects: false,
|
||||
hasIssues: false,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createInOrg,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
org: 'owner',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
visibility: 'private',
|
||||
has_wiki: false,
|
||||
has_projects: false,
|
||||
has_issues: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the githubApis with the correct values for createForAuthenticatedUser', async () => {
|
||||
@@ -222,6 +276,56 @@ describe('publish:github', () => {
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: true,
|
||||
hasProjects: true,
|
||||
hasIssues: true,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createForAuthenticatedUser,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
has_wiki: true,
|
||||
has_projects: true,
|
||||
has_issues: true,
|
||||
});
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
hasWiki: false,
|
||||
hasProjects: false,
|
||||
hasIssues: false,
|
||||
},
|
||||
});
|
||||
expect(
|
||||
mockOctokit.rest.repos.createForAuthenticatedUser,
|
||||
).toHaveBeenCalledWith({
|
||||
description: 'description',
|
||||
name: 'repo',
|
||||
private: true,
|
||||
delete_branch_on_merge: false,
|
||||
allow_squash_merge: true,
|
||||
allow_merge_commit: true,
|
||||
allow_rebase_merge: true,
|
||||
allow_auto_merge: false,
|
||||
has_wiki: false,
|
||||
has_projects: false,
|
||||
has_issues: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should call initRepoAndPush with the correct values', async () => {
|
||||
|
||||
@@ -88,6 +88,9 @@ export function createPublishGithubAction(options: {
|
||||
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
|
||||
}
|
||||
>;
|
||||
hasProjects?: boolean | undefined;
|
||||
hasWiki?: boolean | undefined;
|
||||
hasIssues?: boolean | undefined;
|
||||
token?: string;
|
||||
topics?: string[];
|
||||
}>({
|
||||
@@ -124,6 +127,9 @@ export function createPublishGithubAction(options: {
|
||||
allowAutoMerge: inputProps.allowAutoMerge,
|
||||
sourcePath: inputProps.sourcePath,
|
||||
collaborators: inputProps.collaborators,
|
||||
hasProjects: inputProps.hasProjects,
|
||||
hasWiki: inputProps.hasWiki,
|
||||
hasIssues: inputProps.hasIssues,
|
||||
token: inputProps.token,
|
||||
topics: inputProps.topics,
|
||||
},
|
||||
@@ -161,6 +167,9 @@ export function createPublishGithubAction(options: {
|
||||
allowRebaseMerge = true,
|
||||
allowAutoMerge = false,
|
||||
collaborators,
|
||||
hasProjects = undefined,
|
||||
hasWiki = undefined,
|
||||
hasIssues = undefined,
|
||||
topics,
|
||||
token: providedToken,
|
||||
} = ctx.input;
|
||||
@@ -193,6 +202,9 @@ export function createPublishGithubAction(options: {
|
||||
allowAutoMerge,
|
||||
access,
|
||||
collaborators,
|
||||
hasProjects,
|
||||
hasWiki,
|
||||
hasIssues,
|
||||
topics,
|
||||
ctx.logger,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user