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

feat(manager/poetry): add support for bumpVersion option #26377

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions lib/modules/manager/poetry/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() extracts mixed vers
},
],
"extractedConstraints": {},
"packageFileVersion": "0.1.0",
}
`;

Expand Down Expand Up @@ -427,6 +428,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() extracts multiple d
},
],
"extractedConstraints": {},
"packageFileVersion": "0.1.0",
}
`;

Expand Down Expand Up @@ -555,6 +557,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() handles multiple co
},
],
"extractedConstraints": {},
"packageFileVersion": "0.1.0",
}
`;

Expand Down Expand Up @@ -589,5 +592,6 @@ exports[`modules/manager/poetry/extract extractPackageFile() resolves lockedVers
"extractedConstraints": {
"python": "^3.9",
},
"packageFileVersion": undefined,
}
`;
1 change: 1 addition & 0 deletions lib/modules/manager/poetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 12 additions & 1 deletion lib/modules/manager/poetry/schema.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/manager/poetry/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -256,6 +257,7 @@ export const PoetrySectionSchema = z
})
.transform(
({
version,
dependencies = [],
'dev-dependencies': devDependencies = [],
extras: extraDependencies = [],
Expand All @@ -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) {
Expand Down