mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
fix: better branch code coverage (#24276)
This commit is contained in:
parent
68438adfd0
commit
f0d676242a
15 changed files with 51 additions and 23 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -404,7 +404,7 @@ jobs:
|
||||||
- name: Check coverage threshold
|
- name: Check coverage threshold
|
||||||
run: |
|
run: |
|
||||||
pnpm nyc check-coverage -t ./coverage/nyc \
|
pnpm nyc check-coverage -t ./coverage/nyc \
|
||||||
--branches 99.4 \
|
--branches 99.57 \
|
||||||
--functions 100 \
|
--functions 100 \
|
||||||
--lines 100 \
|
--lines 100 \
|
||||||
--statements 100
|
--statements 100
|
||||||
|
|
|
@ -183,9 +183,9 @@ export function parsePreset(input: string): ParsedPreset {
|
||||||
throw new Error(PRESET_INVALID);
|
throw new Error(PRESET_INVALID);
|
||||||
}
|
}
|
||||||
({ repo, presetPath, presetName, tag } =
|
({ repo, presetPath, presetName, tag } =
|
||||||
nonScopedPresetWithSubdirRegex.exec(str)?.groups ?? {});
|
nonScopedPresetWithSubdirRegex.exec(str)!.groups!);
|
||||||
} else {
|
} else {
|
||||||
({ repo, presetName, tag } = gitPresetRegex.exec(str)?.groups ?? {});
|
({ repo, presetName, tag } = gitPresetRegex.exec(str)!.groups!);
|
||||||
|
|
||||||
if (presetSource === 'npm' && !repo.startsWith('renovate-config-')) {
|
if (presetSource === 'npm' && !repo.startsWith('renovate-config-')) {
|
||||||
repo = `renovate-config-${repo}`;
|
repo = `renovate-config-${repo}`;
|
||||||
|
|
|
@ -8,7 +8,7 @@ type OmitFn = (...args: any[]) => any;
|
||||||
*
|
*
|
||||||
* @example getCallSite() // => 'Object.<anonymous> (/path/to/file.js:10:15)'
|
* @example getCallSite() // => 'Object.<anonymous> (/path/to/file.js:10:15)'
|
||||||
*/
|
*/
|
||||||
function getCallSite(omitFn: OmitFn = getCallSite): string | null {
|
function getCallSite(omitFn: OmitFn): string | null {
|
||||||
const stackTraceLimitOrig = Error.stackTraceLimit;
|
const stackTraceLimitOrig = Error.stackTraceLimit;
|
||||||
const prepareStackTraceOrig = Error.prepareStackTrace;
|
const prepareStackTraceOrig = Error.prepareStackTrace;
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,12 @@ export async function getDependency(
|
||||||
.plus({ minutes: cacheMinutes })
|
.plus({ minutes: cacheMinutes })
|
||||||
.toISO()!;
|
.toISO()!;
|
||||||
let cacheHardTtlMinutes = GlobalConfig.get('cacheHardTtlMinutes');
|
let cacheHardTtlMinutes = GlobalConfig.get('cacheHardTtlMinutes');
|
||||||
if (!(is.number(cacheHardTtlMinutes) && cacheHardTtlMinutes > cacheMinutes)) {
|
if (
|
||||||
|
!(
|
||||||
|
is.number(cacheHardTtlMinutes) &&
|
||||||
|
/* istanbul ignore next: needs test */ cacheHardTtlMinutes > cacheMinutes
|
||||||
|
)
|
||||||
|
) {
|
||||||
cacheHardTtlMinutes = cacheMinutes;
|
cacheHardTtlMinutes = cacheMinutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +209,9 @@ export async function getDependency(
|
||||||
cacheNamespace,
|
cacheNamespace,
|
||||||
packageUrl,
|
packageUrl,
|
||||||
{ ...dep, cacheData },
|
{ ...dep, cacheData },
|
||||||
etag ? cacheHardTtlMinutes : cacheMinutes
|
etag
|
||||||
|
? /* istanbul ignore next: needs test */ cacheHardTtlMinutes
|
||||||
|
: cacheMinutes
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
dep.isPrivate = true;
|
dep.isPrivate = true;
|
||||||
|
|
|
@ -63,7 +63,9 @@ export async function getResourceUrl(
|
||||||
({ type, version }) => type === resourceType && semver.valid(version)
|
({ type, version }) => type === resourceType && semver.valid(version)
|
||||||
)
|
)
|
||||||
.sort((x, y) =>
|
.sort((x, y) =>
|
||||||
x.version && y.version ? semver.compare(x.version, y.version) : 0
|
x.version && y.version
|
||||||
|
? semver.compare(x.version, y.version)
|
||||||
|
: /* istanbul ignore next: hard to test */ 0
|
||||||
);
|
);
|
||||||
const { serviceId, version } = services.pop()!;
|
const { serviceId, version } = services.pop()!;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { getRepoStatus } from '../../../util/git';
|
||||||
import * as hostRules from '../../../util/host-rules';
|
import * as hostRules from '../../../util/host-rules';
|
||||||
import { regEx } from '../../../util/regex';
|
import { regEx } from '../../../util/regex';
|
||||||
import { Json } from '../../../util/schema-utils';
|
import { Json } from '../../../util/schema-utils';
|
||||||
|
import { coerceString } from '../../../util/string';
|
||||||
import { GitTagsDatasource } from '../../datasource/git-tags';
|
import { GitTagsDatasource } from '../../datasource/git-tags';
|
||||||
import { PackagistDatasource } from '../../datasource/packagist';
|
import { PackagistDatasource } from '../../datasource/packagist';
|
||||||
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
|
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
|
||||||
|
@ -71,7 +72,7 @@ function getAuthJson(): string | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gitlabHostRule?.token) {
|
if (gitlabHostRule?.token) {
|
||||||
const host = gitlabHostRule.resolvedHost ?? 'gitlab.com';
|
const host = coerceString(gitlabHostRule.resolvedHost, 'gitlab.com');
|
||||||
authJson['gitlab-token'] = authJson['gitlab-token'] ?? {};
|
authJson['gitlab-token'] = authJson['gitlab-token'] ?? {};
|
||||||
authJson['gitlab-token'][host] = gitlabHostRule.token;
|
authJson['gitlab-token'][host] = gitlabHostRule.token;
|
||||||
// https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token
|
// https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { GlobalConfig } from '../../../config/global';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import type { HostRuleSearchResult } from '../../../types';
|
import type { HostRuleSearchResult } from '../../../types';
|
||||||
import type { ToolConstraint } from '../../../util/exec/types';
|
import type { ToolConstraint } from '../../../util/exec/types';
|
||||||
|
import { coerceNumber } from '../../../util/number';
|
||||||
import { api, id as composerVersioningId } from '../../versioning/composer';
|
import { api, id as composerVersioningId } from '../../versioning/composer';
|
||||||
import type { UpdateArtifactsConfig } from '../types';
|
import type { UpdateArtifactsConfig } from '../types';
|
||||||
import type { Lockfile, PackageFile } from './schema';
|
import type { Lockfile, PackageFile } from './schema';
|
||||||
|
@ -78,8 +79,8 @@ export function extractConstraints(
|
||||||
const phpVersion = config?.platform.php;
|
const phpVersion = config?.platform.php;
|
||||||
if (phpVersion) {
|
if (phpVersion) {
|
||||||
const major = api.getMajor(phpVersion);
|
const major = api.getMajor(phpVersion);
|
||||||
const minor = api.getMinor(phpVersion) ?? 0;
|
const minor = coerceNumber(api.getMinor(phpVersion));
|
||||||
const patch = api.getPatch(phpVersion) ?? 0;
|
const patch = coerceNumber(api.getPatch(phpVersion));
|
||||||
res.php = `<=${major}.${minor}.${patch}`;
|
res.php = `<=${major}.${minor}.${patch}`;
|
||||||
} else if (require.php) {
|
} else if (require.php) {
|
||||||
res.php = require.php;
|
res.php = require.php;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import upath from 'upath';
|
||||||
import { GlobalConfig } from '../../../config/global';
|
import { GlobalConfig } from '../../../config/global';
|
||||||
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
|
import { coerceArray } from '../../../util/array';
|
||||||
import { exec } from '../../../util/exec';
|
import { exec } from '../../../util/exec';
|
||||||
import type { ExecOptions } from '../../../util/exec/types';
|
import type { ExecOptions } from '../../../util/exec/types';
|
||||||
import {
|
import {
|
||||||
|
@ -97,7 +98,9 @@ function useModcacherw(goVersion: string | undefined): boolean {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [, majorPart, minorPart] = regEx(/(\d+)\.(\d+)/).exec(goVersion) ?? [];
|
const [, majorPart, minorPart] = coerceArray(
|
||||||
|
regEx(/(\d+)\.(\d+)/).exec(goVersion)
|
||||||
|
);
|
||||||
const [major, minor] = [majorPart, minorPart].map((x) => parseInt(x, 10));
|
const [major, minor] = [majorPart, minorPart].map((x) => parseInt(x, 10));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -196,7 +199,9 @@ export async function updateArtifacts({
|
||||||
GONOSUMDB: process.env.GONOSUMDB,
|
GONOSUMDB: process.env.GONOSUMDB,
|
||||||
GOSUMDB: process.env.GOSUMDB,
|
GOSUMDB: process.env.GOSUMDB,
|
||||||
GOINSECURE: process.env.GOINSECURE,
|
GOINSECURE: process.env.GOINSECURE,
|
||||||
GOFLAGS: useModcacherw(goConstraints) ? '-modcacherw' : null,
|
GOFLAGS: useModcacherw(goConstraints)
|
||||||
|
? '-modcacherw'
|
||||||
|
: /* istanbul ignore next: hard to test */ null,
|
||||||
CGO_ENABLED: GlobalConfig.get('binarySource') === 'docker' ? '0' : null,
|
CGO_ENABLED: GlobalConfig.get('binarySource') === 'docker' ? '0' : null,
|
||||||
...getGitEnvironmentVariables(['go']),
|
...getGitEnvironmentVariables(['go']),
|
||||||
},
|
},
|
||||||
|
@ -342,7 +347,7 @@ export async function updateArtifacts({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const f of status.deleted || []) {
|
for (const f of coerceArray(status.deleted)) {
|
||||||
res.push({
|
res.push({
|
||||||
file: {
|
file: {
|
||||||
type: 'deletion',
|
type: 'deletion',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { coerceArray } from '../../../util/array';
|
||||||
import { newlineRegex, regEx } from '../../../util/regex';
|
import { newlineRegex, regEx } from '../../../util/regex';
|
||||||
import { ClojureDatasource } from '../../datasource/clojure';
|
import { ClojureDatasource } from '../../datasource/clojure';
|
||||||
import type { PackageDependency, PackageFileContent } from '../types';
|
import type { PackageDependency, PackageFileContent } from '../types';
|
||||||
|
@ -139,8 +140,9 @@ function extractLeinRepos(content: string): string[] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const repoSectionContent = repoContent.slice(0, endIdx);
|
const repoSectionContent = repoContent.slice(0, endIdx);
|
||||||
const matches =
|
const matches = coerceArray(
|
||||||
repoSectionContent.match(regEx(/"https?:\/\/[^"]*"/g)) ?? [];
|
repoSectionContent.match(regEx(/"https?:\/\/[^"]*"/g))
|
||||||
|
);
|
||||||
const urls = matches.map((x) =>
|
const urls = matches.map((x) =>
|
||||||
x.replace(regEx(/^"/), '').replace(regEx(/"$/), '')
|
x.replace(regEx(/^"/), '').replace(regEx(/"$/), '')
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { coerceArray } from '../../../util/array';
|
||||||
import { newlineRegex, regEx } from '../../../util/regex';
|
import { newlineRegex, regEx } from '../../../util/regex';
|
||||||
import type { PuppetfileModule } from './types';
|
import type { PuppetfileModule } from './types';
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ export class Puppetfile {
|
||||||
): PuppetfileModule[] {
|
): PuppetfileModule[] {
|
||||||
const modules = this.forgeModules.get(forgeUrl ?? null);
|
const modules = this.forgeModules.get(forgeUrl ?? null);
|
||||||
|
|
||||||
return modules ?? [];
|
return coerceArray(modules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class HermitVersioning extends RegExpVersioningApi {
|
||||||
compatibility,
|
compatibility,
|
||||||
} = groups;
|
} = groups;
|
||||||
const release = [
|
const release = [
|
||||||
typeof major === 'undefined' ? 0 : Number.parseInt(major, 10),
|
Number.parseInt(major, 10),
|
||||||
typeof minor === 'undefined' ? 0 : Number.parseInt(minor, 10),
|
typeof minor === 'undefined' ? 0 : Number.parseInt(minor, 10),
|
||||||
typeof patch === 'undefined' ? 0 : Number.parseInt(patch, 10),
|
typeof patch === 'undefined' ? 0 : Number.parseInt(patch, 10),
|
||||||
typeof supplement === 'undefined' ? 0 : Number.parseInt(supplement, 10),
|
typeof supplement === 'undefined' ? 0 : Number.parseInt(supplement, 10),
|
||||||
|
|
|
@ -76,5 +76,8 @@ export function jsonStripWhitespaces(json: string | null): string | null {
|
||||||
*
|
*
|
||||||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#parameters
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#parameters
|
||||||
*/
|
*/
|
||||||
return quickStringify(JSON5.parse(json)) ?? null;
|
return (
|
||||||
|
quickStringify(JSON5.parse(json)) ??
|
||||||
|
/* istanbul ignore next: should never happen */ null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import type { PackageFile } from '../../modules/manager/types';
|
||||||
import { platform } from '../../modules/platform';
|
import { platform } from '../../modules/platform';
|
||||||
import { GitHubMaxPrBodyLen } from '../../modules/platform/github';
|
import { GitHubMaxPrBodyLen } from '../../modules/platform/github';
|
||||||
import { regEx } from '../../util/regex';
|
import { regEx } from '../../util/regex';
|
||||||
|
import { coerceString } from '../../util/string';
|
||||||
import * as template from '../../util/template';
|
import * as template from '../../util/template';
|
||||||
import type { BranchConfig, SelectAllConfig } from '../types';
|
import type { BranchConfig, SelectAllConfig } from '../types';
|
||||||
import { extractRepoProblems } from './common';
|
import { extractRepoProblems } from './common';
|
||||||
|
@ -76,8 +77,7 @@ function getAllSelectedBranches(
|
||||||
|
|
||||||
function getCheckedBranches(issueBody: string): Record<string, string> {
|
function getCheckedBranches(issueBody: string): Record<string, string> {
|
||||||
let dependencyDashboardChecks: Record<string, string> = {};
|
let dependencyDashboardChecks: Record<string, string> = {};
|
||||||
for (const [, type, branchName] of issueBody?.matchAll(markedBranchesRe) ??
|
for (const [, type, branchName] of issueBody.matchAll(markedBranchesRe)) {
|
||||||
[]) {
|
|
||||||
dependencyDashboardChecks[branchName] = type;
|
dependencyDashboardChecks[branchName] = type;
|
||||||
}
|
}
|
||||||
dependencyDashboardChecks = getAllSelectedBranches(
|
dependencyDashboardChecks = getAllSelectedBranches(
|
||||||
|
@ -427,7 +427,7 @@ export async function ensureDependencyDashboard(
|
||||||
);
|
);
|
||||||
if (updatedIssue) {
|
if (updatedIssue) {
|
||||||
const { dependencyDashboardChecks } = parseDashboardIssue(
|
const { dependencyDashboardChecks } = parseDashboardIssue(
|
||||||
updatedIssue.body ?? ''
|
coerceString(updatedIssue.body)
|
||||||
);
|
);
|
||||||
for (const branchName of Object.keys(config.dependencyDashboardChecks!)) {
|
for (const branchName of Object.keys(config.dependencyDashboardChecks!)) {
|
||||||
delete dependencyDashboardChecks[branchName];
|
delete dependencyDashboardChecks[branchName];
|
||||||
|
|
|
@ -331,5 +331,10 @@ describe('workers/repository/errors-warnings', () => {
|
||||||
const res = getDepWarningsOnboardingPR(packageFiles, config);
|
const res = getDepWarningsOnboardingPR(packageFiles, config);
|
||||||
expect(res).toBe('');
|
expect(res).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles undefined', () => {
|
||||||
|
const res = getDepWarningsOnboardingPR(undefined as never, {});
|
||||||
|
expect(res).toBe('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import type { RenovateConfig } from '../../config/types';
|
import type { RenovateConfig } from '../../config/types';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import type { PackageFile } from '../../modules/manager/types';
|
import type { PackageFile } from '../../modules/manager/types';
|
||||||
|
import { coerceArray } from '../../util/array';
|
||||||
import { emojify } from '../../util/emoji';
|
import { emojify } from '../../util/emoji';
|
||||||
import { regEx } from '../../util/regex';
|
import { regEx } from '../../util/regex';
|
||||||
import type { DepWarnings } from '../types';
|
import type { DepWarnings } from '../types';
|
||||||
|
@ -41,8 +42,8 @@ function getDepWarnings(
|
||||||
for (const file of files ?? []) {
|
for (const file of files ?? []) {
|
||||||
// TODO: remove condition when type is fixed (#22198)
|
// TODO: remove condition when type is fixed (#22198)
|
||||||
if (file.packageFile) {
|
if (file.packageFile) {
|
||||||
for (const dep of file.deps ?? []) {
|
for (const dep of coerceArray(file.deps)) {
|
||||||
for (const w of dep.warnings ?? []) {
|
for (const w of coerceArray(dep.warnings)) {
|
||||||
const message = w.message;
|
const message = w.message;
|
||||||
if (!warnings.includes(message)) {
|
if (!warnings.includes(message)) {
|
||||||
warnings.push(message);
|
warnings.push(message);
|
||||||
|
|
Loading…
Reference in a new issue