renovatebot/renovate

Evaluate pr/branch limits per-branch

Opened this issue · 1 comments

Describe the proposed change(s).

Current, limit are calculated prior to branch execution:

const prsRemaining = await getPrsRemaining(config, branches);
logger.debug(`Calculated maximum PRs remaining this run: ${prsRemaining}`);
setMaxLimit('PullRequests', prsRemaining);
const branchesRemaining = await getBranchesRemaining(config, branches);
logger.debug(
`Calculated maximum branches remaining this run: ${branchesRemaining}`,
);
setMaxLimit('Branches', branchesRemaining);

And evaluated within branch execution such as

if (
!branchExists &&
isLimitReached('Branches') &&
!dependencyDashboardCheck &&
!config.isVulnerabilityAlert
) {
logger.debug('Reached branch limit - skipping branch creation');
return {
branchExists,
prNo: branchPr?.number,
result: 'branch-limit-reached',
};
}

Much of the logic is also inside https://github.com/renovatebot/renovate/blob/main/lib/workers/repository/process/limits.ts

Instead of having global limits as today, we should instead allow separate limits per-branch, and evaluate those limits per-branch instead. This means removing these global limit settings:

And instead passing the relevant limit like prBranchLimit and prConcurrentLimit through to the "is limit reached?" functions.

Ideally the point in our workers where these limits are evaluated is kept the same as today so that there is "less changes" and risk of breaking things. And so the change is that the limits are passed through rather than used globally.

Note: commits will still be global