mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix: packageFiles per baseBranch (#6136)
This commit is contained in:
parent
2c3ba464a4
commit
2ff90b2396
10 changed files with 21 additions and 27 deletions
|
@ -22,10 +22,7 @@ import {
|
||||||
PR_STATE_OPEN,
|
PR_STATE_OPEN,
|
||||||
} from '../../constants/pull-requests';
|
} from '../../constants/pull-requests';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import {
|
import { getAdditionalFiles } from '../../manager/npm/post-update';
|
||||||
AdditionalPackageFiles,
|
|
||||||
getAdditionalFiles,
|
|
||||||
} from '../../manager/npm/post-update';
|
|
||||||
import { platform } from '../../platform';
|
import { platform } from '../../platform';
|
||||||
import { BranchStatus } from '../../types';
|
import { BranchStatus } from '../../types';
|
||||||
import { emojify } from '../../util/emoji';
|
import { emojify } from '../../util/emoji';
|
||||||
|
@ -55,8 +52,7 @@ function rebaseCheck(config: RenovateConfig, branchPr: any): boolean {
|
||||||
|
|
||||||
export async function processBranch(
|
export async function processBranch(
|
||||||
branchConfig: BranchConfig,
|
branchConfig: BranchConfig,
|
||||||
prHourlyLimitReached?: boolean,
|
prHourlyLimitReached?: boolean
|
||||||
packageFiles?: AdditionalPackageFiles
|
|
||||||
): Promise<ProcessBranchResult> {
|
): Promise<ProcessBranchResult> {
|
||||||
const config: BranchConfig = { ...branchConfig };
|
const config: BranchConfig = { ...branchConfig };
|
||||||
const dependencies = config.upgrades
|
const dependencies = config.upgrades
|
||||||
|
@ -303,7 +299,10 @@ export async function processBranch(
|
||||||
} else {
|
} else {
|
||||||
logger.debug('No package files need updating');
|
logger.debug('No package files need updating');
|
||||||
}
|
}
|
||||||
const additionalFiles = await getAdditionalFiles(config, packageFiles);
|
const additionalFiles = await getAdditionalFiles(
|
||||||
|
config,
|
||||||
|
branchConfig.packageFiles
|
||||||
|
);
|
||||||
config.artifactErrors = (config.artifactErrors || []).concat(
|
config.artifactErrors = (config.artifactErrors || []).concat(
|
||||||
additionalFiles.artifactErrors
|
additionalFiles.artifactErrors
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
ArtifactError,
|
ArtifactError,
|
||||||
LookupUpdate,
|
LookupUpdate,
|
||||||
PackageDependency,
|
PackageDependency,
|
||||||
|
PackageFile,
|
||||||
} from '../manager/common';
|
} from '../manager/common';
|
||||||
import { File, PlatformPrOptions } from '../platform';
|
import { File, PlatformPrOptions } from '../platform';
|
||||||
import { ChangeLogResult } from './pr/changelog/common';
|
import { ChangeLogResult } from './pr/changelog/common';
|
||||||
|
@ -95,4 +96,5 @@ export interface BranchConfig
|
||||||
|
|
||||||
res?: ProcessBranchResult;
|
res?: ProcessBranchResult;
|
||||||
upgrades: BranchUpgradeConfig[];
|
upgrades: BranchUpgradeConfig[];
|
||||||
|
packageFiles?: Record<string, PackageFile[]>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ export async function renovateRepository(
|
||||||
config = await initRepo(config);
|
config = await initRepo(config);
|
||||||
const { branches, branchList, packageFiles } = await processRepo(config);
|
const { branches, branchList, packageFiles } = await processRepo(config);
|
||||||
await ensureOnboardingPr(config, packageFiles, branches);
|
await ensureOnboardingPr(config, packageFiles, branches);
|
||||||
const res = await updateRepo(config, branches, branchList, packageFiles);
|
const res = await updateRepo(config, branches, branchList);
|
||||||
if (res !== 'automerged') {
|
if (res !== 'automerged') {
|
||||||
await ensureMasterIssue(config, branches);
|
await ensureMasterIssue(config, branches);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ jest.mock('../extract');
|
||||||
const branchify = mocked(_branchify);
|
const branchify = mocked(_branchify);
|
||||||
|
|
||||||
branchify.branchifyUpgrades.mockResolvedValueOnce({
|
branchify.branchifyUpgrades.mockResolvedValueOnce({
|
||||||
branches: [],
|
branches: [{ branchName: 'some-branch', upgrades: [] }],
|
||||||
branchList: [],
|
branchList: ['branchName'],
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('workers/repository/process/extract-update', () => {
|
describe('workers/repository/process/extract-update', () => {
|
||||||
|
@ -23,7 +23,7 @@ describe('workers/repository/process/extract-update', () => {
|
||||||
suppressNotifications: ['deprecationWarningIssues'],
|
suppressNotifications: ['deprecationWarningIssues'],
|
||||||
};
|
};
|
||||||
const res = await extract(config);
|
const res = await extract(config);
|
||||||
await update(config, res.branches, res.branchList, res.packageFiles);
|
await update(config, res.branches);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,14 +64,12 @@ export async function extract(config: RenovateConfig): Promise<ExtractResult> {
|
||||||
|
|
||||||
export async function update(
|
export async function update(
|
||||||
config: RenovateConfig,
|
config: RenovateConfig,
|
||||||
branches: BranchConfig[],
|
branches: BranchConfig[]
|
||||||
branchList: string[],
|
|
||||||
packageFiles: Record<string, PackageFile[]>
|
|
||||||
): Promise<WriteUpdateResult | undefined> {
|
): Promise<WriteUpdateResult | undefined> {
|
||||||
let res: WriteUpdateResult | undefined;
|
let res: WriteUpdateResult | undefined;
|
||||||
// istanbul ignore else
|
// istanbul ignore else
|
||||||
if (config.repoIsOnboarded) {
|
if (config.repoIsOnboarded) {
|
||||||
res = await writeUpdates(config, packageFiles, branches);
|
res = await writeUpdates(config, branches);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('workers/repository/process/index', () => {
|
||||||
extract.mockResolvedValue({} as never);
|
extract.mockResolvedValue({} as never);
|
||||||
config.baseBranches = ['branch1', 'branch2'];
|
config.baseBranches = ['branch1', 'branch2'];
|
||||||
const res = await processRepo(config);
|
const res = await processRepo(config);
|
||||||
await updateRepo(config, res.branches, res.branchList, res.packageFiles);
|
await updateRepo(config, res.branches, res.branchList);
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -71,10 +71,9 @@ export async function processRepo(
|
||||||
export async function updateRepo(
|
export async function updateRepo(
|
||||||
config: RenovateConfig,
|
config: RenovateConfig,
|
||||||
branches: BranchConfig[],
|
branches: BranchConfig[],
|
||||||
branchList: string[],
|
branchList: string[]
|
||||||
packageFiles?: Record<string, PackageFile[]>
|
|
||||||
): Promise<WriteUpdateResult | undefined> {
|
): Promise<WriteUpdateResult | undefined> {
|
||||||
logger.debug('processRepo()');
|
logger.debug('processRepo()');
|
||||||
|
|
||||||
return update(config, branches, branchList, packageFiles);
|
return update(config, branches);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,13 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('workers/repository/write', () => {
|
describe('workers/repository/write', () => {
|
||||||
describe('writeUpdates()', () => {
|
describe('writeUpdates()', () => {
|
||||||
const packageFiles = {};
|
|
||||||
it('skips branches blocked by pin', async () => {
|
it('skips branches blocked by pin', async () => {
|
||||||
const branches: BranchConfig[] = [
|
const branches: BranchConfig[] = [
|
||||||
{ updateType: 'pin' },
|
{ updateType: 'pin' },
|
||||||
{ blockedByPin: true },
|
{ blockedByPin: true },
|
||||||
{},
|
{},
|
||||||
] as never;
|
] as never;
|
||||||
const res = await writeUpdates(config, packageFiles, branches);
|
const res = await writeUpdates(config, branches);
|
||||||
expect(res).toEqual('done');
|
expect(res).toEqual('done');
|
||||||
expect(branchWorker.processBranch).toHaveBeenCalledTimes(2);
|
expect(branchWorker.processBranch).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
@ -35,7 +34,7 @@ describe('workers/repository/write', () => {
|
||||||
branchWorker.processBranch.mockResolvedValueOnce('pr-created');
|
branchWorker.processBranch.mockResolvedValueOnce('pr-created');
|
||||||
branchWorker.processBranch.mockResolvedValueOnce('already-existed');
|
branchWorker.processBranch.mockResolvedValueOnce('already-existed');
|
||||||
branchWorker.processBranch.mockResolvedValueOnce('automerged');
|
branchWorker.processBranch.mockResolvedValueOnce('automerged');
|
||||||
const res = await writeUpdates(config, packageFiles, branches);
|
const res = await writeUpdates(config, branches);
|
||||||
expect(res).toEqual('automerged');
|
expect(res).toEqual('automerged');
|
||||||
expect(branchWorker.processBranch).toHaveBeenCalledTimes(3);
|
expect(branchWorker.processBranch).toHaveBeenCalledTimes(3);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { RenovateConfig } from '../../../config';
|
import { RenovateConfig } from '../../../config';
|
||||||
import { addMeta, logger, removeMeta } from '../../../logger';
|
import { addMeta, logger, removeMeta } from '../../../logger';
|
||||||
import { PackageFile } from '../../../manager/common';
|
|
||||||
import { AdditionalPackageFiles } from '../../../manager/npm/post-update';
|
|
||||||
import { processBranch } from '../../branch';
|
import { processBranch } from '../../branch';
|
||||||
import { BranchConfig } from '../../common';
|
import { BranchConfig } from '../../common';
|
||||||
import { getLimitRemaining } from '../../global/limits';
|
import { getLimitRemaining } from '../../global/limits';
|
||||||
|
@ -11,7 +9,6 @@ export type WriteUpdateResult = 'done' | 'automerged';
|
||||||
|
|
||||||
export async function writeUpdates(
|
export async function writeUpdates(
|
||||||
config: RenovateConfig,
|
config: RenovateConfig,
|
||||||
packageFiles: Record<string, PackageFile[]> | AdditionalPackageFiles,
|
|
||||||
allBranches: BranchConfig[]
|
allBranches: BranchConfig[]
|
||||||
): Promise<WriteUpdateResult> {
|
): Promise<WriteUpdateResult> {
|
||||||
let branches = allBranches;
|
let branches = allBranches;
|
||||||
|
@ -35,8 +32,7 @@ export async function writeUpdates(
|
||||||
addMeta({ branch: branch.branchName });
|
addMeta({ branch: branch.branchName });
|
||||||
const res = await processBranch(
|
const res = await processBranch(
|
||||||
branch,
|
branch,
|
||||||
prsRemaining <= 0 || getLimitRemaining('prCommitsPerRunLimit') <= 0,
|
prsRemaining <= 0 || getLimitRemaining('prCommitsPerRunLimit') <= 0
|
||||||
packageFiles
|
|
||||||
);
|
);
|
||||||
branch.res = res;
|
branch.res = res;
|
||||||
if (res === 'automerged' && config.automergeType !== 'pr-comment') {
|
if (res === 'automerged' && config.automergeType !== 'pr-comment') {
|
||||||
|
|
|
@ -150,6 +150,7 @@ export async function branchifyUpgrades(
|
||||||
);
|
);
|
||||||
const branch = generateBranchConfig(branchUpgrades[branchName]);
|
const branch = generateBranchConfig(branchUpgrades[branchName]);
|
||||||
branch.branchName = branchName;
|
branch.branchName = branchName;
|
||||||
|
branch.packageFiles = packageFiles;
|
||||||
branches.push(branch);
|
branches.push(branch);
|
||||||
}
|
}
|
||||||
removeMeta(['branch']);
|
removeMeta(['branch']);
|
||||||
|
|
Loading…
Reference in a new issue