From d620a5fb96e2d98968acdcb62d27cd79ab5bca2a Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 27 Jul 2021 10:54:49 +0300 Subject: [PATCH 01/11] feat(gitlab): Add gitLabIgnoreApprovals option --- docs/usage/configuration-options.md | 4 ++++ lib/config/definitions.ts | 8 +++++++- lib/platform/gitlab/index.ts | 19 +++++++++++++++++++ lib/platform/types.ts | 1 + lib/workers/pr/index.ts | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index c3b371708676ee..24907f87093161 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -685,6 +685,10 @@ If you enabled `automerge` in the Renovate config, you can speed up the automerg Caution (fixed in GitLab >= 12.7): when this option is enabled it is possible due to a bug in GitLab that MRs with failing pipelines might still get merged. This is caused by a race condition in GitLab's Merge Request API - [read the corresponding issue](https://gitlab.com/gitlab-org/gitlab/issues/26293) for details. +## gitLabIgnoreApprovals + +Ignore default project level approvals, so that an automerge can be completed without those approvals. Under the hood, it creates MR-level approval rule with `approvals_required=0` parameter. + ## golang Configuration added here applies for all Go-related updates, however currently the only supported package manager for Go is the native Go Modules (the `gomod` manager). diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts index 2c232094fd336c..8aeb541a26603c 100644 --- a/lib/config/definitions.ts +++ b/lib/config/definitions.ts @@ -1884,7 +1884,13 @@ const options: RenovateOptions[] = [ }, { name: 'gitLabAutomerge', - description: `Enable or disable usage of GitLab's "merge when pipeline succeeds" feature when automerging PRs.`, + description: `Enable or disable usage of GitLab's "merge when pipeline succeeds" feature when automerging MRs.`, + type: 'boolean', + default: false, + }, + { + name: 'gitLabIgnoreApprovals', + description: `Ignore approval rules for MRs created by Renovate, which is useful for automerge.`, type: 'boolean', default: false, }, diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 18125a3e264a29..625feb5e0f9c2b 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -440,12 +440,31 @@ export async function getPrList(): Promise { return config.prList; } +async function ignoreApprovals(pr: number): Promise { + const url = `projects/${config.repository}/merge_requests/${pr}/approval_rules`; + const { body: rules } = await gitlabApi.getJson<{ name: string }[]>(url); + const ruleName = 'renovateIgnoreApprovals'; + const zeroApproversRule = rules.find(({ name }) => name === ruleName); + if (!zeroApproversRule) { + await gitlabApi.postJson(url, { + body: { + name: ruleName, + approvals_required: 0, + }, + }); + } +} + async function tryPrAutomerge( pr: number, platformOptions: PlatformPrOptions ): Promise { if (platformOptions?.gitLabAutomerge) { try { + if (platformOptions?.gitLabIgnoreApprovals) { + await ignoreApprovals(pr); + } + const desiredStatus = 'can_be_merged'; const retryTimes = 5; diff --git a/lib/platform/types.ts b/lib/platform/types.ts index 150e6d1818e406..13b53aa3e84685 100644 --- a/lib/platform/types.ts +++ b/lib/platform/types.ts @@ -77,6 +77,7 @@ export type PlatformPrOptions = { azureWorkItemId?: number; bbUseDefaultReviewers?: boolean; gitLabAutomerge?: boolean; + gitLabIgnoreApprovals?: boolean; }; export interface CreatePRConfig { sourceBranch: string; diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index b4bd2b75b9a236..a05022d9d89563 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -124,6 +124,7 @@ export function getPlatformPrOptions( config.automerge && config.automergeType === 'pr' && config.gitLabAutomerge, + gitLabIgnoreApprovals: config.gitLabIgnoreApprovals, }; } From 6f05370fa84e9346ac433d1b318d18a8efb8c48a Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 27 Jul 2021 12:52:06 +0300 Subject: [PATCH 02/11] Add unit tests --- .../gitlab/__snapshots__/index.spec.ts.snap | 190 ++++++++++++++++++ lib/platform/gitlab/index.spec.ts | 86 ++++++++ lib/platform/gitlab/index.ts | 2 +- lib/workers/pr/index.ts | 9 +- 4 files changed, 284 insertions(+), 3 deletions(-) diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index d1499c65bebe09..3ad080c5753e37 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -141,6 +141,108 @@ Array [ ] `; +exports[`platform/gitlab/index createPr(branchName, title, body) adds approval rule to ignore all approvals 1`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer some-token", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/user", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer some-token", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/version", + }, + Object { + "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":\\"\\"}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "142", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + }, + Object { + "body": "{\\"name\\":\\"renovateIgnoreApprovals\\",\\"approvals_required\\":0}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "57", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + }, + Object { + "body": "{\\"should_remove_source_branch\\":true,\\"merge_when_pipeline_succeeds\\":true}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "72", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "PUT", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/merge", + }, +] +`; + exports[`platform/gitlab/index createPr(branchName, title, body) auto-accepts the MR when requested 1`] = ` Array [ Object { @@ -218,6 +320,94 @@ Array [ ] `; +exports[`platform/gitlab/index createPr(branchName, title, body) does not trying to create already existing approval rule 1`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer some-token", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/user", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer some-token", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/version", + }, + Object { + "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":\\"\\"}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "142", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + }, + Object { + "body": "{\\"should_remove_source_branch\\":true,\\"merge_when_pipeline_succeeds\\":true}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "72", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "PUT", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/merge", + }, +] +`; + exports[`platform/gitlab/index createPr(branchName, title, body) returns the PR 1`] = ` Object { "displayNumber": "Merge Request #12345", diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 1deb9edbbf1d01..5ff3e2b7787cf8 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -1359,6 +1359,92 @@ describe(getName(), () => { }); expect(httpMock.getTrace()).toMatchSnapshot(); }); + + it('adds approval rule to ignore all approvals', async () => { + await initPlatform('13.3.6-ee'); + httpMock + .scope(gitlabApiHost) + .post('/api/v4/projects/undefined/merge_requests') + .reply(200, { + id: 1, + iid: 12345, + title: 'some title', + }) + .get('/api/v4/projects/undefined/merge_requests/12345') + .reply(200) + .get('/api/v4/projects/undefined/merge_requests/12345') + .reply(200, { + merge_status: 'can_be_merged', + pipeline: { + id: 29626725, + sha: '2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f', + ref: 'patch-28', + status: 'success', + }, + }) + .put('/api/v4/projects/undefined/merge_requests/12345/merge') + .reply(200) + .get('/api/v4/projects/undefined/merge_requests/12345/approval_rules') + .reply(200, []) + .post('/api/v4/projects/undefined/merge_requests/12345/approval_rules') + .reply(200); + await gitlab.createPr({ + sourceBranch: 'some-branch', + targetBranch: 'master', + prTitle: 'some-title', + prBody: 'the-body', + labels: [], + platformOptions: { + azureAutoComplete: false, + gitLabAutomerge: true, + gitLabIgnoreApprovals: true, + }, + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('does not trying to create already existing approval rule', async () => { + await initPlatform('13.3.6-ee'); + httpMock + .scope(gitlabApiHost) + .post('/api/v4/projects/undefined/merge_requests') + .reply(200, { + id: 1, + iid: 12345, + title: 'some title', + }) + .get('/api/v4/projects/undefined/merge_requests/12345') + .reply(200) + .get('/api/v4/projects/undefined/merge_requests/12345') + .reply(200, { + merge_status: 'can_be_merged', + pipeline: { + id: 29626725, + sha: '2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f', + ref: 'patch-28', + status: 'success', + }, + }) + .put('/api/v4/projects/undefined/merge_requests/12345/merge') + .reply(200) + .get('/api/v4/projects/undefined/merge_requests/12345/approval_rules') + .reply(200, [ + { name: 'renovateIgnoreApprovals', approvals_required: 0 }, + ]); + await gitlab.createPr({ + sourceBranch: 'some-branch', + targetBranch: 'master', + prTitle: 'some-title', + prBody: 'the-body', + labels: [], + platformOptions: { + azureAutoComplete: false, + gitLabAutomerge: true, + gitLabIgnoreApprovals: true, + }, + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); }); describe('getPr(prNo)', () => { it('returns the PR', async () => { diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 625feb5e0f9c2b..72ad860176b231 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -444,7 +444,7 @@ async function ignoreApprovals(pr: number): Promise { const url = `projects/${config.repository}/merge_requests/${pr}/approval_rules`; const { body: rules } = await gitlabApi.getJson<{ name: string }[]>(url); const ruleName = 'renovateIgnoreApprovals'; - const zeroApproversRule = rules.find(({ name }) => name === ruleName); + const zeroApproversRule = rules?.find(({ name }) => name === ruleName); if (!zeroApproversRule) { await gitlabApi.postJson(url, { body: { diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index a05022d9d89563..652af411193ac6 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -115,7 +115,7 @@ export async function addAssigneesReviewers( export function getPlatformPrOptions( config: RenovateConfig & PlatformPrOptions ): PlatformPrOptions { - return { + const result: PlatformPrOptions = { azureAutoApprove: config.azureAutoApprove, azureAutoComplete: config.azureAutoComplete, azureWorkItemId: config.azureWorkItemId, @@ -124,8 +124,13 @@ export function getPlatformPrOptions( config.automerge && config.automergeType === 'pr' && config.gitLabAutomerge, - gitLabIgnoreApprovals: config.gitLabIgnoreApprovals, }; + + if (config.gitLabIgnoreApprovals) { + result.gitLabIgnoreApprovals = config.gitLabIgnoreApprovals; + } + + return result; } export type ResultWithPr = { From 63d455f3cbe7dda7c32f0f702770128c6117833c Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 27 Jul 2021 13:16:41 +0300 Subject: [PATCH 03/11] More tests --- .../gitlab/__snapshots__/index.spec.ts.snap | 102 ++++++++++++++++++ lib/platform/gitlab/index.spec.ts | 43 ++++++++ lib/platform/gitlab/index.ts | 26 +++-- 3 files changed, 160 insertions(+), 11 deletions(-) diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index 3ad080c5753e37..0ab031c9dd5803 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -408,6 +408,108 @@ Array [ ] `; +exports[`platform/gitlab/index createPr(branchName, title, body) fails silently on approval rules errors 1`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer some-token", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/user", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer some-token", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/version", + }, + Object { + "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":\\"\\"}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "142", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + }, + Object { + "body": "{\\"name\\":\\"renovateIgnoreApprovals\\",\\"approvals_required\\":0}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "57", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + }, + Object { + "body": "{\\"should_remove_source_branch\\":true,\\"merge_when_pipeline_succeeds\\":true}", + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "content-length": "72", + "content-type": "application/json", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "PUT", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/merge", + }, +] +`; + exports[`platform/gitlab/index createPr(branchName, title, body) returns the PR 1`] = ` Object { "displayNumber": "Merge Request #12345", diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 5ff3e2b7787cf8..6cc6f37facb938 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -1445,6 +1445,49 @@ describe(getName(), () => { }); expect(httpMock.getTrace()).toMatchSnapshot(); }); + + it('silently ignores approval rules adding errors', async () => { + await initPlatform('13.3.6-ee'); + httpMock + .scope(gitlabApiHost) + .post('/api/v4/projects/undefined/merge_requests') + .reply(200, { + id: 1, + iid: 12345, + title: 'some title', + }) + .get('/api/v4/projects/undefined/merge_requests/12345') + .reply(200) + .get('/api/v4/projects/undefined/merge_requests/12345') + .reply(200, { + merge_status: 'can_be_merged', + pipeline: { + id: 29626725, + sha: '2be7ddb704c7b6b83732fdd5b9f09d5a397b5f8f', + ref: 'patch-28', + status: 'success', + }, + }) + .put('/api/v4/projects/undefined/merge_requests/12345/merge') + .reply(200) + .get('/api/v4/projects/undefined/merge_requests/12345/approval_rules') + .reply(200, []) + .post('/api/v4/projects/undefined/merge_requests/12345/approval_rules') + .replyWithError('Unknown'); + await gitlab.createPr({ + sourceBranch: 'some-branch', + targetBranch: 'master', + prTitle: 'some-title', + prBody: 'the-body', + labels: [], + platformOptions: { + azureAutoComplete: false, + gitLabAutomerge: true, + gitLabIgnoreApprovals: true, + }, + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); }); describe('getPr(prNo)', () => { it('returns the PR', async () => { diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 72ad860176b231..3eef7d4ee719d1 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -441,17 +441,21 @@ export async function getPrList(): Promise { } async function ignoreApprovals(pr: number): Promise { - const url = `projects/${config.repository}/merge_requests/${pr}/approval_rules`; - const { body: rules } = await gitlabApi.getJson<{ name: string }[]>(url); - const ruleName = 'renovateIgnoreApprovals'; - const zeroApproversRule = rules?.find(({ name }) => name === ruleName); - if (!zeroApproversRule) { - await gitlabApi.postJson(url, { - body: { - name: ruleName, - approvals_required: 0, - }, - }); + try { + const url = `projects/${config.repository}/merge_requests/${pr}/approval_rules`; + const { body: rules } = await gitlabApi.getJson<{ name: string }[]>(url); + const ruleName = 'renovateIgnoreApprovals'; + const zeroApproversRule = rules?.find(({ name }) => name === ruleName); + if (!zeroApproversRule) { + await gitlabApi.postJson(url, { + body: { + name: ruleName, + approvals_required: 0, + }, + }); + } + } catch (err) { + logger.debug({ err }, 'GitLab: Error adding approval rule'); } } From a26c7fc9430e87e31a76e141e78411b2c67b6b1f Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 27 Jul 2021 13:44:32 +0300 Subject: [PATCH 04/11] Fixes --- .../gitlab/__snapshots__/index.spec.ts.snap | 84 +++++++++---------- lib/platform/gitlab/index.ts | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index 0ab031c9dd5803..381d0f288ef14a 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -408,7 +408,18 @@ Array [ ] `; -exports[`platform/gitlab/index createPr(branchName, title, body) fails silently on approval rules errors 1`] = ` +exports[`platform/gitlab/index createPr(branchName, title, body) returns the PR 1`] = ` +Object { + "displayNumber": "Merge Request #12345", + "id": 1, + "iid": 12345, + "number": 12345, + "sourceBranch": "some-branch", + "title": "some title", +} +`; + +exports[`platform/gitlab/index createPr(branchName, title, body) returns the PR 2`] = ` Array [ Object { "headers": Object { @@ -433,12 +444,12 @@ Array [ "url": "https://gitlab.com/api/v4/version", }, Object { - "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":\\"\\"}", + "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":null}", "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", "authorization": "Bearer abc123", - "content-length": "142", + "content-length": "144", "content-type": "application/json", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", @@ -446,41 +457,46 @@ Array [ "method": "POST", "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests", }, +] +`; + +exports[`platform/gitlab/index createPr(branchName, title, body) silently ignores approval rules adding errors 1`] = ` +Array [ Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", - "authorization": "Bearer abc123", + "authorization": "Bearer some-token", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, "method": "GET", - "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + "url": "https://gitlab.com/api/v4/user", }, Object { - "body": "{\\"name\\":\\"renovateIgnoreApprovals\\",\\"approvals_required\\":0}", "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", - "authorization": "Bearer abc123", - "content-length": "57", - "content-type": "application/json", + "authorization": "Bearer some-token", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, - "method": "POST", - "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", + "method": "GET", + "url": "https://gitlab.com/api/v4/version", }, Object { + "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":\\"\\"}", "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", "authorization": "Bearer abc123", + "content-length": "142", + "content-type": "application/json", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, - "method": "GET", - "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests", }, Object { "headers": Object { @@ -491,73 +507,57 @@ Array [ "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, "method": "GET", - "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", }, Object { - "body": "{\\"should_remove_source_branch\\":true,\\"merge_when_pipeline_succeeds\\":true}", + "body": "{\\"name\\":\\"renovateIgnoreApprovals\\",\\"approvals_required\\":0}", "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", "authorization": "Bearer abc123", - "content-length": "72", + "content-length": "57", "content-type": "application/json", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, - "method": "PUT", - "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/merge", + "method": "POST", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/approval_rules", }, -] -`; - -exports[`platform/gitlab/index createPr(branchName, title, body) returns the PR 1`] = ` -Object { - "displayNumber": "Merge Request #12345", - "id": 1, - "iid": 12345, - "number": 12345, - "sourceBranch": "some-branch", - "title": "some title", -} -`; - -exports[`platform/gitlab/index createPr(branchName, title, body) returns the PR 2`] = ` -Array [ Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", - "authorization": "Bearer some-token", + "authorization": "Bearer abc123", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, "method": "GET", - "url": "https://gitlab.com/api/v4/user", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", }, Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", - "authorization": "Bearer some-token", + "authorization": "Bearer abc123", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, "method": "GET", - "url": "https://gitlab.com/api/v4/version", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345", }, Object { - "body": "{\\"source_branch\\":\\"some-branch\\",\\"target_branch\\":\\"master\\",\\"remove_source_branch\\":true,\\"title\\":\\"some-title\\",\\"description\\":\\"the-body\\",\\"labels\\":null}", + "body": "{\\"should_remove_source_branch\\":true,\\"merge_when_pipeline_succeeds\\":true}", "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate, br", "authorization": "Bearer abc123", - "content-length": "144", + "content-length": "72", "content-type": "application/json", "host": "gitlab.com", "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, - "method": "POST", - "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests", + "method": "PUT", + "url": "https://gitlab.com/api/v4/projects/undefined/merge_requests/12345/merge", }, ] `; diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 3eef7d4ee719d1..6f73e198b84aef 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -455,7 +455,7 @@ async function ignoreApprovals(pr: number): Promise { }); } } catch (err) { - logger.debug({ err }, 'GitLab: Error adding approval rule'); + logger.warn({ err }, 'GitLab: Error adding approval rule'); } } From d4442571c27d423db225eaa89dcbf77622f7b61d Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 27 Jul 2021 14:03:03 +0300 Subject: [PATCH 05/11] Fix --- lib/workers/pr/index.spec.ts | 2 ++ lib/workers/pr/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/workers/pr/index.spec.ts b/lib/workers/pr/index.spec.ts index 4d0e5f62ea85a0..9e4772a7092b09 100644 --- a/lib/workers/pr/index.spec.ts +++ b/lib/workers/pr/index.spec.ts @@ -628,11 +628,13 @@ describe(getName(), () => { it('should trigger GitLab automerge when configured', async () => { config.gitLabAutomerge = true; + config.gitLabIgnoreApprovals = true; config.automerge = true; await prWorker.ensurePr(config); const args = platform.createPr.mock.calls[0]; expect(args[0].platformOptions).toMatchObject({ gitLabAutomerge: true, + gitLabIgnoreApprovals: true, }); }); diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 652af411193ac6..68033b77f682aa 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -126,8 +126,8 @@ export function getPlatformPrOptions( config.gitLabAutomerge, }; - if (config.gitLabIgnoreApprovals) { - result.gitLabIgnoreApprovals = config.gitLabIgnoreApprovals; + if (config.gitLabIgnoreApprovals === true) { + result.gitLabIgnoreApprovals = true; } return result; From b68b1f30ee85472ad90dc46bfe2452c779004fa0 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 27 Jul 2021 15:16:03 +0300 Subject: [PATCH 06/11] Fix --- lib/workers/pr/__snapshots__/index.spec.ts.snap | 5 +++++ lib/workers/pr/index.ts | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/workers/pr/__snapshots__/index.spec.ts.snap b/lib/workers/pr/__snapshots__/index.spec.ts.snap index 19997363f4e8a0..8c734aeabab1d6 100644 --- a/lib/workers/pr/__snapshots__/index.spec.ts.snap +++ b/lib/workers/pr/__snapshots__/index.spec.ts.snap @@ -63,6 +63,7 @@ Array [ "azureWorkItemId": 0, "bbUseDefaultReviewers": true, "gitLabAutomerge": false, + "gitLabIgnoreApprovals": false, }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` |\\n\\nšŸ“Œ **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` to your config if you instead don't wish to pin dependencies.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" in timezone some timezone.\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, check this box.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", @@ -96,6 +97,7 @@ Array [ "azureWorkItemId": 0, "bbUseDefaultReviewers": true, "gitLabAutomerge": false, + "gitLabIgnoreApprovals": false, }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, check this box.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", @@ -116,6 +118,7 @@ Array [ "azureWorkItemId": 0, "bbUseDefaultReviewers": true, "gitLabAutomerge": false, + "gitLabIgnoreApprovals": false, }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [gitlabdummy](https://dummy.com) ([source](https://gitlab.com/renovateapp/gitlabdummy), [changelog](https://gitlab.com/renovateapp/gitlabdummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: \\"before 5am\\" (UTC).\\n\\nšŸš¦ **Automerge**: Enabled.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, check this box.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", @@ -136,6 +139,7 @@ Array [ "azureWorkItemId": 0, "bbUseDefaultReviewers": true, "gitLabAutomerge": false, + "gitLabIgnoreApprovals": false, }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are using the hosted GitLab app, please follow [this guide](https://docs.renovatebot.com/install-gitlab-app/#configuring-a-token-for-githubcom-hosted-release-notes). If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/self-hosting.md#githubcom-token-for-release-notes) instead.\\n\\nšŸ”” If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\nšŸ”§ This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n
\\nrenovateapp/dummy\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n
\\nrenovateapp/dummy\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\nšŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, check this box.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", @@ -156,6 +160,7 @@ Array [ "azureWorkItemId": 0, "bbUseDefaultReviewers": true, "gitLabAutomerge": false, + "gitLabIgnoreApprovals": false, }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n
\\nsomeproject\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n
\\n\\n---\\n\\n### Configuration\\n\\nšŸ“… **Schedule**: At any time (no schedule defined).\\n\\nšŸš¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\nā™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\nšŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] If you want to rebase/retry this PR, check this box.\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 68033b77f682aa..a05022d9d89563 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -115,7 +115,7 @@ export async function addAssigneesReviewers( export function getPlatformPrOptions( config: RenovateConfig & PlatformPrOptions ): PlatformPrOptions { - const result: PlatformPrOptions = { + return { azureAutoApprove: config.azureAutoApprove, azureAutoComplete: config.azureAutoComplete, azureWorkItemId: config.azureWorkItemId, @@ -124,13 +124,8 @@ export function getPlatformPrOptions( config.automerge && config.automergeType === 'pr' && config.gitLabAutomerge, + gitLabIgnoreApprovals: config.gitLabIgnoreApprovals, }; - - if (config.gitLabIgnoreApprovals === true) { - result.gitLabIgnoreApprovals = true; - } - - return result; } export type ResultWithPr = { From ef29c78bd32a39d6e7670c8893395b0fda258157 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Thu, 29 Jul 2021 21:59:48 +0200 Subject: [PATCH 07/11] Apply suggestions from code review Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/configuration-options.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 24907f87093161..03cdeb6ce491af 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -687,7 +687,8 @@ This is caused by a race condition in GitLab's Merge Request API - [read the cor ## gitLabIgnoreApprovals -Ignore default project level approvals, so that an automerge can be completed without those approvals. Under the hood, it creates MR-level approval rule with `approvals_required=0` parameter. +Ignore the default project level approval(s), so that Renovate bot can automerge its merge requests, without needing approval(s). +Under the hood, it creates a MR-level approval rule where `approvals_required` is set to `0`. ## golang From a56a26062ca17355bd85b32dfedc69d06597475d Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Fri, 30 Jul 2021 10:11:37 +0300 Subject: [PATCH 08/11] Add more doc --- docs/usage/configuration-options.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 3404d1293b678f..50c28417662ab3 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -709,6 +709,7 @@ This is caused by a race condition in GitLab's Merge Request API - [read the cor Ignore the default project level approval(s), so that Renovate bot can automerge its merge requests, without needing approval(s). Under the hood, it creates a MR-level approval rule where `approvals_required` is set to `0`. +This option works only when `automerge=true`, `automergeType=pr` and `gitLabAutomerge=true`. ## golang From 716edae8f5914b40a004f5e0ade7fc31ff686a6c Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 3 Aug 2021 08:16:56 +0300 Subject: [PATCH 09/11] Spell --- lib/platform/gitlab/__snapshots__/index.spec.ts.snap | 2 +- lib/platform/gitlab/index.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index f6b4d62434299a..5404a043b264bb 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -320,7 +320,7 @@ Array [ ] `; -exports[`platform/gitlab/index createPr(branchName, title, body) does not trying to create already existing approval rule 1`] = ` +exports[`platform/gitlab/index createPr(branchName, title, body) does not try to create already existing approval rule 1`] = ` Array [ Object { "headers": Object { diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 6cc6f37facb938..f778cddaf3b03e 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -1403,7 +1403,7 @@ describe(getName(), () => { expect(httpMock.getTrace()).toMatchSnapshot(); }); - it('does not trying to create already existing approval rule', async () => { + it('does not try to create already existing approval rule', async () => { await initPlatform('13.3.6-ee'); httpMock .scope(gitlabApiHost) From 114aff6773fd66f536733335789316ed72467ee9 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Wed, 4 Aug 2021 09:53:05 +0300 Subject: [PATCH 10/11] Update doc --- docs/usage/configuration-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 50c28417662ab3..e3dccf64d6f919 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -709,7 +709,7 @@ This is caused by a race condition in GitLab's Merge Request API - [read the cor Ignore the default project level approval(s), so that Renovate bot can automerge its merge requests, without needing approval(s). Under the hood, it creates a MR-level approval rule where `approvals_required` is set to `0`. -This option works only when `automerge=true`, `automergeType=pr` and `gitLabAutomerge=true`. +This option works only when `automerge=true`, `automergeType=pr` and `gitLabAutomerge=true`. Also, approval rules ovveriding should not be [prevented in GitLab settings](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/settings.html#prevent-overrides-of-default-approvals). ## golang From 3523c6a930845efe37a6814f4cdb60699fa5c82f Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Wed, 4 Aug 2021 10:10:16 +0300 Subject: [PATCH 11/11] Update docs/usage/configuration-options.md Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/configuration-options.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index e3dccf64d6f919..d889328df0e85e 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -709,7 +709,8 @@ This is caused by a race condition in GitLab's Merge Request API - [read the cor Ignore the default project level approval(s), so that Renovate bot can automerge its merge requests, without needing approval(s). Under the hood, it creates a MR-level approval rule where `approvals_required` is set to `0`. -This option works only when `automerge=true`, `automergeType=pr` and `gitLabAutomerge=true`. Also, approval rules ovveriding should not be [prevented in GitLab settings](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/settings.html#prevent-overrides-of-default-approvals). +This option works only when `automerge=true`, `automergeType=pr` and `gitLabAutomerge=true`. +Also, approval rules overriding should not be [prevented in GitLab settings](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/settings.html#prevent-overrides-of-default-approvals). ## golang