Merge branch 'master' into feat/6662-secrets

This commit is contained in:
Jamie Magee 2020-10-28 14:14:33 +01:00 коммит произвёл GitHub
Родитель d121746f8b 30f461f7d1
Коммит ff9e8455af
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 122 добавлений и 50 удалений

Просмотреть файл

@ -435,5 +435,26 @@ describe('config/migration', () => {
expect(res.isMigrated).toBe(false);
expect(res.migratedConfig).toMatchObject({ semanticCommits: 'disabled' });
});
it('it migrates preset strings to array', () => {
let config: RenovateConfig;
let res: MigratedConfig;
config = { extends: ':js-app' } as never;
res = configMigration.migrateConfig(config);
expect(res.isMigrated).toBe(true);
expect(res.migratedConfig).toMatchObject({ extends: ['config:js-app'] });
config = { extends: 'foo' } as never;
res = configMigration.migrateConfig(config);
expect(res.isMigrated).toBe(true);
expect(res.migratedConfig).toMatchObject({ extends: ['foo'] });
config = { extends: ['foo', ':js-app', 'bar'] } as never;
res = configMigration.migrateConfig(config);
expect(res.isMigrated).toBe(true);
expect(res.migratedConfig).toMatchObject({
extends: ['foo', 'config:js-app', 'bar'],
});
});
});
});

Просмотреть файл

@ -237,20 +237,29 @@ export function migrateConfig(
} else {
migratedConfig.semanticCommitScope = null;
}
} else if (key === 'extends' && is.array<string>(val)) {
for (let i = 0; i < val.length; i += 1) {
if (val[i] === 'config:application' || val[i] === ':js-app') {
isMigrated = true;
migratedConfig.extends[i] = 'config:js-app';
} else if (val[i] === ':library' || val[i] === 'config:library') {
isMigrated = true;
migratedConfig.extends[i] = 'config:js-lib';
} else if (is.string(val[i]) && val[i].startsWith(':masterIssue')) {
isMigrated = true;
migratedConfig.extends[i] = val[i].replace(
'masterIssue',
'dependencyDashboard'
);
} else if (
key === 'extends' &&
(is.array<string>(val) || is.string(val))
) {
if (is.string(migratedConfig.extends)) {
migratedConfig.extends = [migratedConfig.extends];
isMigrated = true;
}
const presets = migratedConfig.extends;
for (let i = 0; i < presets.length; i += 1) {
let preset = presets[i];
if (is.string(preset)) {
if (preset === 'config:application' || preset === ':js-app') {
isMigrated = true;
preset = 'config:js-app';
} else if (preset === ':library' || preset === 'config:library') {
isMigrated = true;
preset = 'config:js-lib';
} else if (preset.startsWith(':masterIssue')) {
isMigrated = true;
preset = preset.replace('masterIssue', 'dependencyDashboard');
}
presets[i] = preset;
}
}
} else if (key === 'versionScheme') {

Просмотреть файл

@ -434,5 +434,17 @@ describe('config/validation', () => {
expect(errors).toMatchSnapshot();
expect(warnings).toMatchSnapshot();
});
it('validates preset values', async () => {
const config = {
extends: ['foo', 'bar', 42] as never,
};
const { warnings, errors } = await configValidation.validateConfig(
config,
true
);
expect(warnings).toHaveLength(0);
expect(errors).toHaveLength(1);
});
});
});

Просмотреть файл

@ -214,17 +214,24 @@ export async function validateConfig(
if (key === 'extends') {
const tzRe = /^:timezone\((.+)\)$/;
for (const subval of val) {
if (is.string(subval) && tzRe.test(subval)) {
const [, timezone] = tzRe.exec(subval);
const [validTimezone, errorMessage] = hasValidTimezone(
timezone
);
if (!validTimezone) {
errors.push({
depName: 'Configuration Error',
message: `${currentPath}: ${errorMessage}`,
});
if (is.string(subval)) {
if (tzRe.test(subval)) {
const [, timezone] = tzRe.exec(subval);
const [validTimezone, errorMessage] = hasValidTimezone(
timezone
);
if (!validTimezone) {
errors.push({
depName: 'Configuration Error',
message: `${currentPath}: ${errorMessage}`,
});
}
}
} else {
errors.push({
depName: 'Configuration Warning',
message: `${currentPath}: preset value is not a string`,
});
}
}
}

Просмотреть файл

@ -74,15 +74,18 @@ export async function getResourceUrl(
resourceType === 'RegistrationsBaseUrl' &&
!semver.satisfies(version, '^3.0.0')
) {
logger.warn(`Nuget: RegistrationsBaseUrl/${version} is the major update`);
logger.warn(
{ url },
`Nuget: RegistrationsBaseUrl/${version} is the major update`
);
}
await packageCache.set(cacheNamespace, resultCacheKey, serviceId, 60);
return serviceId;
} catch (err) {
logger.debug(
{ err },
`nuget registry failure: can't get ${resourceType} form ${url}`
{ err, url },
`nuget registry failure: can't get ${resourceType}`
);
return null;
}

Просмотреть файл

@ -127,7 +127,9 @@ export function sanitizeValue(value: unknown, seen = new WeakMap()): any {
seen.set(value as any, objectResult);
for (const [key, val] of Object.entries<any>(value)) {
let curValue: any;
if (redactedFields.includes(key)) {
if (!val) {
curValue = val;
} else if (redactedFields.includes(key)) {
curValue = '***********';
} else if (contentFields.includes(key)) {
curValue = '[content]';

Просмотреть файл

@ -793,7 +793,10 @@ const platform: Platform = {
},
getPrBody(prBody: string): string {
return smartTruncate(prBody, 1000000);
return smartTruncate(
prBody.replace(/\]\(\.\.\/pull\//g, '](pulls/'),
1000000
);
},
getVulnerabilityAlerts(): Promise<VulnerabilityAlert[]> {

Просмотреть файл

@ -14,13 +14,13 @@ export function applyHostRules(url: string, inOptions: GotOptions): GotOptions {
}) || /* istanbul ignore next: can only happen in tests */ {};
const { username, password, token, enabled } = foundRules;
if (options.headers?.authorization || options.password || options.token) {
logger.trace(`Authorization already set for host: ${options.hostname}`);
logger.trace({ url }, `Authorization already set`);
} else if (password) {
logger.trace(`Applying Basic authentication for host ${options.hostname}`);
logger.trace({ url }, `Applying Basic authentication`);
options.username = username;
options.password = password;
} else if (token) {
logger.trace(`Applying Bearer authentication for host ${options.hostname}`);
logger.trace({ url }, `Applying Bearer authentication`);
options.token = token;
} else if (enabled === false) {
options.enabled = false;

Просмотреть файл

@ -479,6 +479,17 @@ describe('workers/pr', () => {
expect(reviewers).toHaveLength(2);
expect(config.reviewers).toEqual(expect.arrayContaining(reviewers));
});
it('should not add any assignees or reviewers to new PR', async () => {
config.assignees = ['foo', 'bar', 'baz'];
config.assigneesSampleSize = 0;
config.reviewers = ['baz', 'boo', 'bor'];
config.reviewersSampleSize = 0;
const { prResult, pr } = await prWorker.ensurePr(config);
expect(prResult).toEqual(PrResult.Created);
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
expect(platform.addAssignees).toHaveBeenCalledTimes(0);
expect(platform.addReviewers).toHaveBeenCalledTimes(0);
});
it('should add and deduplicate additionalReviewers on new PR', async () => {
config.reviewers = ['@foo', 'bar'];
config.additionalReviewers = ['bar', 'baz', '@boo'];

Просмотреть файл

@ -48,12 +48,14 @@ export async function addAssigneesReviewers(
if (config.assigneesSampleSize !== null) {
assignees = sampleSize(assignees, config.assigneesSampleSize);
}
// istanbul ignore if
if (config.dryRun) {
logger.info(`DRY-RUN: Would add assignees to PR #${pr.number}`);
} else {
await platform.addAssignees(pr.number, assignees);
logger.debug({ assignees }, 'Added assignees');
if (assignees.length > 0) {
// istanbul ignore if
if (config.dryRun) {
logger.info(`DRY-RUN: Would add assignees to PR #${pr.number}`);
} else {
await platform.addAssignees(pr.number, assignees);
logger.debug({ assignees }, 'Added assignees');
}
}
} catch (err) {
logger.debug(
@ -78,12 +80,14 @@ export async function addAssigneesReviewers(
if (config.reviewersSampleSize !== null) {
reviewers = sampleSize(reviewers, config.reviewersSampleSize);
}
// istanbul ignore if
if (config.dryRun) {
logger.info(`DRY-RUN: Would add reviewers to PR #${pr.number}`);
} else {
await platform.addReviewers(pr.number, reviewers);
logger.debug({ reviewers }, 'Added reviewers');
if (reviewers.length > 0) {
// istanbul ignore if
if (config.dryRun) {
logger.info(`DRY-RUN: Would add reviewers to PR #${pr.number}`);
} else {
await platform.addReviewers(pr.number, reviewers);
logger.debug({ reviewers }, 'Added reviewers');
}
}
} catch (err) {
logger.debug(

Просмотреть файл

@ -124,7 +124,7 @@
"chalk": "4.1.0",
"changelog-filename-regex": "2.0.1",
"clean-git-ref": "2.0.1",
"commander": "6.1.0",
"commander": "6.2.0",
"conventional-commits-detector": "1.0.3",
"deepmerge": "4.2.2",
"delay": "4.4.0",

Просмотреть файл

@ -5,7 +5,7 @@
"@actions/core": "1.2.6",
"@jest/reporters": "26.6.1",
"@jest/test-result": "26.6.1",
"commander": "6.1.0",
"commander": "6.2.0",
"eslint": "7.11.0",
"fs-extra": "9.0.1",
"got": "11.8.0",

Просмотреть файл

@ -3222,10 +3222,10 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"
commander@6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-6.1.0.tgz#f8d722b78103141006b66f4c7ba1e97315ba75bc"
integrity sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA==
commander@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75"
integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==
commander@^4.0.1:
version "4.1.1"