From aa514d12e0c2c2295ee66522f0f29e0c89cb1dca Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Sat, 6 Apr 2024 15:47:02 +0530 Subject: [PATCH 1/7] Add examples for scaffolder action & improve related tests Signed-off-by: parmar-abhinav --- .changeset/fluffy-ducks-joke.md | 5 + .../gitlabMergeRequest.examples.test.ts | 305 ++++++++++++++++++ .../actions/gitlabMergeRequest.examples.ts | 142 ++++++++ .../src/actions/gitlabMergeRequest.ts | 2 + 4 files changed, 454 insertions(+) create mode 100644 .changeset/fluffy-ducks-joke.md create mode 100644 plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.test.ts create mode 100644 plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.ts diff --git a/.changeset/fluffy-ducks-joke.md b/.changeset/fluffy-ducks-joke.md new file mode 100644 index 0000000000..932cbb5298 --- /dev/null +++ b/.changeset/fluffy-ducks-joke.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gitlab': patch +--- + +Add examples for `publish:gitlab:merge-request` scaffolder action & improve related tests diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.test.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.test.ts new file mode 100644 index 0000000000..6f26bc1c68 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.test.ts @@ -0,0 +1,305 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { createRootLogger } from '@backstage/backend-common'; +import { ConfigReader } from '@backstage/config'; +import { ScmIntegrations } from '@backstage/integration'; +import { TemplateAction } from '@backstage/plugin-scaffolder-node'; +import { createPublishGitlabMergeRequestAction } from './gitlabMergeRequest'; +import { createMockDirectory } from '@backstage/backend-test-utils'; +import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; +import { examples } from './gitlabMergeRequest.examples'; +import yaml from 'yaml'; + +// Make sure root logger is initialized ahead of FS mock +createRootLogger(); + +const mockGitlabClient = { + Namespaces: { + show: jest.fn(), + }, + Branches: { + create: jest.fn(), + }, + Commits: { + create: jest.fn(), + }, + MergeRequests: { + create: jest.fn(async (_: any) => { + return { + default_branch: 'main', + }; + }), + }, + Projects: { + create: jest.fn(), + show: jest.fn(async (_: any) => { + return { + default_branch: 'main', + }; + }), + }, + Users: { + current: jest.fn(), + username: jest.fn(async (user: string) => { + const users: string[] = ['John Smith', 'my-assignee']; + if (!users.includes(user)) throw new Error('user does not exist'); + else + return [ + { + id: 123, + }, + ]; + }), + }, +}; + +jest.mock('@gitbeaker/node', () => ({ + Gitlab: class { + constructor() { + return mockGitlabClient; + } + }, +})); + +describe('createGitLabMergeRequest', () => { + let instance: TemplateAction; + + const mockDir = createMockDirectory(); + const workspacePath = mockDir.resolve('workspace'); + + beforeEach(() => { + jest.clearAllMocks(); + + mockDir.clear(); + + const config = new ConfigReader({ + integrations: { + gitlab: [ + { + host: 'gitlab.com', + token: 'token', + apiBaseUrl: 'https://api.gitlab.com', + }, + { + host: 'hosted.gitlab.com', + apiBaseUrl: 'https://api.hosted.gitlab.com', + }, + ], + }, + }); + + const integrations = ScmIntegrations.fromConfig(config); + instance = createPublishGitlabMergeRequestAction({ integrations }); + }); + + describe('createGitLabMergeRequestWithAssignee', () => { + it(`Should ${examples[0].description}`, async () => { + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + + const input = yaml.parse(examples[0].example).steps[0].input; + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'main', + 'Create my new MR', + { + description: 'This MR is really good', + removeSourceBranch: false, + assigneeId: 123, + }, + ); + }); + + it('assignee is not set when a valid assignee username is not passed in options', async () => { + const input = { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + branchName: 'new-mr', + description: 'This is an important change', + removeSourceBranch: false, + targetPath: 'Subdirectory', + assingnee: 'John Doe', + }; + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'main', + 'Create my new MR', + { + description: 'This is an important change', + removeSourceBranch: false, + assigneeId: undefined, + }, + ); + }); + }); + + describe('createGitLabMergeRequestWithRemoveBranch', () => { + it(`Should ${examples[1].description}`, async () => { + const input = yaml.parse(examples[1].example).steps[0].input; + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'main', + 'Create my new MR', + { description: 'This MR is really good', removeSourceBranch: true }, + ); + }); + }); + + describe('createGitLabMergeRequestWithSpecifiedTargetBranch', () => { + it(`Should ${examples[2].description}`, async () => { + const input = yaml.parse(examples[2].example).steps[0].input; + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.Projects.show).not.toHaveBeenCalled(); + expect(mockGitlabClient.Branches.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'test', + ); + expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'test', + 'Create my new MR', + { description: 'This MR is really good', removeSourceBranch: false }, + ); + expect(ctx.output).toHaveBeenCalledWith('targetBranchName', 'test'); + }); + }); + + describe('createGitLabMergeRequestWithCommitAction', () => { + it(`Should ${examples[3].description}`, async () => { + const input = yaml.parse(examples[3].example).steps[0].input; + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.Commits.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'Create my new MR', + [ + { + action: 'create', + filePath: 'source/foo.txt', + content: 'SGVsbG8gdGhlcmUh', + encoding: 'base64', + execute_filemode: false, + }, + ], + ); + }); + + it(`Should ${examples[4].description}`, async () => { + const input = yaml.parse(examples[4].example).steps[0].input; + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.Commits.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'Create my new MR', + [ + { + action: 'delete', + filePath: 'source/foo.txt', + content: 'SGVsbG8gdGhlcmUh', + encoding: 'base64', + execute_filemode: false, + }, + ], + ); + }); + + it(`Should ${examples[5].description}`, async () => { + const input = yaml.parse(examples[5].example).steps[0].input; + mockDir.setContent({ + [workspacePath]: { + source: { 'foo.txt': 'Hello there!' }, + irrelevant: { 'bar.txt': 'Nothing to see here' }, + }, + }); + + const ctx = createMockActionContext({ input, workspacePath }); + await instance.handler(ctx); + + expect(mockGitlabClient.Commits.create).toHaveBeenCalledWith( + 'owner/repo', + 'new-mr', + 'Create my new MR', + [ + { + action: 'update', + filePath: 'source/foo.txt', + content: 'SGVsbG8gdGhlcmUh', + encoding: 'base64', + execute_filemode: false, + }, + ], + ); + }); + }); +}); diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.ts new file mode 100644 index 0000000000..8bed461d25 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.examples.ts @@ -0,0 +1,142 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { TemplateExample } from '@backstage/plugin-scaffolder-node'; +import yaml from 'yaml'; + +export const examples: TemplateExample[] = [ + { + description: 'Create a merge request with a specific assignee', + example: yaml.stringify({ + steps: [ + { + id: 'createMergeRequest', + action: 'publish:gitlab:merge-request', + name: 'Create a Merge Request', + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + description: 'This MR is really good', + sourcePath: './path/to/my/changes', + branchName: 'new-mr', + assignee: 'my-assignee', + }, + }, + ], + }), + }, + { + description: + 'Create a merge request with removal of source branch after merge', + example: yaml.stringify({ + steps: [ + { + id: 'createMergeRequest', + action: 'publish:gitlab:merge-request', + name: 'Create a Merge Request', + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + description: 'This MR is really good', + sourcePath: './path/to/my/changes', + branchName: 'new-mr', + removeSourceBranch: true, + }, + }, + ], + }), + }, + { + description: 'Create a merge request with a target branch', + example: yaml.stringify({ + steps: [ + { + id: 'createMergeRequest', + action: 'publish:gitlab:merge-request', + name: 'Create a Merge Request', + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + description: 'This MR is really good', + sourcePath: './path/to/my/changes', + branchName: 'new-mr', + targetBranchName: 'test', + targetPath: 'Subdirectory', + }, + }, + ], + }), + }, + { + description: 'Create a merge request with a commit action as create', + example: yaml.stringify({ + steps: [ + { + id: 'createMergeRequest', + action: 'publish:gitlab:merge-request', + name: 'Create a Merge Request', + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + branchName: 'new-mr', + description: 'MR description', + commitAction: 'create', + targetPath: 'source', + }, + }, + ], + }), + }, + { + description: 'Create a merge request with a commit action as delete', + example: yaml.stringify({ + steps: [ + { + id: 'createMergeRequest', + action: 'publish:gitlab:merge-request', + name: 'Create a Merge Request', + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + branchName: 'new-mr', + description: 'MR description', + commitAction: 'delete', + targetPath: 'source', + }, + }, + ], + }), + }, + { + description: 'Create a merge request with a commit action as update', + example: yaml.stringify({ + steps: [ + { + id: 'createMergeRequest', + action: 'publish:gitlab:merge-request', + name: 'Create a Merge Request', + input: { + repoUrl: 'gitlab.com?repo=repo&owner=owner', + title: 'Create my new MR', + branchName: 'new-mr', + description: 'MR description', + commitAction: 'update', + targetPath: 'source', + }, + }, + ], + }), + }, +]; diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts index 86f69ee357..c9b8ce68a9 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts @@ -25,6 +25,7 @@ import { ScmIntegrationRegistry } from '@backstage/integration'; import { InputError } from '@backstage/errors'; import { resolveSafeChildPath } from '@backstage/backend-common'; import { createGitlabApi } from './helpers'; +import { examples } from './gitlabMergeRequest.examples'; /** * Create a new action that creates a gitlab merge request. @@ -52,6 +53,7 @@ export const createPublishGitlabMergeRequestAction = (options: { assignee?: string; }>({ id: 'publish:gitlab:merge-request', + examples, schema: { input: { required: ['repoUrl', 'branchName'], From 52f40ea81aaf5b2901a5d985fbc9de36c45e625b Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Sun, 7 Apr 2024 10:23:10 +0530 Subject: [PATCH 2/7] Add examples for gitlab:group:ensureExists scaffolder action and improve related tests Signed-off-by: parmar-abhinav --- .changeset/proud-queens-mix.md | 5 + ...abGroupEnsureExistsAction.examples.test.ts | 198 ++++++++++++++++++ ...eGitlabGroupEnsureExistsAction.examples.ts | 85 ++++++++ .../createGitlabGroupEnsureExistsAction.ts | 2 + 4 files changed, 290 insertions(+) create mode 100644 .changeset/proud-queens-mix.md create mode 100644 plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.test.ts create mode 100644 plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.ts diff --git a/.changeset/proud-queens-mix.md b/.changeset/proud-queens-mix.md new file mode 100644 index 0000000000..b5a1343998 --- /dev/null +++ b/.changeset/proud-queens-mix.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gitlab': minor +--- + +Add examples for gitlab:group:ensureExists scaffolder action & improve related tests diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.test.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.test.ts new file mode 100644 index 0000000000..2d077c7400 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.test.ts @@ -0,0 +1,198 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createGitlabGroupEnsureExistsAction } from './createGitlabGroupEnsureExistsAction'; +import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils'; +import { ConfigReader } from '@backstage/core-app-api'; +import { ScmIntegrations } from '@backstage/integration'; +import yaml from 'yaml'; +import { examples } from './createGitlabGroupEnsureExistsAction.examples'; + +const mockGitlabClient = { + Groups: { + search: jest.fn(), + create: jest.fn(), + }, +}; +jest.mock('@gitbeaker/node', () => ({ + Gitlab: class { + constructor() { + return mockGitlabClient; + } + }, +})); + +describe('gitlab:group:ensureExists', () => { + const mockContext = createMockActionContext(); + + afterEach(() => { + jest.resetAllMocks(); + }); + + it(`Should ${examples[0].description}`, async () => { + mockGitlabClient.Groups.search.mockResolvedValue([]); + mockGitlabClient.Groups.create.mockResolvedValue({ + id: 3, + full_path: 'group1', + }); + + const config = new ConfigReader({ + integrations: { + gitlab: [ + { + host: 'gitlab.com', + token: 'tokenlols', + apiBaseUrl: 'https://api.gitlab.com', + }, + ], + }, + }); + const integrations = ScmIntegrations.fromConfig(config); + + const action = createGitlabGroupEnsureExistsAction({ integrations }); + + await action.handler({ + ...mockContext, + input: yaml.parse(examples[0].example).steps[0].input, + }); + + expect(mockGitlabClient.Groups.create).toHaveBeenCalledWith( + 'group1', + 'group1', + {}, + ); + + expect(mockContext.output).toHaveBeenCalledWith('groupId', 3); + }); + + it(`Should ${examples[1].description}`, async () => { + mockGitlabClient.Groups.search.mockResolvedValue([ + { + id: 1, + full_path: 'group1', + }, + ]); + mockGitlabClient.Groups.create.mockResolvedValue({ + id: 3, + full_path: 'group1/group2', + }); + + const config = new ConfigReader({ + integrations: { + gitlab: [ + { + host: 'gitlab.com', + token: 'tokenlols', + apiBaseUrl: 'https://api.gitlab.com', + }, + ], + }, + }); + const integrations = ScmIntegrations.fromConfig(config); + + const action = createGitlabGroupEnsureExistsAction({ integrations }); + + await action.handler({ + ...mockContext, + input: yaml.parse(examples[1].example).steps[0].input, + }); + + expect(mockGitlabClient.Groups.create).toHaveBeenCalledWith( + 'group2', + 'group2', + { + parent_id: 1, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('groupId', 3); + }); + + it(`Should ${examples[2].description}`, async () => { + mockGitlabClient.Groups.search.mockResolvedValue([ + { + id: 1, + full_path: 'group1', + }, + { + id: 2, + full_path: 'group1/group2', + }, + ]); + mockGitlabClient.Groups.create.mockResolvedValue({ + id: 3, + full_path: 'group1/group2/group3', + }); + + const config = new ConfigReader({ + integrations: { + gitlab: [ + { + host: 'gitlab.com', + token: 'tokenlols', + apiBaseUrl: 'https://api.gitlab.com', + }, + ], + }, + }); + const integrations = ScmIntegrations.fromConfig(config); + + const action = createGitlabGroupEnsureExistsAction({ integrations }); + + await action.handler({ + ...mockContext, + input: yaml.parse(examples[2].example).steps[0].input, + }); + + expect(mockGitlabClient.Groups.create).toHaveBeenCalledWith( + 'group3', + 'group3', + { + parent_id: 2, + }, + ); + + expect(mockContext.output).toHaveBeenCalledWith('groupId', 3); + }); + + it(`Should ${examples[3].description}`, async () => { + const config = new ConfigReader({ + integrations: { + gitlab: [ + { + host: 'gitlab.com', + token: 'tokenlols', + apiBaseUrl: 'https://api.gitlab.com', + }, + ], + }, + }); + const integrations = ScmIntegrations.fromConfig(config); + + const action = createGitlabGroupEnsureExistsAction({ integrations }); + + await action.handler({ + ...mockContext, + isDryRun: yaml.parse(examples[3].example).steps[0].isDryRun, + input: yaml.parse(examples[3].example).steps[0].input, + }); + + expect(mockGitlabClient.Groups.search).not.toHaveBeenCalled(); + expect(mockGitlabClient.Groups.create).not.toHaveBeenCalled(); + + expect(mockContext.output).toHaveBeenCalledWith('groupId', 42); + }); +}); diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.ts new file mode 100644 index 0000000000..41dd822e82 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.examples.ts @@ -0,0 +1,85 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { TemplateExample } from '@backstage/plugin-scaffolder-node'; +import yaml from 'yaml'; + +export const examples: TemplateExample[] = [ + { + description: 'Creating a group at the top level', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabGroup', + name: 'Group', + action: 'gitlab:group:ensureExists', + input: { + repoUrl: 'gitlab.com', + path: ['group1'], + }, + }, + ], + }), + }, + { + description: 'Create a group nested within another group', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabGroup', + name: 'Group', + action: 'gitlab:group:ensureExists', + input: { + repoUrl: 'gitlab.com', + path: ['group1', 'group2'], + }, + }, + ], + }), + }, + { + description: 'Create a group nested within multiple other groups', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabGroup', + name: 'Group', + action: 'gitlab:group:ensureExists', + input: { + repoUrl: 'gitlab.com', + path: ['group1', 'group2', 'group3'], + }, + }, + ], + }), + }, + { + description: 'Create a group in dry run mode', + example: yaml.stringify({ + steps: [ + { + id: 'gitlabGroup', + name: 'Group', + action: 'gitlab:group:ensureExists', + isDryRun: true, + input: { + repoUrl: 'https://gitlab.com/my-repo', + path: ['group1', 'group2', 'group3'], + }, + }, + ], + }), + }, +]; diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.ts index 74d3805254..2cf583a95d 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabGroupEnsureExistsAction.ts @@ -21,6 +21,7 @@ import { GroupSchema } from '@gitbeaker/core/dist/types/resources/Groups'; import commonGitlabConfig from '../commonGitlabConfig'; import { getToken } from '../util'; import { z } from 'zod'; +import { examples } from './createGitlabGroupEnsureExistsAction.examples'; /** * Creates an `gitlab:group:ensureExists` Scaffolder action. @@ -36,6 +37,7 @@ export const createGitlabGroupEnsureExistsAction = (options: { id: 'gitlab:group:ensureExists', description: 'Ensures a Gitlab group exists', supportsDryRun: true, + examples, schema: { input: commonGitlabConfig.merge( z.object({ From ee333a1736b2ae28b8fe2c08485e95411e4a0241 Mon Sep 17 00:00:00 2001 From: parmar-abhinav Date: Tue, 9 Apr 2024 15:07:16 +0530 Subject: [PATCH 3/7] chore: changeset changes based on review feedback Signed-off-by: parmar-abhinav --- .changeset/proud-queens-mix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/proud-queens-mix.md b/.changeset/proud-queens-mix.md index b5a1343998..f051b44d4d 100644 --- a/.changeset/proud-queens-mix.md +++ b/.changeset/proud-queens-mix.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-scaffolder-backend-module-gitlab': minor +'@backstage/plugin-scaffolder-backend-module-gitlab': patch --- -Add examples for gitlab:group:ensureExists scaffolder action & improve related tests +Add examples for `gitlab:group:ensureExists` scaffolder action & improve related tests From 4dbd200c4e4883b0321c8cb63debb27819595ed2 Mon Sep 17 00:00:00 2001 From: CiscoRob <133238823+CiscoRob@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:59:25 -0500 Subject: [PATCH 4/7] Update plugin/badges README.md Change `export` to `import` to reflect what the user will be doing in their code Signed-off-by: CiscoRob <133238823+CiscoRob@users.noreply.github.com> --- plugins/badges/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/badges/README.md b/plugins/badges/README.md index 06c0e3e413..3badfd2ea1 100644 --- a/plugins/badges/README.md +++ b/plugins/badges/README.md @@ -89,7 +89,7 @@ This plugin requires explicit registration, so you will need to add it to your A ```ts // ... -export { badgesPlugin } from '@backstage/plugin-badges'; +import { badgesPlugin } from '@backstage/plugin-badges'; ``` If you don't have a `plugins.ts` file see: [troubleshooting](#troubleshooting) From 93c1d9c5b2a2920234525f1e7bcad34b734872b0 Mon Sep 17 00:00:00 2001 From: Coderrob Date: Tue, 9 Apr 2024 17:07:49 -0500 Subject: [PATCH 5/7] Add changeset identifier Signed-off-by: Coderrob --- .changeset/spotty-ravens-whisper.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/spotty-ravens-whisper.md diff --git a/.changeset/spotty-ravens-whisper.md b/.changeset/spotty-ravens-whisper.md new file mode 100644 index 0000000000..6c52f22111 --- /dev/null +++ b/.changeset/spotty-ravens-whisper.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-badges': patch +--- + +Update README to fix invalid import command From 7f849b82e3541345de7afaac9445b77b06965017 Mon Sep 17 00:00:00 2001 From: Coderrob Date: Tue, 9 Apr 2024 17:14:29 -0500 Subject: [PATCH 6/7] Make it easier to copy pasta by removing comment from code with no actual comment Signed-off-by: Coderrob --- plugins/badges/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/badges/README.md b/plugins/badges/README.md index 3badfd2ea1..202b26762d 100644 --- a/plugins/badges/README.md +++ b/plugins/badges/README.md @@ -88,7 +88,6 @@ yarn --cwd packages/app add @backstage/plugin-badges This plugin requires explicit registration, so you will need to add it to your App's `plugins.ts` file: ```ts -// ... import { badgesPlugin } from '@backstage/plugin-badges'; ``` From b8512c663619c8b65ba14edec8ce3204cbc79c11 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:45:02 +0000 Subject: [PATCH 7/7] fix(deps): update dependency testcontainers to v10.8.2 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index dffbf4f6d3..30da40a007 100644 --- a/yarn.lock +++ b/yarn.lock @@ -43644,8 +43644,8 @@ __metadata: linkType: hard "testcontainers@npm:^10.0.0": - version: 10.7.2 - resolution: "testcontainers@npm:10.7.2" + version: 10.8.2 + resolution: "testcontainers@npm:10.8.2" dependencies: "@balena/dockerignore": ^1.0.2 "@types/dockerode": ^3.3.24 @@ -43662,7 +43662,7 @@ __metadata: ssh-remote-port-forward: ^1.0.4 tar-fs: ^3.0.5 tmp: ^0.2.1 - checksum: b4650509e3e072b96cd8ed75fdeeaa8a51a81cc9d45aabec26d4915cf9942e051f14fce4d23a29e70a007c2e8b3ce46f72dac602962f21c5a8d27976c846ef24 + checksum: 3a97ad705c98abc5066577699be5e791090ef2a5c45fee3a203196fa09d0cb66c7709f6ae8168c025ed97a07f1f5f0676a34e748680514e732e90671720d34c6 languageName: node linkType: hard