From 591b572edabb1506da0fc82808d8c2878817cda3 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Wed, 29 Nov 2023 19:17:39 +0100 Subject: [PATCH] feat(pip_requirements): allow override hashin constraints (#26037) --- .../manager/pip_requirements/artifacts.spec.ts | 8 +++++--- lib/modules/manager/pip_requirements/artifacts.ts | 2 +- .../pipenv/__snapshots__/artifacts.spec.ts.snap | 2 +- lib/modules/manager/pipenv/artifacts.spec.ts | 11 ++++++++++- lib/util/exec/containerbase.spec.ts | 9 +++++++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/modules/manager/pip_requirements/artifacts.spec.ts b/lib/modules/manager/pip_requirements/artifacts.spec.ts index d82910c9df68d7..052dabf077bf12 100644 --- a/lib/modules/manager/pip_requirements/artifacts.spec.ts +++ b/lib/modules/manager/pip_requirements/artifacts.spec.ts @@ -23,7 +23,9 @@ const adminConfig: RepoGlobalConfig = { containerbaseDir: join('/tmp/renovate/cache/containerbase'), }; -const config: UpdateArtifactsConfig = { constraints: { python: '3.10.2' } }; +const config: UpdateArtifactsConfig = { + constraints: { python: '3.10.2', hashin: '0.17.0' }, +}; /* * Sample package file content that exhibits dependencies with and without @@ -231,7 +233,7 @@ describe('modules/manager/pip_requirements/artifacts', () => { 'bash -l -c "' + 'install-tool python 3.10.2 ' + '&& ' + - 'install-tool hashin 0.1.7 ' + + 'install-tool hashin 0.17.0 ' + '&& ' + 'hashin atomicwrites==1.4.0 -r requirements.txt' + '"', @@ -266,7 +268,7 @@ describe('modules/manager/pip_requirements/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { cmd: 'install-tool python 3.10.2' }, - { cmd: 'install-tool hashin 0.1.7' }, + { cmd: 'install-tool hashin 0.17.0' }, { cmd: 'hashin atomicwrites==1.4.0 -r requirements.txt', options: { cwd: '/tmp/github/some/repo' }, diff --git a/lib/modules/manager/pip_requirements/artifacts.ts b/lib/modules/manager/pip_requirements/artifacts.ts index d1c92e7f5351bf..82053e6ea07909 100644 --- a/lib/modules/manager/pip_requirements/artifacts.ts +++ b/lib/modules/manager/pip_requirements/artifacts.ts @@ -71,7 +71,7 @@ export async function updateArtifacts({ docker: {}, toolConstraints: [ { toolName: 'python', constraint: config.constraints?.python }, - { toolName: 'hashin' }, + { toolName: 'hashin', constraint: config.constraints?.hashin }, ], extraEnv: { PIP_CACHE_DIR: await ensureCacheDir('pip'), diff --git a/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap index d08dc91b55db39..396bc4f6f50164 100644 --- a/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap @@ -111,7 +111,7 @@ exports[`modules/manager/pipenv/artifacts supports docker mode 1`] = ` }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e PIP_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool python 3.7.6 && install-tool pipenv 2023.1.2 && pipenv lock"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e PIP_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool python 3.7.6 && install-tool pipenv 2013.6.12 && pipenv lock"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", diff --git a/lib/modules/manager/pipenv/artifacts.spec.ts b/lib/modules/manager/pipenv/artifacts.spec.ts index 059f7fd61916a6..943c607c14c518 100644 --- a/lib/modules/manager/pipenv/artifacts.spec.ts +++ b/lib/modules/manager/pipenv/artifacts.spec.ts @@ -77,6 +77,15 @@ describe('modules/manager/pipenv/artifacts', () => { { version: '3.10.2' }, ], }); + + // pipenv + getPkgReleases.mockResolvedValueOnce({ + releases: [ + { version: '2013.5.19' }, + { version: '2013.6.11' }, + { version: '2013.6.12' }, + ], + }); }); it('returns if no Pipfile.lock found', async () => { @@ -209,7 +218,7 @@ describe('modules/manager/pipenv/artifacts', () => { ).not.toBeNull(); expect(execSnapshots).toMatchObject([ { cmd: 'install-tool python 3.7.6' }, - { cmd: 'install-tool pipenv 2023.1.2' }, + { cmd: 'install-tool pipenv 2013.6.12' }, { cmd: 'pipenv lock', options: { cwd: '/tmp/github/some/repo' } }, ]); }); diff --git a/lib/util/exec/containerbase.spec.ts b/lib/util/exec/containerbase.spec.ts index 40e1bea053e39d..0f73c6f74b053a 100644 --- a/lib/util/exec/containerbase.spec.ts +++ b/lib/util/exec/containerbase.spec.ts @@ -163,6 +163,15 @@ describe('util/exec/containerbase', () => { ).toBe(expected); }, ); + + it('removes pep440 ==', async () => { + expect( + await resolveConstraint({ + toolName: 'pipenv', + constraint: '==2020.8.13', + }), + ).toBe('2020.8.13'); + }); }); describe('generateInstallCommands()', () => {