From 0af7b2a37ef3807399681cd34fe07d224c296561 Mon Sep 17 00:00:00 2001 From: secustor Date: Thu, 4 Jan 2024 21:58:06 +0100 Subject: [PATCH 1/9] feat(managers/ocb): add new manager for OpenTelemetryCollectorBuilder --- lib/modules/manager/api.ts | 2 + .../manager/ocb/__fixtures__/valid.yaml | 16 +++++ lib/modules/manager/ocb/extract.spec.ts | 44 ++++++++++++ lib/modules/manager/ocb/extract.ts | 72 +++++++++++++++++++ lib/modules/manager/ocb/index.ts | 13 ++++ lib/modules/manager/ocb/readme.md | 21 ++++++ lib/modules/manager/ocb/schema.ts | 21 ++++++ lib/modules/manager/ocb/update.spec.ts | 44 ++++++++++++ lib/modules/manager/ocb/update.ts | 47 ++++++++++++ 9 files changed, 280 insertions(+) create mode 100644 lib/modules/manager/ocb/__fixtures__/valid.yaml create mode 100644 lib/modules/manager/ocb/extract.spec.ts create mode 100644 lib/modules/manager/ocb/extract.ts create mode 100644 lib/modules/manager/ocb/index.ts create mode 100644 lib/modules/manager/ocb/readme.md create mode 100644 lib/modules/manager/ocb/schema.ts create mode 100644 lib/modules/manager/ocb/update.spec.ts create mode 100644 lib/modules/manager/ocb/update.ts diff --git a/lib/modules/manager/api.ts b/lib/modules/manager/api.ts index ba08a398818dbd..6f618abaee49d2 100644 --- a/lib/modules/manager/api.ts +++ b/lib/modules/manager/api.ts @@ -61,6 +61,7 @@ import * as nodenv from './nodenv'; import * as npm from './npm'; import * as nuget from './nuget'; import * as nvm from './nvm'; +import * as ocb from './ocb'; import * as osgi from './osgi'; import * as pep621 from './pep621'; import * as pipCompile from './pip-compile'; @@ -153,6 +154,7 @@ api.set('nodenv', nodenv); api.set('npm', npm); api.set('nuget', nuget); api.set('nvm', nvm); +api.set('ocb', ocb); api.set('osgi', osgi); api.set('pep621', pep621); api.set('pip-compile', pipCompile); diff --git a/lib/modules/manager/ocb/__fixtures__/valid.yaml b/lib/modules/manager/ocb/__fixtures__/valid.yaml new file mode 100644 index 00000000000000..42063bf721711c --- /dev/null +++ b/lib/modules/manager/ocb/__fixtures__/valid.yaml @@ -0,0 +1,16 @@ +dist: + name: otelcol-custom + description: Local OpenTelemetry Collector binary + module: github.com/open-telemetry/opentelemetry-collector + otelcol_version: 0.40.0 + version: 1.0.0 + output_path: /tmp/dist +exporters: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.86.0 + - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.86.0 + +receivers: + - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0 + +processors: + - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.86.0 diff --git a/lib/modules/manager/ocb/extract.spec.ts b/lib/modules/manager/ocb/extract.spec.ts new file mode 100644 index 00000000000000..80146ca45592e5 --- /dev/null +++ b/lib/modules/manager/ocb/extract.spec.ts @@ -0,0 +1,44 @@ +import { Fixtures } from '../../../../test/fixtures'; +import { extractPackageFile } from '.'; + +const test = Fixtures.get('valid.yaml'); + +describe('modules/manager/ocb/extract', () => { + describe('extractPackageFile', () => { + it('run successfully with full example', () => { + const result = extractPackageFile(test, 'builder-config.yaml'); + expect(result?.deps).toEqual([ + { + currentValue: '0.40.0', + datasource: 'go', + depName: 'github.com/open-telemetry/opentelemetry-collector', + depType: 'collector', + extractVersion: '^v(?\\S+)', + }, + { + currentValue: 'v0.86.0', + datasource: 'go', + depName: + 'github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter', + depType: 'exports', + }, + { + currentValue: 'v0.86.0', + datasource: 'go', + depName: 'go.opentelemetry.io/collector/exporter/debugexporter', + depType: 'exports', + }, + { + currentValue: 'v0.86.0', + datasource: 'go', + depName: 'go.opentelemetry.io/collector/processor/batchprocessor', + depType: 'processors', + }, + ]); + }); + + it('return null for unknown content', () => { + expect(extractPackageFile('foo', 'bar.yaml')).toBeNull(); + }); + }); +}); diff --git a/lib/modules/manager/ocb/extract.ts b/lib/modules/manager/ocb/extract.ts new file mode 100644 index 00000000000000..cbdedd7069a63a --- /dev/null +++ b/lib/modules/manager/ocb/extract.ts @@ -0,0 +1,72 @@ +import is from '@sindresorhus/is'; +import { logger } from '../../../logger'; +import { regEx } from '../../../util/regex'; +import { parseSingleYaml } from '../../../util/yaml'; +import { GoDatasource } from '../../datasource/go'; +import type { + ExtractConfig, + PackageDependency, + PackageFileContent, +} from '../types'; +import { type Module, OCBConfigSchema } from './schema'; + +export function extractPackageFile( + content: string, + packageFile: string, + _config?: ExtractConfig, +): PackageFileContent | null { + const yaml = parseSingleYaml(content); + const parsed = OCBConfigSchema.safeParse(yaml); + if (!parsed.success) { + logger.trace( + { packageFile, error: parsed.error }, + 'Failed to parse OCB schema', + ); + return null; + } + + const definition = parsed.data; + + const deps: PackageDependency[] = []; + if (definition.dist.module && definition.dist.otelcol_version) { + deps.push({ + datasource: GoDatasource.id, + depType: 'collector', + depName: definition.dist.module, + currentValue: definition.dist.otelcol_version, + extractVersion: '^v(?\\S+)', + }); + } + + deps.push(...processModule(definition.connectors, 'connectors')); + deps.push(...processModule(definition.exporters, 'exports')); + deps.push(...processModule(definition.extension, 'extensions')); + deps.push(...processModule(definition.processors, 'processors')); + + return { + packageFileVersion: definition.dist.version, + deps, + }; +} + +export function processModule( + module: Module, + depType: string, +): PackageDependency[] { + const deps: PackageDependency[] = []; + if (is.nullOrUndefined(module)) { + return deps; + } + + for (const element of module) { + const [depName, currentValue] = element.gomod.trim().split(regEx(/\s+/)); + deps.push({ + datasource: GoDatasource.id, + depType, + depName, + currentValue, + }); + } + + return deps; +} diff --git a/lib/modules/manager/ocb/index.ts b/lib/modules/manager/ocb/index.ts new file mode 100644 index 00000000000000..013a7f62965a02 --- /dev/null +++ b/lib/modules/manager/ocb/index.ts @@ -0,0 +1,13 @@ +import type { Category } from '../../../constants'; +import { GoDatasource } from '../../datasource/go'; + +export { extractPackageFile } from './extract'; +export { bumpPackageVersion } from './update'; + +export const supportedDatasources = [GoDatasource.id]; + +export const categories: Category[] = ['golang']; + +export const defaultConfig = { + fileMatch: [], +}; diff --git a/lib/modules/manager/ocb/readme.md b/lib/modules/manager/ocb/readme.md new file mode 100644 index 00000000000000..d7f4f09407e289 --- /dev/null +++ b/lib/modules/manager/ocb/readme.md @@ -0,0 +1,21 @@ +This manager allows updating dependencies defined in build definitions for the [OpenTelemetry Collector Builder (ocb)](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder). + +The `ocb` manager has no `fileMatch` default patterns, so it won't match any files until you configure it with a pattern. + +```json title="If your builder files are named like foo-builder.yml or builder.yaml" +{ + "ocb": { + "fileMatch": ["builder.ya?ml$"] + } +} +``` + +Supported dependencies and their respective `depType`s are: + +| Name | depType | +| -------------- | ------------ | +| Base collector | `collector` | +| connectors | `connectors` | +| exports | `exports` | +| extensions | `extensions` | +| processors | `processors` | diff --git a/lib/modules/manager/ocb/schema.ts b/lib/modules/manager/ocb/schema.ts new file mode 100644 index 00000000000000..abdebd6d0f3f6d --- /dev/null +++ b/lib/modules/manager/ocb/schema.ts @@ -0,0 +1,21 @@ +import { z } from 'zod'; + +const Entry = z.object({ + gomod: z.string(), +}); + +const ModuleSchema = z.array(Entry).optional(); +export type Module = z.infer; + +export const OCBConfigSchema = z.object({ + dist: z.object({ + otelcol_version: z.string().optional(), + module: z.string().optional(), + version: z.string().optional(), + }), + extension: ModuleSchema, + exporters: ModuleSchema, + receivers: ModuleSchema, + processors: ModuleSchema, + connectors: ModuleSchema, +}); diff --git a/lib/modules/manager/ocb/update.spec.ts b/lib/modules/manager/ocb/update.spec.ts new file mode 100644 index 00000000000000..d843833901e0a0 --- /dev/null +++ b/lib/modules/manager/ocb/update.spec.ts @@ -0,0 +1,44 @@ +import { codeBlock } from 'common-tags'; +import { bumpPackageVersion } from './update'; + +describe('modules/manager/ocb/update', () => { + describe('bumpPackageVersion()', () => { + it('increments with all fields', () => { + const content = codeBlock` + dist: + name: otelcol-custom + description: Local OpenTelemetry Collector binary + module: github.com/open-telemetry/opentelemetry-collector + otelcol_version: 0.40.0 + version: 1.0.0 + output_path: /tmp/dist + `; + const expected = content.replace('1.0.0', '1.0.1'); + + const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch'); + expect(bumpedContent).toEqual(expected); + }); + + it('increments with double quotes', () => { + const content = codeBlock` + dist: + version: "1.0.0" + `; + const expected = content.replace('1.0.0', '1.0.1'); + + const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch'); + expect(bumpedContent).toEqual(expected); + }); + + it('increments with single quotes', () => { + const content = codeBlock` + dist: + version: '1.0.0' + `; + const expected = content.replace('1.0.0', '1.0.1'); + + const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch'); + expect(bumpedContent).toEqual(expected); + }); + }); +}); diff --git a/lib/modules/manager/ocb/update.ts b/lib/modules/manager/ocb/update.ts new file mode 100644 index 00000000000000..7e893c699b0f03 --- /dev/null +++ b/lib/modules/manager/ocb/update.ts @@ -0,0 +1,47 @@ +import { type ReleaseType, inc } from 'semver'; +import { logger } from '../../../logger'; +import { regEx } from '../../../util/regex'; +import type { BumpPackageVersionResult } from '../types'; + +export function bumpPackageVersion( + content: string, + currentValue: string, + bumpVersion: ReleaseType, +): BumpPackageVersionResult { + logger.debug( + { bumpVersion, currentValue }, + 'Checking if we should bump OCB version', + ); + + let bumpedContent = content; + try { + const newProjectVersion = inc(currentValue, bumpVersion); + if (!newProjectVersion) { + throw new Error('semver inc failed'); + } + + logger.debug(`newProjectVersion: ${newProjectVersion}`); + bumpedContent = content.replace( + regEx(/\b(?version:\s+["']?)(?[^'"\s]*)/), + `$${newProjectVersion}`, + ); + + if (bumpedContent === content) { + logger.debug('Version was already bumped'); + } else { + logger.debug('Bumped OCB version'); + } + } catch (err) { + logger.warn( + { + content, + currentValue, + bumpVersion, + manager: 'ocb', + }, + 'Failed to bumpVersion', + ); + } + + return { bumpedContent }; +} From 097ea89244b1c4281cf676c2705276b58c78fb05 Mon Sep 17 00:00:00 2001 From: secustor Date: Thu, 4 Jan 2024 22:04:20 +0100 Subject: [PATCH 2/9] docs(managers/ocb): update bumpVersion support --- docs/usage/configuration-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 7e099f851b683d..9eda0b2462253b 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -410,7 +410,7 @@ This is an advance field and it's recommend you seek a config review before appl ## bumpVersion -Currently this setting supports `helmv3`, `npm`, `nuget`, `maven`, `pep621`, `poetry` and `sbt` only, so raise a feature request if you have a use for it with other package managers. +Currently, this setting supports `helmv3`, `npm`, `nuget`, `maven`, `ocb`, `pep621`, `poetry` and `sbt` only, so raise a feature request if you have a use for it with other package managers. Its purpose is if you want Renovate to update the `version` field within your package file any time it updates dependencies within. Usually this is for automatic release purposes, so that you don't need to add another step after Renovate before you can release a new version. From d06862ea3f9cb5c7b8bb4e27b54655c5d8dd38ff Mon Sep 17 00:00:00 2001 From: secustor Date: Thu, 4 Jan 2024 22:22:17 +0100 Subject: [PATCH 3/9] test(managers/ocb): fix coverage --- lib/modules/manager/ocb/update.spec.ts | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/modules/manager/ocb/update.spec.ts b/lib/modules/manager/ocb/update.spec.ts index d843833901e0a0..dd17bf0d0e080d 100644 --- a/lib/modules/manager/ocb/update.spec.ts +++ b/lib/modules/manager/ocb/update.spec.ts @@ -40,5 +40,37 @@ describe('modules/manager/ocb/update', () => { const { bumpedContent } = bumpPackageVersion(content, '1.0.0', 'patch'); expect(bumpedContent).toEqual(expected); }); + + it('no ops', () => { + const content = codeBlock` + dist: + version: '0.0.2' + `; + const { bumpedContent } = bumpPackageVersion(content, '0.0.1', 'patch'); + expect(bumpedContent).toEqual(content); + }); + + it('updates', () => { + const content = codeBlock` + dist: + version: '0.0.2' + `; + const { bumpedContent } = bumpPackageVersion(content, '0.0.1', 'minor'); + const expected = content.replace('0.0.2', '0.1.0'); + expect(bumpedContent).toEqual(expected); + }); + + it('returns content if bumping errors', () => { + const content = codeBlock` + dist: + version: '1.0.0' + `; + const { bumpedContent } = bumpPackageVersion( + content, + '0.0.2', + true as any, + ); + expect(bumpedContent).toEqual(content); + }); }); }); From 76dca954c201008ba412e089686ed172e1586678 Mon Sep 17 00:00:00 2001 From: secustor Date: Fri, 5 Jan 2024 22:12:41 +0100 Subject: [PATCH 4/9] chore: implement suggestions --- docs/usage/configuration-options.md | 14 ++++++- .../manager/ocb/__fixtures__/valid.yaml | 16 -------- lib/modules/manager/ocb/extract.spec.ts | 38 +++++++++++++++++-- lib/modules/manager/ocb/extract.ts | 26 ++++++++----- lib/modules/manager/ocb/schema.ts | 1 + lib/modules/manager/ocb/update.spec.ts | 2 +- 6 files changed, 65 insertions(+), 32 deletions(-) delete mode 100644 lib/modules/manager/ocb/__fixtures__/valid.yaml diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 9eda0b2462253b..5c6190b8ff1012 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -410,7 +410,19 @@ This is an advance field and it's recommend you seek a config review before appl ## bumpVersion -Currently, this setting supports `helmv3`, `npm`, `nuget`, `maven`, `ocb`, `pep621`, `poetry` and `sbt` only, so raise a feature request if you have a use for it with other package managers. +Currently, this setting supports following managers only: + +- `helmv3` +- `npm` +- `nuget` +- `maven` +- `ocb` +- `pep621` +- `poetry` +- `sbt` + +Raise a feature request if you have a use for it with other package managers. + Its purpose is if you want Renovate to update the `version` field within your package file any time it updates dependencies within. Usually this is for automatic release purposes, so that you don't need to add another step after Renovate before you can release a new version. diff --git a/lib/modules/manager/ocb/__fixtures__/valid.yaml b/lib/modules/manager/ocb/__fixtures__/valid.yaml deleted file mode 100644 index 42063bf721711c..00000000000000 --- a/lib/modules/manager/ocb/__fixtures__/valid.yaml +++ /dev/null @@ -1,16 +0,0 @@ -dist: - name: otelcol-custom - description: Local OpenTelemetry Collector binary - module: github.com/open-telemetry/opentelemetry-collector - otelcol_version: 0.40.0 - version: 1.0.0 - output_path: /tmp/dist -exporters: - - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.86.0 - - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.86.0 - -receivers: - - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0 - -processors: - - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.86.0 diff --git a/lib/modules/manager/ocb/extract.spec.ts b/lib/modules/manager/ocb/extract.spec.ts index 80146ca45592e5..99fd13ec2a1f71 100644 --- a/lib/modules/manager/ocb/extract.spec.ts +++ b/lib/modules/manager/ocb/extract.spec.ts @@ -1,12 +1,28 @@ -import { Fixtures } from '../../../../test/fixtures'; +import { codeBlock } from 'common-tags'; import { extractPackageFile } from '.'; -const test = Fixtures.get('valid.yaml'); - describe('modules/manager/ocb/extract', () => { describe('extractPackageFile', () => { it('run successfully with full example', () => { - const result = extractPackageFile(test, 'builder-config.yaml'); + const content = codeBlock` + dist: + name: otelcol-custom + description: Local OpenTelemetry Collector binary + module: github.com/open-telemetry/opentelemetry-collector + otelcol_version: 0.40.0 + version: 1.0.0 + output_path: /tmp/dist + exporters: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.86.0 + - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.86.0 + + receivers: + - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.86.0 + + processors: + - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.86.0 + `; + const result = extractPackageFile(content, 'builder-config.yaml'); expect(result?.deps).toEqual([ { currentValue: '0.40.0', @@ -40,5 +56,19 @@ describe('modules/manager/ocb/extract', () => { it('return null for unknown content', () => { expect(extractPackageFile('foo', 'bar.yaml')).toBeNull(); }); + + it('return null for content which is not YAML', () => { + expect( + extractPackageFile( + codeBlock` + myObject: + aString: value + --- + foo: bar + `, + 'bar.yaml', + ), + ).toBeNull(); + }); }); }); diff --git a/lib/modules/manager/ocb/extract.ts b/lib/modules/manager/ocb/extract.ts index cbdedd7069a63a..a92700ecadae89 100644 --- a/lib/modules/manager/ocb/extract.ts +++ b/lib/modules/manager/ocb/extract.ts @@ -8,25 +8,31 @@ import type { PackageDependency, PackageFileContent, } from '../types'; -import { type Module, OCBConfigSchema } from './schema'; +import { type Module, type OCBConfig, OCBConfigSchema } from './schema'; export function extractPackageFile( content: string, packageFile: string, _config?: ExtractConfig, ): PackageFileContent | null { - const yaml = parseSingleYaml(content); - const parsed = OCBConfigSchema.safeParse(yaml); - if (!parsed.success) { - logger.trace( - { packageFile, error: parsed.error }, - 'Failed to parse OCB schema', - ); + let definition: OCBConfig | null = null; + try { + const yaml = parseSingleYaml(content); + const parsed = OCBConfigSchema.safeParse(yaml); + if (!parsed.success) { + logger.trace( + { packageFile, error: parsed.error }, + 'Failed to parse OCB schema', + ); + return null; + } + + definition = parsed.data; + } catch (error) { + logger.trace({ packageFile, error }, 'Failed to parse OCB file as YAML'); return null; } - const definition = parsed.data; - const deps: PackageDependency[] = []; if (definition.dist.module && definition.dist.otelcol_version) { deps.push({ diff --git a/lib/modules/manager/ocb/schema.ts b/lib/modules/manager/ocb/schema.ts index abdebd6d0f3f6d..0b8bd927b469a5 100644 --- a/lib/modules/manager/ocb/schema.ts +++ b/lib/modules/manager/ocb/schema.ts @@ -19,3 +19,4 @@ export const OCBConfigSchema = z.object({ processors: ModuleSchema, connectors: ModuleSchema, }); +export type OCBConfig = z.infer; diff --git a/lib/modules/manager/ocb/update.spec.ts b/lib/modules/manager/ocb/update.spec.ts index dd17bf0d0e080d..cbae6ce3ff733e 100644 --- a/lib/modules/manager/ocb/update.spec.ts +++ b/lib/modules/manager/ocb/update.spec.ts @@ -1,5 +1,5 @@ import { codeBlock } from 'common-tags'; -import { bumpPackageVersion } from './update'; +import { bumpPackageVersion } from '.'; describe('modules/manager/ocb/update', () => { describe('bumpPackageVersion()', () => { From 8f8d64bc9d49fefd0566e01f8bebcc8e91564806 Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer Date: Fri, 5 Jan 2024 22:21:13 +0100 Subject: [PATCH 5/9] Apply suggestions from code review Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/configuration-options.md | 4 ++-- lib/modules/manager/ocb/readme.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 5c6190b8ff1012..922014a1b6ff8b 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -410,7 +410,7 @@ This is an advance field and it's recommend you seek a config review before appl ## bumpVersion -Currently, this setting supports following managers only: +Currently, this config option only works with these managers: - `helmv3` - `npm` @@ -421,7 +421,7 @@ Currently, this setting supports following managers only: - `poetry` - `sbt` -Raise a feature request if you have a use for it with other package managers. +Raise a feature request if you want to use this config option with other package managers. Its purpose is if you want Renovate to update the `version` field within your package file any time it updates dependencies within. Usually this is for automatic release purposes, so that you don't need to add another step after Renovate before you can release a new version. diff --git a/lib/modules/manager/ocb/readme.md b/lib/modules/manager/ocb/readme.md index d7f4f09407e289..cebb41e57cb53b 100644 --- a/lib/modules/manager/ocb/readme.md +++ b/lib/modules/manager/ocb/readme.md @@ -1,4 +1,4 @@ -This manager allows updating dependencies defined in build definitions for the [OpenTelemetry Collector Builder (ocb)](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder). +Renovate uses this manager to update dependencies defined in the build definitions for the [OpenTelemetry Collector Builder (ocb)](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder). The `ocb` manager has no `fileMatch` default patterns, so it won't match any files until you configure it with a pattern. @@ -14,7 +14,7 @@ Supported dependencies and their respective `depType`s are: | Name | depType | | -------------- | ------------ | -| Base collector | `collector` | +| base collector | `collector` | | connectors | `connectors` | | exports | `exports` | | extensions | `extensions` | From be6d6680db665bd2acc154cff009ed7a9b92f6a0 Mon Sep 17 00:00:00 2001 From: secustor Date: Sat, 6 Jan 2024 11:20:11 +0100 Subject: [PATCH 6/9] chore: implement suggestions --- lib/modules/manager/ocb/extract.ts | 2 +- lib/modules/manager/ocb/update.spec.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/modules/manager/ocb/extract.ts b/lib/modules/manager/ocb/extract.ts index a92700ecadae89..0ffbad965896ff 100644 --- a/lib/modules/manager/ocb/extract.ts +++ b/lib/modules/manager/ocb/extract.ts @@ -29,7 +29,7 @@ export function extractPackageFile( definition = parsed.data; } catch (error) { - logger.trace({ packageFile, error }, 'Failed to parse OCB file as YAML'); + logger.debug({ packageFile, error }, 'Failed to parse OCB file as YAML'); return null; } diff --git a/lib/modules/manager/ocb/update.spec.ts b/lib/modules/manager/ocb/update.spec.ts index cbae6ce3ff733e..dc1e8cda5f9463 100644 --- a/lib/modules/manager/ocb/update.spec.ts +++ b/lib/modules/manager/ocb/update.spec.ts @@ -68,7 +68,8 @@ describe('modules/manager/ocb/update', () => { const { bumpedContent } = bumpPackageVersion( content, '0.0.2', - true as any, + // @ts-expect-error supplying a wrong parameter to trigger an exception + true, ); expect(bumpedContent).toEqual(content); }); From 603e0298197e460eb00136f572a6874a541019dd Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer Date: Mon, 8 Jan 2024 11:17:20 +0100 Subject: [PATCH 7/9] Apply suggestions from code review Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/configuration-options.md | 4 ++-- lib/modules/manager/ocb/readme.md | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 922014a1b6ff8b..bb4a74e298a9ad 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -423,8 +423,8 @@ Currently, this config option only works with these managers: Raise a feature request if you want to use this config option with other package managers. -Its purpose is if you want Renovate to update the `version` field within your package file any time it updates dependencies within. -Usually this is for automatic release purposes, so that you don't need to add another step after Renovate before you can release a new version. +Use `bumpVersion` if you want Renovate to update the `version` field in your package file when it updates the dependencies in that file. +This can be handy when you have automated your package's release, as you you don't need extra steps after the Renovate upgrade, you can just release a new version. Configure this value to `"prerelease"`, `"patch"`, `"minor"` or `"major"` to have Renovate update the version in your edited package file. e.g. if you wish Renovate to always increase the target `package.json` version with a patch update, configure this to `"patch"`. diff --git a/lib/modules/manager/ocb/readme.md b/lib/modules/manager/ocb/readme.md index cebb41e57cb53b..2ca2119d6aedd0 100644 --- a/lib/modules/manager/ocb/readme.md +++ b/lib/modules/manager/ocb/readme.md @@ -1,6 +1,8 @@ Renovate uses this manager to update dependencies defined in the build definitions for the [OpenTelemetry Collector Builder (ocb)](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder). -The `ocb` manager has no `fileMatch` default patterns, so it won't match any files until you configure it with a pattern. +By default, the `ocb` manager has no `fileMatch` patterns. +This means you must set a `fileMatch` pattern for the `ocb` manager, in order for Renovate to update your `ocb` files. +Here's a configuration example: ```json title="If your builder files are named like foo-builder.yml or builder.yaml" { From fe2da3377d198237cca8764baf153fc1bf3988d0 Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer Date: Mon, 8 Jan 2024 11:34:54 +0100 Subject: [PATCH 8/9] Update lib/modules/manager/ocb/extract.ts --- lib/modules/manager/ocb/extract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/manager/ocb/extract.ts b/lib/modules/manager/ocb/extract.ts index 0ffbad965896ff..31bdbd741f41ee 100644 --- a/lib/modules/manager/ocb/extract.ts +++ b/lib/modules/manager/ocb/extract.ts @@ -29,7 +29,7 @@ export function extractPackageFile( definition = parsed.data; } catch (error) { - logger.debug({ packageFile, error }, 'Failed to parse OCB file as YAML'); + logger.debug({ packageFile, error }, 'OCB manager failed to parse file as YAML'); return null; } From 21f310c50cd505c0d53051784147764d923cc6bb Mon Sep 17 00:00:00 2001 From: secustor Date: Mon, 8 Jan 2024 13:37:19 +0100 Subject: [PATCH 9/9] prettier fix --- lib/modules/manager/ocb/extract.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/ocb/extract.ts b/lib/modules/manager/ocb/extract.ts index 31bdbd741f41ee..99416851bce64f 100644 --- a/lib/modules/manager/ocb/extract.ts +++ b/lib/modules/manager/ocb/extract.ts @@ -29,7 +29,10 @@ export function extractPackageFile( definition = parsed.data; } catch (error) { - logger.debug({ packageFile, error }, 'OCB manager failed to parse file as YAML'); + logger.debug( + { packageFile, error }, + 'OCB manager failed to parse file as YAML', + ); return null; }