From d2536a7cc2cc4af967b1bf6c04af061fe2aedcca Mon Sep 17 00:00:00 2001 From: Johannes Feichtner <343448+Churro@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:11:04 +0100 Subject: [PATCH] feat(manager/poetry): add support for `bumpVersion` option (#26377) --- docs/usage/configuration-options.md | 1 + .../poetry/__snapshots__/extract.spec.ts.snap | 4 ++++ lib/modules/manager/poetry/index.ts | 1 + lib/modules/manager/poetry/schema.spec.ts | 13 ++++++++++++- lib/modules/manager/poetry/schema.ts | 4 +++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 40f9e3bcc821c4..f93316f3c55efb 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -411,6 +411,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` 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`, `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. diff --git a/lib/modules/manager/poetry/__snapshots__/extract.spec.ts.snap b/lib/modules/manager/poetry/__snapshots__/extract.spec.ts.snap index 23cdcb538c841e..81b6571687665d 100644 --- a/lib/modules/manager/poetry/__snapshots__/extract.spec.ts.snap +++ b/lib/modules/manager/poetry/__snapshots__/extract.spec.ts.snap @@ -345,6 +345,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() extracts mixed vers }, ], "extractedConstraints": {}, + "packageFileVersion": "0.1.0", } `; @@ -427,6 +428,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() extracts multiple d }, ], "extractedConstraints": {}, + "packageFileVersion": "0.1.0", } `; @@ -555,6 +557,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() handles multiple co }, ], "extractedConstraints": {}, + "packageFileVersion": "0.1.0", } `; @@ -589,5 +592,6 @@ exports[`modules/manager/poetry/extract extractPackageFile() resolves lockedVers "extractedConstraints": { "python": "^3.9", }, + "packageFileVersion": undefined, } `; diff --git a/lib/modules/manager/poetry/index.ts b/lib/modules/manager/poetry/index.ts index ba5cdee9a8e951..0b69f3415625bf 100644 --- a/lib/modules/manager/poetry/index.ts +++ b/lib/modules/manager/poetry/index.ts @@ -3,6 +3,7 @@ import { GithubReleasesDatasource } from '../../datasource/github-releases'; import { GithubTagsDatasource } from '../../datasource/github-tags'; import { PypiDatasource } from '../../datasource/pypi'; +export { bumpPackageVersion } from '../pep621/update'; export { extractPackageFile } from './extract'; export { updateArtifacts } from './artifacts'; export { updateLockedDependency } from './update-locked'; diff --git a/lib/modules/manager/poetry/schema.spec.ts b/lib/modules/manager/poetry/schema.spec.ts index 4da5b1e6e99367..373aa68d44c8cb 100644 --- a/lib/modules/manager/poetry/schema.spec.ts +++ b/lib/modules/manager/poetry/schema.spec.ts @@ -1,6 +1,17 @@ -import { PoetrySources } from './schema'; +import { PoetrySectionSchema, PoetrySources } from './schema'; describe('modules/manager/poetry/schema', () => { + it('parses project version', () => { + expect( + PoetrySectionSchema.parse({ version: '1.2.3' }).packageFileVersion, + ).toBe('1.2.3'); + + expect( + PoetrySectionSchema.parse({ version: { some: 'value' } }) + .packageFileVersion, + ).toBeUndefined(); + }); + describe('PoetrySources', () => { it('parses default values', () => { expect(PoetrySources.parse([])).toBeEmptyArray(); diff --git a/lib/modules/manager/poetry/schema.ts b/lib/modules/manager/poetry/schema.ts index 527c54a2b17783..460ddee33812ff 100644 --- a/lib/modules/manager/poetry/schema.ts +++ b/lib/modules/manager/poetry/schema.ts @@ -245,6 +245,7 @@ export const PoetrySources = LooseArray(PoetrySource, { export const PoetrySectionSchema = z .object({ + version: z.string().optional().catch(undefined), dependencies: withDepType(PoetryDependencies, 'dependencies').optional(), 'dev-dependencies': withDepType( PoetryDependencies, @@ -256,6 +257,7 @@ export const PoetrySectionSchema = z }) .transform( ({ + version, dependencies = [], 'dev-dependencies': devDependencies = [], extras: extraDependencies = [], @@ -269,7 +271,7 @@ export const PoetrySectionSchema = z ...groupDependencies, ]; - const res: PackageFileContent = { deps }; + const res: PackageFileContent = { deps, packageFileVersion: version }; if (sourceUrls.length) { for (const dep of res.deps) {