fix: packageFiles per baseBranch (#6136)

This commit is contained in:
Rhys Arkins 2020-05-05 19:46:35 +02:00 committed by GitHub
parent 2c3ba464a4
commit 2ff90b2396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 27 deletions

View file

@ -22,10 +22,7 @@ import {
PR_STATE_OPEN,
} from '../../constants/pull-requests';
import { logger } from '../../logger';
import {
AdditionalPackageFiles,
getAdditionalFiles,
} from '../../manager/npm/post-update';
import { getAdditionalFiles } from '../../manager/npm/post-update';
import { platform } from '../../platform';
import { BranchStatus } from '../../types';
import { emojify } from '../../util/emoji';
@ -55,8 +52,7 @@ function rebaseCheck(config: RenovateConfig, branchPr: any): boolean {
export async function processBranch(
branchConfig: BranchConfig,
prHourlyLimitReached?: boolean,
packageFiles?: AdditionalPackageFiles
prHourlyLimitReached?: boolean
): Promise<ProcessBranchResult> {
const config: BranchConfig = { ...branchConfig };
const dependencies = config.upgrades
@ -303,7 +299,10 @@ export async function processBranch(
} else {
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(
additionalFiles.artifactErrors
);

View file

@ -10,6 +10,7 @@ import {
ArtifactError,
LookupUpdate,
PackageDependency,
PackageFile,
} from '../manager/common';
import { File, PlatformPrOptions } from '../platform';
import { ChangeLogResult } from './pr/changelog/common';
@ -95,4 +96,5 @@ export interface BranchConfig
res?: ProcessBranchResult;
upgrades: BranchUpgradeConfig[];
packageFiles?: Record<string, PackageFile[]>;
}

View file

@ -33,7 +33,7 @@ export async function renovateRepository(
config = await initRepo(config);
const { branches, branchList, packageFiles } = await processRepo(config);
await ensureOnboardingPr(config, packageFiles, branches);
const res = await updateRepo(config, branches, branchList, packageFiles);
const res = await updateRepo(config, branches, branchList);
if (res !== 'automerged') {
await ensureMasterIssue(config, branches);
}

View file

@ -11,8 +11,8 @@ jest.mock('../extract');
const branchify = mocked(_branchify);
branchify.branchifyUpgrades.mockResolvedValueOnce({
branches: [],
branchList: [],
branches: [{ branchName: 'some-branch', upgrades: [] }],
branchList: ['branchName'],
});
describe('workers/repository/process/extract-update', () => {
@ -23,7 +23,7 @@ describe('workers/repository/process/extract-update', () => {
suppressNotifications: ['deprecationWarningIssues'],
};
const res = await extract(config);
await update(config, res.branches, res.branchList, res.packageFiles);
await update(config, res.branches);
});
});
});

View file

@ -64,14 +64,12 @@ export async function extract(config: RenovateConfig): Promise<ExtractResult> {
export async function update(
config: RenovateConfig,
branches: BranchConfig[],
branchList: string[],
packageFiles: Record<string, PackageFile[]>
branches: BranchConfig[]
): Promise<WriteUpdateResult | undefined> {
let res: WriteUpdateResult | undefined;
// istanbul ignore else
if (config.repoIsOnboarded) {
res = await writeUpdates(config, packageFiles, branches);
res = await writeUpdates(config, branches);
}
return res;

View file

@ -22,7 +22,7 @@ describe('workers/repository/process/index', () => {
extract.mockResolvedValue({} as never);
config.baseBranches = ['branch1', 'branch2'];
const res = await processRepo(config);
await updateRepo(config, res.branches, res.branchList, res.packageFiles);
await updateRepo(config, res.branches, res.branchList);
expect(res).toMatchSnapshot();
});
});

View file

@ -71,10 +71,9 @@ export async function processRepo(
export async function updateRepo(
config: RenovateConfig,
branches: BranchConfig[],
branchList: string[],
packageFiles?: Record<string, PackageFile[]>
branchList: string[]
): Promise<WriteUpdateResult | undefined> {
logger.debug('processRepo()');
return update(config, branches, branchList, packageFiles);
return update(config, branches);
}

View file

@ -19,14 +19,13 @@ beforeEach(() => {
describe('workers/repository/write', () => {
describe('writeUpdates()', () => {
const packageFiles = {};
it('skips branches blocked by pin', async () => {
const branches: BranchConfig[] = [
{ updateType: 'pin' },
{ blockedByPin: true },
{},
] as never;
const res = await writeUpdates(config, packageFiles, branches);
const res = await writeUpdates(config, branches);
expect(res).toEqual('done');
expect(branchWorker.processBranch).toHaveBeenCalledTimes(2);
});
@ -35,7 +34,7 @@ describe('workers/repository/write', () => {
branchWorker.processBranch.mockResolvedValueOnce('pr-created');
branchWorker.processBranch.mockResolvedValueOnce('already-existed');
branchWorker.processBranch.mockResolvedValueOnce('automerged');
const res = await writeUpdates(config, packageFiles, branches);
const res = await writeUpdates(config, branches);
expect(res).toEqual('automerged');
expect(branchWorker.processBranch).toHaveBeenCalledTimes(3);
});

View file

@ -1,7 +1,5 @@
import { RenovateConfig } from '../../../config';
import { addMeta, logger, removeMeta } from '../../../logger';
import { PackageFile } from '../../../manager/common';
import { AdditionalPackageFiles } from '../../../manager/npm/post-update';
import { processBranch } from '../../branch';
import { BranchConfig } from '../../common';
import { getLimitRemaining } from '../../global/limits';
@ -11,7 +9,6 @@ export type WriteUpdateResult = 'done' | 'automerged';
export async function writeUpdates(
config: RenovateConfig,
packageFiles: Record<string, PackageFile[]> | AdditionalPackageFiles,
allBranches: BranchConfig[]
): Promise<WriteUpdateResult> {
let branches = allBranches;
@ -35,8 +32,7 @@ export async function writeUpdates(
addMeta({ branch: branch.branchName });
const res = await processBranch(
branch,
prsRemaining <= 0 || getLimitRemaining('prCommitsPerRunLimit') <= 0,
packageFiles
prsRemaining <= 0 || getLimitRemaining('prCommitsPerRunLimit') <= 0
);
branch.res = res;
if (res === 'automerged' && config.automergeType !== 'pr-comment') {

View file

@ -150,6 +150,7 @@ export async function branchifyUpgrades(
);
const branch = generateBranchConfig(branchUpgrades[branchName]);
branch.branchName = branchName;
branch.packageFiles = packageFiles;
branches.push(branch);
}
removeMeta(['branch']);