diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 9101b42677705427ffb731439fdce91b3eb13519..5ff4585270b15ffc9320f200c7c4958691eced49 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -190,6 +190,10 @@ So for example you could choose to automerge all (passing) `devDependencies` onl } ``` +<!-- prettier-ignore --> +!!! note + Branches creation follows [`schedule`](#schedule) and the automerge follows [`automergeSchedule`](#automergeschedule). + <!-- prettier-ignore --> !!! warning "Negative reviews on GitHub block Renovate automerge" Renovate won't automerge on GitHub if a PR has a negative review. diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index ebb9d62ba954cff86c02a041168a3704a4764fc3..ba0f04efa426ebe9ba0bd08950c90bb19d131ac3 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -610,6 +610,29 @@ describe('workers/repository/update/branch/index', () => { }); }); + // automerge should respect only automergeSchedule + // mock a case where branchPr does not exist, pr-creation is off-schedule, and the branch is configured for automerge + it('automerges when there is no pr and, pr-creation is off-schedule', async () => { + schedule.isScheduledNow.mockReturnValueOnce(false); + getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce( + partial<PackageFilesResult>({ + updatedPackageFiles: [partial<FileChange>()], + }) + ); + npmPostExtract.getAdditionalFiles.mockResolvedValueOnce({ + artifactErrors: [], + updatedArtifacts: [partial<FileChange>()], + }); + scm.branchExists.mockResolvedValue(true); + commit.commitFilesToBranch.mockResolvedValueOnce(null); + automerge.tryBranchAutomerge.mockResolvedValueOnce('automerged'); + config.automerge = true; + config.automergeType = 'branch'; + await branchWorker.processBranch(config); + expect(automerge.tryBranchAutomerge).toHaveBeenCalledTimes(1); + expect(prWorker.ensurePr).toHaveBeenCalledTimes(0); + }); + it('returns if branch automerged', async () => { getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce( partial<PackageFilesResult>({ diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index 2b7b603b64ebb4b3f972cc4dca1f5a81aeaf94d8..4bacd8fe755c31a8c3e67be6e8b87a4c116d6640 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -309,8 +309,10 @@ export async function processBranch( result: 'update-not-scheduled', }; } - // istanbul ignore if - if (!branchPr) { + if ( + !branchPr && + !(config.automerge && config.automergeType === 'branch') // if branch is configured for automerge there's no need for a PR + ) { logger.debug('Skipping PR creation out of schedule'); return { branchExists,