Skip to content

Commit

Permalink
Merge branch 'main' into feat/10641-pgp
Browse files Browse the repository at this point in the history
# Conflicts:
#	yarn.lock
  • Loading branch information
rarkins committed Sep 14, 2021
2 parents 84207bc + 45d1aee commit 67c1d20
Show file tree
Hide file tree
Showing 57 changed files with 1,480 additions and 1,467 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-pr.yml
Expand Up @@ -54,7 +54,7 @@ jobs:
run: yarn jest --maxWorkers=2 --ci

- name: Codecov
uses: codecov/codecov-action@5a8bb4701eca7ba3673f21664b887f652c58d0a3 # renovate: tag=v2.0.3
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # renovate: tag=v2.1.0
if: always()

# build after tests to exclude files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -87,7 +87,7 @@ jobs:
run: yarn jest --maxWorkers=2 --ci --coverage ${{ env.coverage }}

- name: Codecov
uses: codecov/codecov-action@5a8bb4701eca7ba3673f21664b887f652c58d0a3 # renovate: tag=v2.0.3
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # renovate: tag=v2.1.0
if: always() && env.coverage == 'true'

# build after tests to exclude build files from tests
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/config-presets.md
Expand Up @@ -6,7 +6,7 @@ description: Renovate's support for ESLint-like shareable configs
# Shareable Config Presets

Renovate's "config presets" are a convenient way to distribute config for reuse across multiple repositories.
It is similar in design to `eslint`'s shareable configs, and can be used for whole repository configs and for individual rules.
It is similar in design to ESLint's shareable configs, and can be used for whole repository configs and for individual rules.
They are defined using the `extends` array within config and may also be nested.

In short:
Expand All @@ -33,7 +33,7 @@ Renovate's configuration is self-documenting, because you can fill in the `"desc

## Implementation Approach

In order to achieve these goals, preset configs allow for a very modular approach - preset configs can be as small as a partial package rule or as large as an entire configuration, like an `eslint` config.
In order to achieve these goals, preset configs allow for a very modular approach - preset configs can be as small as a partial package rule or as large as an entire configuration, like an ESLint config.

## Preset Hosting

Expand Down
21 changes: 9 additions & 12 deletions docs/usage/configuration-options.md
Expand Up @@ -201,7 +201,7 @@ In that case Renovate first creates a branch and associated Pull Request, and th
If by the next run the PR is already behind the base branch it will be automatically rebased, because Renovate only automerges branches which are up-to-date and green.
If Renovate is scheduled for hourly runs on the repository but commits are made every 15 minutes to the main branch, then an automerge like this will keep getting deferred with every rebase.

Note: if you have no tests but still want Renovate to automerge, you need to add `"requiredStatusChecks": null` to your configuration.
Note: if you have no tests but still want Renovate to automerge, you need to add `"ignoreTests": true` to your configuration.

If you prefer that Renovate more silently automerge _without_ Pull Requests at all, you can configure `"automergeType": "branch"`. In this case Renovate will:

Expand Down Expand Up @@ -1106,6 +1106,14 @@ It would take the entire `"config:base"` preset - which contains a lot of sub-pr

Applicable for npm and Composer only for now. Set this to `true` if running scripts causes problems.

## ignoreTests

Currently Renovate's default behavior is to only automerge if every status check has succeeded.

Setting this option to `true` means that Renovate will ignore _all_ status checks.
You can set this if you don't have any status checks but still want Renovate to automerge PRs.
Beware: configuring Renovate to automerge without any tests can lead to broken builds on your base branch, please think again before enabling this!

## ignoreUnstable

By default, Renovate won't update any package versions to unstable versions (e.g. `4.0.0-rc3`) unless the current version has the same `major.minor.patch` and was _already_ unstable (e.g. it was already on `4.0.0-rc2`).
Expand Down Expand Up @@ -2144,17 +2152,6 @@ In case there is a need to configure them manually, it can be done using this `r

The field supports multiple URLs however it is datasource-dependent on whether only the first is used or multiple.

## requiredStatusChecks

Currently Renovate's default behavior is to only automerge if every status check has succeeded.

Setting this option to `null` means that Renovate will ignore _all_ status checks.
You can set this if you don't have any status checks but still want Renovate to automerge PRs.
Beware: configuring Renovate to automerge without any tests can lead to broken builds on your base branch, please think again before enabling this!

In future, this might be configurable to allow certain status checks to be ignored/required.
See [issue 1853 at the Renovate repository](https://github.com/renovatebot/renovate/issues/1853) for more details.

## respectLatest

Similar to `ignoreUnstable`, this option controls whether to update to versions that are greater than the version tagged as `latest` in the repository.
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/docker.md
Expand Up @@ -227,7 +227,7 @@ To get access to the token a custom Renovate Docker image is needed that include
The Dockerfile to create such an image can look like this:

```Dockerfile
FROM renovate/renovate:26.19.1
FROM renovate/renovate:27.5.0
# Include the "Docker tip" which you can find here https://cloud.google.com/sdk/docs/install
# under "Installation" for "Debian/Ubuntu"
RUN ...
Expand Down
6 changes: 6 additions & 0 deletions docs/usage/getting-started/private-packages.md
Expand Up @@ -257,6 +257,12 @@ The end-result looks like this:
}
```

#### Yarn 2+

Renovate doesn't support reading `npmRegistries` and `npmScopes` from `.yarnrc.yml`, so `hostRules` (or `npmToken`) and `npmrc` should be configured like above.
Renovate updates `npmRegistries` in `.yarnrc.yml` with resolved `hostRules` before running Yarn.
For Renovate to overwrite existing `npmRegistries` entry, the key should match the `matchHost` without the protocol (`http:` or `https:`) and with the trailing slash.

### nuget

For each known NuGet registry, Renovate searches for `hostRules` with `hostType=nuget` and matching host.
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/key-concepts/automerge.md
Expand Up @@ -117,7 +117,7 @@ If you see "Automerge: Disabled by config" it means you need to make a config ch
### Absence of tests

By default, Renovate will not automerge until it sees passing status checks / check runs for the branch.
If you have no tests but still want Renovate to automerge, you need to add `"requiredStatusChecks": null` to your configuration.
If you have no tests but still want Renovate to automerge, you need to add `"ignoreTests": true` to your configuration.
However, we strongly recommend you have tests in any project where you are regularly updating dependencies.

### Committer restrictions
Expand Down
11 changes: 11 additions & 0 deletions lib/config/migration.spec.ts
Expand Up @@ -772,4 +772,15 @@ describe('config/migration', () => {
expect(isMigrated).toBe(true);
expect(migratedConfig).toMatchSnapshot();
});
it('migrates empty requiredStatusChecks', () => {
const config: RenovateConfig = {
requiredStatusChecks: [],
};
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
config,
defaultConfig
);
expect(isMigrated).toBe(true);
expect(migratedConfig).toMatchInlineSnapshot(`Object {}`);
});
});
20 changes: 12 additions & 8 deletions lib/config/migration.ts
Expand Up @@ -4,6 +4,7 @@ import { dequal } from 'dequal';
import { logger } from '../logger';
import { clone } from '../util/clone';
import { getGlobalConfig } from './global';
import { applyMigrations } from './migrations';
import { getOptions } from './options';
import { removedPresets } from './presets/common';
import type {
Expand Down Expand Up @@ -57,6 +58,7 @@ export function migrateConfig(
'peerDependencies',
];
const { migratePresets } = getGlobalConfig();
applyMigrations(config, migratedConfig);
for (const [key, val] of Object.entries(config)) {
if (removedOptions.includes(key)) {
delete migratedConfig[key];
Expand Down Expand Up @@ -488,16 +490,18 @@ export function migrateConfig(
delete migratedConfig.node;
}
} else if (is.array(val)) {
const newArray = [];
for (const item of migratedConfig[key] as unknown[]) {
if (is.object(item) && !is.array(item)) {
const arrMigrate = migrateConfig(item as RenovateConfig, key);
newArray.push(arrMigrate.migratedConfig);
} else {
newArray.push(item);
if (is.array(migratedConfig?.[key])) {
const newArray = [];
for (const item of migratedConfig[key] as unknown[]) {
if (is.object(item) && !is.array(item)) {
const arrMigrate = migrateConfig(item as RenovateConfig, key);
newArray.push(arrMigrate.migratedConfig);
} else {
newArray.push(item);
}
}
migratedConfig[key] = newArray;
}
migratedConfig[key] = newArray;
} else if (key === 'compatibility' && is.object(val)) {
migratedConfig.constraints = migratedConfig.compatibility;
delete migratedConfig.compatibility;
Expand Down
18 changes: 18 additions & 0 deletions lib/config/migrations/index.ts
@@ -0,0 +1,18 @@
import { RenovateConfig } from '../types';
import type { Migration } from './migration';
import { RequiredStatusChecksMigration } from './required-status-checks-migration';

export function applyMigrations(
originalConfig: RenovateConfig,
migratedConfig: RenovateConfig
): RenovateConfig {
const migrations: Migration[] = [
new RequiredStatusChecksMigration(originalConfig, migratedConfig),
];

for (const migration of migrations) {
migration.migrate();
}

return migratedConfig;
}
18 changes: 18 additions & 0 deletions lib/config/migrations/migration.ts
@@ -0,0 +1,18 @@
import type { RenovateConfig } from '../types';

export abstract class Migration {
protected readonly originalConfig: RenovateConfig;

protected readonly migratedConfig: RenovateConfig;

constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) {
this.originalConfig = originalConfig;
this.migratedConfig = migratedConfig;
}

abstract migrate(): void;

protected delete(property: string): void {
delete this.migratedConfig[property];
}
}
21 changes: 21 additions & 0 deletions lib/config/migrations/required-status-checks-migration.spec.ts
@@ -0,0 +1,21 @@
import { RequiredStatusChecksMigration } from './required-status-checks-migration';

describe('config/migrations/required-status-checks-migration', () => {
it('should migrate requiredStatusChecks=null to ignoreTests=true', () => {
const originalConfig: any = {
requiredStatusChecks: null,
};
const migratedConfig: any = {
requiredStatusChecks: null,
};
const migration = new RequiredStatusChecksMigration(
originalConfig,
migratedConfig
);

expect(migratedConfig.requiredStatusChecks).toBeNull();
migration.migrate();
expect(migratedConfig.requiredStatusChecks).toBeUndefined();
expect(migratedConfig.ignoreTests).toBeTrue();
});
});
11 changes: 11 additions & 0 deletions lib/config/migrations/required-status-checks-migration.ts
@@ -0,0 +1,11 @@
import { Migration } from './migration';

export class RequiredStatusChecksMigration extends Migration {
public migrate(): void {
this.delete('requiredStatusChecks');

if (this.originalConfig.requiredStatusChecks === null) {
this.migratedConfig.ignoreTests = true;
}
}
}
11 changes: 4 additions & 7 deletions lib/config/options/index.ts
Expand Up @@ -1317,13 +1317,10 @@ const options: RenovateOptions[] = [
default: 'automergeComment',
},
{
name: 'requiredStatusChecks',
description:
'List of status checks that must pass before automerging. Set to null to enable automerging without tests.',
type: 'array',
subType: 'string',
cli: false,
env: false,
name: 'ignoreTests',
description: 'Set to true to enable automerging without tests.',
type: 'boolean',
default: false,
},
{
name: 'transitiveRemediation',
Expand Down
2 changes: 1 addition & 1 deletion lib/config/presets/__snapshots__/index.spec.ts.snap
Expand Up @@ -33,6 +33,7 @@ Object {
"Require all status checks to pass before any automerging",
"Pin dependency versions for <code>devDependencies</code> and retain semver ranges for others",
],
"ignoreTests": false,
"ignoreUnstable": true,
"labels": Array [
"dependencies",
Expand Down Expand Up @@ -85,7 +86,6 @@ Object {
],
"prCreation": "immediate",
"rebaseWhen": "behind-base-branch",
"requiredStatusChecks": Array [],
"respectLatest": true,
"schedule": Array [
"before 8am",
Expand Down
6 changes: 6 additions & 0 deletions lib/config/presets/index.spec.ts
Expand Up @@ -601,6 +601,12 @@ Object {
"monorepo:opentelemetry-js",
],
"groupName": "opentelemetry-js monorepo",
"matchUpdateTypes": Array [
"digest",
"patch",
"minor",
"major",
],
},
],
}
Expand Down
4 changes: 2 additions & 2 deletions lib/config/presets/internal/default.ts
Expand Up @@ -316,11 +316,11 @@ export const presets: Record<string, Preset> = {
},
automergeRequireAllStatusChecks: {
description: 'Require all status checks to pass before any automerging',
requiredStatusChecks: [],
ignoreTests: false,
},
skipStatusChecks: {
description: 'Skip status checks and automerge right away',
requiredStatusChecks: null,
ignoreTests: true,
},
maintainLockFilesDisabled: {
description:
Expand Down
3 changes: 3 additions & 0 deletions lib/config/presets/internal/group.ts
@@ -1,6 +1,8 @@
import type { Preset } from '../types';
import * as monorepos from './monorepo';

const nonPinUpdateTypes = ['digest', 'patch', 'minor', 'major'];

const staticGroups = {
all: {
description: 'Group all updates together',
Expand Down Expand Up @@ -596,6 +598,7 @@ for (const monorepo of Object.keys(monorepos.presets)) {
{
description: `Group packages from ${monorepo} monorepo together`,
extends: `monorepo:${monorepo}`,
matchUpdateTypes: nonPinUpdateTypes,
groupName: `${monorepo} monorepo`,
},
],
Expand Down
2 changes: 1 addition & 1 deletion lib/config/types.ts
Expand Up @@ -38,6 +38,7 @@ export interface RenovateSharedConfig {
includePaths?: string[];
ignoreDeps?: string[];
ignorePaths?: string[];
ignoreTests?: boolean;
labels?: string[];
addLabels?: string[];
dependencyDashboardApproval?: boolean;
Expand All @@ -55,7 +56,6 @@ export interface RenovateSharedConfig {
recreateClosed?: boolean;
repository?: string;
repositoryCache?: RepositoryCacheConfig;
requiredStatusChecks?: string[];
schedule?: string[];
semanticCommits?: 'auto' | 'enabled' | 'disabled';
semanticCommitScope?: string;
Expand Down

0 comments on commit 67c1d20

Please sign in to comment.