Skip to content

Commit

Permalink
feat(config)!: change onboardingNoDeps from boolean to enum (#28133)
Browse files Browse the repository at this point in the history
Change onboardingNoDeps from boolean to enum, with new default "auto". Auto means that Renovate will continue skipping repos with no dependencies if autodiscover is in use, but onboarding them if they are explicitly specified in a non-autodiscover mode.

Closes #28101

BREAKING CHANGE: onboardingNoDeps changes from boolean to enum. Repositories with no dependencies will be onboarded unless in autodiscover mode.
  • Loading branch information
RahulGautamSingh authored and rarkins committed May 4, 2024
1 parent 95ae815 commit 8063a25
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/usage/config-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ To get a onboarding PR from Renovate, change to Interactive mode either at the R

#### Installing Renovate into selected repositories always leads to onboarding PRs

Additionally, if an Organization is installed with "Selected repositories" then the app will change `onboardingNoDeps` to `true` so that an Onboarding PR is created even if no dependencies are detected.
Additionally, if an Organization is installed with "Selected repositories" then the app will change `onboardingNoDeps` to `"enabled"` so that an Onboarding PR is created even if no dependencies are detected.

### Fork Processing

Expand Down
8 changes: 6 additions & 2 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,12 @@ Falls back to `renovate.json` if the name provided is not valid.

## onboardingNoDeps

Set this to `true` if you want Renovate to create an onboarding PR even if no dependencies are found.
Otherwise, Renovate skips onboarding a repository if it finds no dependencies in it.
The default `auto` setting is converted to `disabled` if `autodiscoverRepositories` is `true`, or converted to `enabled` if false.

In other words, the default behavior is:

- If you run Renovate on discovered repositories then it will skip onboarding those without dependencies detected, but
- If you run Renovate on _specific_ repositories then Renovate will onboard all such repositories even if no dependencies are found

## onboardingPrTitle

Expand Down
5 changes: 3 additions & 2 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ const options: RenovateOptions[] = [
{
name: 'onboardingNoDeps',
description: 'Onboard the repository even if no dependencies are found.',
type: 'boolean',
default: false,
type: 'string',
default: 'auto',
allowedValues: ['auto', 'enabled', 'disabled'],
globalOnly: true,
inheritConfigSupport: true,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export interface LegacyAdminConfig {
onboarding?: boolean;
onboardingBranch?: string;
onboardingCommitMessage?: string;
onboardingNoDeps?: boolean;
onboardingNoDeps?: 'auto' | 'enabled' | 'disabled';
onboardingRebaseCheckbox?: boolean;
onboardingPrTitle?: string;
onboardingConfig?: RenovateSharedConfig;
Expand Down
13 changes: 13 additions & 0 deletions lib/workers/global/config/parse/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,18 @@ describe('workers/global/config/parse/index', () => {
const parsed = await configParser.parseConfigs(defaultEnv, defaultArgv);
expect(parsed).toContainEntries([['dryRun', null]]);
});

it('massage onboardingNoDeps when autodiscover is false', async () => {
jest.mock(
'../../config.js',
() => ({ onboardingNoDeps: 'auto', autodiscover: false }),
{
virtual: true,
},
);
const env: NodeJS.ProcessEnv = {};
const parsedConfig = await configParser.parseConfigs(env, defaultArgv);
expect(parsedConfig).toContainEntries([['onboardingNoDeps', 'enabled']]);
});
});
});
6 changes: 6 additions & 0 deletions lib/workers/global/config/parse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export async function parseConfigs(
config.forkProcessing = 'enabled';
}

// Massage onboardingNoDeps
if (!config.autodiscover && config.onboardingNoDeps !== 'disabled') {
logger.debug('Enabling onboardingNoDeps while in non-autodiscover mode');
config.onboardingNoDeps = 'enabled';
}

// Remove log file entries
delete config.logFile;
delete config.logFileLevel;
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/onboarding/branch/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('workers/repository/onboarding/branch/index', () => {
});

it("doesn't throw if there are no package files and onboardingNoDeps config option is set", async () => {
config.onboardingNoDeps = true;
config.onboardingNoDeps = 'enabled';
await expect(checkOnboardingBranch(config)).resolves.not.toThrow(
REPOSITORY_NO_PACKAGE_FILES,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/onboarding/branch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function checkOnboardingBranch(
Object.entries((await extractAllDependencies(mergedConfig)).packageFiles)
.length === 0
) {
if (!config?.onboardingNoDeps) {
if (config.onboardingNoDeps !== 'enabled') {
throw new Error(REPOSITORY_NO_PACKAGE_FILES);
}
}
Expand Down

0 comments on commit 8063a25

Please sign in to comment.