From 2b0a609e2652c8955405ab3613cdc2ab0b135ca5 Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer Date: Wed, 31 May 2023 00:07:41 +0200 Subject: [PATCH] perf(manager/pep621): do sync packages on pdm lockfile updates (#22508) --- lib/modules/manager/pep621/artifacts.spec.ts | 2 +- .../manager/pep621/processors/pdm.spec.ts | 12 ++++++------ lib/modules/manager/pep621/processors/pdm.ts | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/modules/manager/pep621/artifacts.spec.ts b/lib/modules/manager/pep621/artifacts.spec.ts index ebcc935879894b..d28645cf794350 100644 --- a/lib/modules/manager/pep621/artifacts.spec.ts +++ b/lib/modules/manager/pep621/artifacts.spec.ts @@ -123,7 +123,7 @@ requires-python = "<3.9" '&& ' + 'install-tool pdm v2.5.0 ' + '&& ' + - 'pdm update dep1' + + 'pdm update --no-sync dep1' + '"', options: { cwd: '/tmp/github/some/repo', diff --git a/lib/modules/manager/pep621/processors/pdm.spec.ts b/lib/modules/manager/pep621/processors/pdm.spec.ts index a7588535d0e567..4e1c77a1f4ae4c 100644 --- a/lib/modules/manager/pep621/processors/pdm.spec.ts +++ b/lib/modules/manager/pep621/processors/pdm.spec.ts @@ -86,7 +86,7 @@ describe('modules/manager/pep621/processors/pdm', () => { '&& ' + 'install-tool pdm v2.5.0 ' + '&& ' + - 'pdm update dep1' + + 'pdm update --no-sync dep1' + '"', }, ]); @@ -173,16 +173,16 @@ describe('modules/manager/pep621/processors/pdm', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'pdm update dep1 dep2', + cmd: 'pdm update --no-sync dep1 dep2', }, { - cmd: 'pdm update -G group1 dep3 dep4', + cmd: 'pdm update --no-sync -G group1 dep3 dep4', }, { - cmd: 'pdm update -dG group2 dep5 dep6', + cmd: 'pdm update --no-sync -dG group2 dep5 dep6', }, { - cmd: 'pdm update -dG group3 dep7 dep8', + cmd: 'pdm update --no-sync -dG group3 dep7 dep8', }, ]); }); @@ -224,7 +224,7 @@ describe('modules/manager/pep621/processors/pdm', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'pdm update', + cmd: 'pdm update --no-sync', options: { cwd: '/tmp/github/some/repo/folder', }, diff --git a/lib/modules/manager/pep621/processors/pdm.ts b/lib/modules/manager/pep621/processors/pdm.ts index 365c2d2a64ad41..9e630952f9e957 100644 --- a/lib/modules/manager/pep621/processors/pdm.ts +++ b/lib/modules/manager/pep621/processors/pdm.ts @@ -15,6 +15,8 @@ import type { PyProject } from '../schema'; import { depTypes, parseDependencyGroupRecord } from '../utils'; import type { PyProjectProcessor } from './types'; +const pdmUpdateCMD = 'pdm update --no-sync'; + export class PdmProcessor implements PyProjectProcessor { process(project: PyProject, deps: PackageDependency[]): PackageDependency[] { const pdm = project.tool?.pdm; @@ -87,7 +89,7 @@ export class PdmProcessor implements PyProjectProcessor { // else only update specific packages const cmds: string[] = []; if (isLockFileMaintenance) { - cmds.push('pdm update'); + cmds.push(pdmUpdateCMD); } else { cmds.push(...generateCMDs(updatedDeps)); } @@ -135,16 +137,24 @@ function generateCMDs(updatedDeps: Upgrade[]): string[] { switch (dep.depType) { case depTypes.optionalDependencies: { const [group, name] = dep.depName!.split('/'); - addPackageToCMDRecord(packagesByCMD, `pdm update -G ${group}`, name); + addPackageToCMDRecord( + packagesByCMD, + `${pdmUpdateCMD} -G ${group}`, + name + ); break; } case depTypes.pdmDevDependencies: { const [group, name] = dep.depName!.split('/'); - addPackageToCMDRecord(packagesByCMD, `pdm update -dG ${group}`, name); + addPackageToCMDRecord( + packagesByCMD, + `${pdmUpdateCMD} -dG ${group}`, + name + ); break; } default: { - addPackageToCMDRecord(packagesByCMD, `pdm update`, dep.packageName!); + addPackageToCMDRecord(packagesByCMD, pdmUpdateCMD, dep.packageName!); } } }