diff --git a/lib/api/github.js b/lib/api/github.js index ff4f35659d54e935248ef64cfb3b51b71c682d71..c66498b2de1a78219b7605e2cfd0aae40027afa0 100644 --- a/lib/api/github.js +++ b/lib/api/github.js @@ -592,7 +592,7 @@ async function mergePr(pr) { await ghGotRetry.put(url, options); } catch (err) { logger.error({ err }, `Failed to ${options.body.merge_method} PR`); - return; + return false; } } else { // We need to guess the merge method and try squash -> rebase -> merge @@ -621,7 +621,7 @@ async function mergePr(pr) { `Failed to ${options.body.merge_method} PR` ); logger.warn({ pr: pr.number }, 'All merge attempts failed'); - return; + return false; } } } @@ -630,6 +630,7 @@ async function mergePr(pr) { config.baseCommitSHA = await getBranchCommit(config.baseBranch); // Delete branch await deleteBranch(pr.head.ref); + return true; } // Generic File operations diff --git a/lib/api/gitlab.js b/lib/api/gitlab.js index 3d78ba50cf354b49847f3cfe6f8e7696bf1ca709..2094654479cd4f4172a76b33afa485b2793b520a 100644 --- a/lib/api/gitlab.js +++ b/lib/api/gitlab.js @@ -408,6 +408,7 @@ async function mergePr(pr) { }, } ); + return true; } // Generic File operations diff --git a/lib/workers/pr/index.js b/lib/workers/pr/index.js index eea336d0ef1376d8527c24bb619a0bca904b4aff..2f8d9c4bda9a08a58eca87a62bae378e79e746d3 100644 --- a/lib/workers/pr/index.js +++ b/lib/workers/pr/index.js @@ -230,8 +230,7 @@ async function checkAutoMerge(pr, config) { } // Let's merge this logger.info(`Automerging #${pr.number}`); - await config.api.mergePr(pr); - return true; + return config.api.mergePr(pr); } logger.debug('No automerge'); return false; diff --git a/test/api/github.spec.js b/test/api/github.spec.js index aa9282fe3244d61458867c521f762c40f2532dcb..d70a024eea801ca7834fb476515c9c1cc6aec96d 100644 --- a/test/api/github.spec.js +++ b/test/api/github.spec.js @@ -1317,7 +1317,7 @@ describe('api/github', () => { ref: 'someref', }, }; - await github.mergePr(pr); + expect(await github.mergePr(pr)).toBe(true); expect(ghGot.put.mock.calls).toHaveLength(1); expect(ghGot.delete.mock.calls).toHaveLength(1); expect(ghGot.mock.calls).toHaveLength(4); @@ -1335,7 +1335,7 @@ describe('api/github', () => { ghGot.put.mockImplementationOnce(() => { throw new Error('merge error'); }); - await github.mergePr(pr); + expect(await github.mergePr(pr)).toBe(false); expect(ghGot.put.mock.calls).toHaveLength(1); expect(ghGot.delete.mock.calls).toHaveLength(0); expect(ghGot.mock.calls).toHaveLength(3); @@ -1389,7 +1389,7 @@ describe('api/github', () => { ref: 'someref', }, }; - await github.mergePr(pr); + expect(await github.mergePr(pr)).toBe(true); expect(ghGot.put.mock.calls).toHaveLength(1); expect(ghGot.delete.mock.calls).toHaveLength(1); }); @@ -1420,7 +1420,7 @@ describe('api/github', () => { ghGot.put.mockImplementationOnce(() => { throw new Error('no squashing allowed'); }); - await github.mergePr(pr); + expect(await github.mergePr(pr)).toBe(true); expect(ghGot.put.mock.calls).toHaveLength(3); expect(ghGot.delete.mock.calls).toHaveLength(1); }); @@ -1440,7 +1440,7 @@ describe('api/github', () => { ghGot.put.mockImplementationOnce(() => { throw new Error('no merging allowed'); }); - await github.mergePr(pr); + expect(await github.mergePr(pr)).toBe(false); expect(ghGot.put.mock.calls).toHaveLength(3); expect(ghGot.delete.mock.calls).toHaveLength(0); });