Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validation): massage config #28458

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/workers/global/config/parse/util.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { logger } from '../../../../logger';
import { migrateAndValidateConfig } from './util';

describe('workers/global/config/parse/util', () => {
it('massages config', async () => {
const config = {
packageRules: [
{
description: 'haha',
matchPackageNames: ['name'],
enabled: false,
},
],
};

const migratedConfig = await migrateAndValidateConfig(config, 'global');
expect(migratedConfig?.packageRules?.[0].description).toBeArray();
expect(logger.warn).toHaveBeenCalledTimes(0);
});
});
11 changes: 9 additions & 2 deletions lib/workers/global/config/parse/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { dequal } from 'dequal';
import { massageConfig } from '../../../../config/massage';
import { migrateConfig } from '../../../../config/migration';
import type { RenovateConfig } from '../../../../config/types';
import { validateConfig } from '../../../../config/validation';
Expand All @@ -14,8 +16,13 @@ export async function migrateAndValidateConfig(
`${configType} needs migrating`,
);
}
const massagedConfig = massageConfig(migratedConfig);
// log only if it's changed
if (!dequal(migratedConfig, massagedConfig)) {
logger.debug({ config: massagedConfig }, 'Post-massage config');
rarkins marked this conversation as resolved.
Show resolved Hide resolved
}

const { warnings, errors } = await validateConfig('global', migratedConfig);
const { warnings, errors } = await validateConfig('global', massagedConfig);

if (warnings.length) {
logger.warn(
Expand All @@ -27,5 +34,5 @@ export async function migrateAndValidateConfig(
logger.warn({ errors }, `Config validation errors found in ${configType}`);
}

return migratedConfig;
return massagedConfig;
}