mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix(core/dashboard): GitHub error "maximum is 65536 characters" (#16208)
This commit is contained in:
parent
84228b1b12
commit
ee52021a9d
2 changed files with 47 additions and 1 deletions
|
@ -10,23 +10,54 @@ import {
|
|||
} from '../../../test/util';
|
||||
import { GlobalConfig } from '../../config/global';
|
||||
import { PlatformId } from '../../constants';
|
||||
import type {
|
||||
PackageDependency,
|
||||
PackageFile,
|
||||
} from '../../modules/manager/types';
|
||||
import type { Platform } from '../../modules/platform';
|
||||
import { massageMarkdown } from '../../modules/platform/github';
|
||||
import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types';
|
||||
import * as dependencyDashboard from './dependency-dashboard';
|
||||
import { PackageFiles } from './package-files';
|
||||
|
||||
type PrUpgrade = BranchUpgradeConfig;
|
||||
|
||||
const massageMdSpy = jest.spyOn(platform, 'massageMarkdown');
|
||||
let config: RenovateConfig;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
massageMdSpy.mockImplementation(massageMarkdown);
|
||||
config = getConfig();
|
||||
config.platform = PlatformId.Github;
|
||||
config.errors = [];
|
||||
config.warnings = [];
|
||||
});
|
||||
|
||||
function genRandString(length: number): string {
|
||||
let result = '';
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const charsLen = chars.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * charsLen));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function genRandPackageFile(
|
||||
depsNum: number,
|
||||
depNameLen: number
|
||||
): Record<string, PackageFile[]> {
|
||||
const deps: PackageDependency[] = [];
|
||||
for (let i = 0; i < depsNum; i++) {
|
||||
deps.push({
|
||||
depName: genRandString(depNameLen),
|
||||
currentVersion: '1.0.0',
|
||||
});
|
||||
}
|
||||
return { npm: [{ packageFile: 'package.json', deps }] };
|
||||
}
|
||||
|
||||
async function dryRun(
|
||||
branches: BranchConfig[],
|
||||
platform: jest.Mocked<Platform>,
|
||||
|
@ -666,6 +697,21 @@ describe('workers/repository/dependency-dashboard', () => {
|
|||
// same with dry run
|
||||
await dryRun(branches, platform);
|
||||
});
|
||||
|
||||
it('truncates the body of a really big repo', async () => {
|
||||
const branches: BranchConfig[] = [];
|
||||
const truncatedLength = 60000;
|
||||
const packageFilesBigRepo = genRandPackageFile(100, 700);
|
||||
PackageFiles.add('main', packageFilesBigRepo);
|
||||
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
||||
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
||||
expect(platform.ensureIssue.mock.calls[0][0].body).toHaveLength(
|
||||
truncatedLength
|
||||
);
|
||||
|
||||
// same with dry run
|
||||
await dryRun(branches, platform);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -358,7 +358,7 @@ export async function ensureDependencyDashboard(
|
|||
await platform.ensureIssue({
|
||||
title: config.dependencyDashboardTitle!,
|
||||
reuseTitle,
|
||||
body: issueBody,
|
||||
body: platform.massageMarkdown(issueBody),
|
||||
labels: config.dependencyDashboardLabels,
|
||||
confidential: config.confidential,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue