diff --git a/lib/modules/manager/pip-compile/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/pip-compile/__snapshots__/artifacts.spec.ts.snap index 5dc20e1ff92d45..04c3f4a1b394e2 100644 --- a/lib/modules/manager/pip-compile/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/pip-compile/__snapshots__/artifacts.spec.ts.snap @@ -15,6 +15,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/renovate/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -38,6 +39,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/renovate/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -61,6 +63,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/renovate/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, diff --git a/lib/modules/manager/pip-compile/artifacts.spec.ts b/lib/modules/manager/pip-compile/artifacts.spec.ts index 44614d2d0d637f..7fe989fd81babf 100644 --- a/lib/modules/manager/pip-compile/artifacts.spec.ts +++ b/lib/modules/manager/pip-compile/artifacts.spec.ts @@ -112,6 +112,7 @@ describe('modules/manager/pip-compile/artifacts', () => { '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 PIP_CACHE_DIR ' + '-e BUILDPACK_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + 'renovate/sidecar ' + @@ -216,6 +217,7 @@ describe('modules/manager/pip-compile/artifacts', () => { '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 PIP_CACHE_DIR ' + '-e BUILDPACK_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + 'renovate/sidecar ' + diff --git a/lib/modules/manager/pip-compile/artifacts.ts b/lib/modules/manager/pip-compile/artifacts.ts index 34b92468958e6b..2af44d13318f0f 100644 --- a/lib/modules/manager/pip-compile/artifacts.ts +++ b/lib/modules/manager/pip-compile/artifacts.ts @@ -7,6 +7,7 @@ import { exec } from '../../../util/exec'; import type { ExecOptions } from '../../../util/exec/types'; import { deleteLocalFile, + ensureCacheDir, readLocalFile, writeLocalFile, } from '../../../util/fs'; @@ -130,6 +131,9 @@ export async function updateArtifacts({ constraint, }, ], + extraEnv: { + PIP_CACHE_DIR: await ensureCacheDir('pip'), + }, }; logger.debug({ cmd }, 'pip-compile command'); await exec(cmd, execOptions); diff --git a/lib/modules/manager/pip_requirements/artifacts.spec.ts b/lib/modules/manager/pip_requirements/artifacts.spec.ts index d52eeca9802d6f..1ca4eb14f37555 100644 --- a/lib/modules/manager/pip_requirements/artifacts.spec.ts +++ b/lib/modules/manager/pip_requirements/artifacts.spec.ts @@ -134,6 +134,7 @@ describe('modules/manager/pip_requirements/artifacts', () => { it('supports docker mode', async () => { GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); fs.readLocalFile.mockResolvedValueOnce('new content'); + fs.ensureCacheDir.mockResolvedValueOnce('/tmp/cache'); const execSnapshots = mockExecAll(); expect( @@ -161,6 +162,7 @@ describe('modules/manager/pip_requirements/artifacts', () => { '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 PIP_CACHE_DIR ' + '-e BUILDPACK_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + 'renovate/sidecar ' + diff --git a/lib/modules/manager/pip_requirements/artifacts.ts b/lib/modules/manager/pip_requirements/artifacts.ts index f6b0ba63b3035c..060ca4c2ac1030 100644 --- a/lib/modules/manager/pip_requirements/artifacts.ts +++ b/lib/modules/manager/pip_requirements/artifacts.ts @@ -3,7 +3,7 @@ import { TEMPORARY_ERROR } from '../../../constants/error-messages'; import { logger } from '../../../logger'; import { exec } from '../../../util/exec'; import type { ExecOptions } from '../../../util/exec/types'; -import { readLocalFile } from '../../../util/fs'; +import { ensureCacheDir, readLocalFile } from '../../../util/fs'; import { newlineRegex, regEx } from '../../../util/regex'; import type { UpdateArtifact, UpdateArtifactsResult } from '../types'; @@ -48,6 +48,9 @@ export async function updateArtifacts({ toolConstraints: [ { toolName: 'python', constraint: config.constraints?.python }, ], + extraEnv: { + PIP_CACHE_DIR: await ensureCacheDir('pip'), + }, }; await exec(cmd, execOptions); const newContent = await readLocalFile(packageFileName, 'utf8'); diff --git a/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap index 0f0a0dcdb4590a..5137de4f93f826 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 @@ Array [ }, }, Object { - "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 BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 3.10.2 && pip install --user pipenv && 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 BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 3.10.2 && pip install --user pipenv && pipenv lock\\"", "options": Object { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -125,6 +125,7 @@ Array [ "NO_PROXY": "localhost", "PATH": "/tmp/path", "PIPENV_CACHE_DIR": "/tmp/renovate/cache/others/pipenv", + "PIP_CACHE_DIR": "/tmp/renovate/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, diff --git a/lib/modules/manager/pipenv/artifacts.spec.ts b/lib/modules/manager/pipenv/artifacts.spec.ts index 7eaf8bfeb500ec..2dd3caa80d12d7 100644 --- a/lib/modules/manager/pipenv/artifacts.spec.ts +++ b/lib/modules/manager/pipenv/artifacts.spec.ts @@ -135,6 +135,7 @@ describe('modules/manager/pipenv/artifacts', () => { fs.ensureCacheDir.mockResolvedValueOnce( '/tmp/renovate/cache/others/pipenv' ); + fs.ensureCacheDir.mockResolvedValueOnce('/tmp/renovate/cache/others/pip'); fs.readLocalFile.mockResolvedValueOnce(JSON.stringify(pipFileLock)); const execSnapshots = mockExecAll(); git.getRepoStatus.mockResolvedValue({ @@ -158,6 +159,7 @@ describe('modules/manager/pipenv/artifacts', () => { fs.ensureCacheDir.mockResolvedValueOnce( '/tmp/renovate/cache/others/pipenv' ); + fs.ensureCacheDir.mockResolvedValueOnce('/tmp/renovate/cache/others/pip'); fs.readLocalFile.mockResolvedValueOnce(JSON.stringify(pipFileLock)); const execSnapshots = mockExecAll(); git.getRepoStatus.mockResolvedValue({ diff --git a/lib/modules/manager/pipenv/artifacts.ts b/lib/modules/manager/pipenv/artifacts.ts index 506afc684a27cd..e6beb1b0999462 100644 --- a/lib/modules/manager/pipenv/artifacts.ts +++ b/lib/modules/manager/pipenv/artifacts.ts @@ -99,6 +99,7 @@ export async function updateArtifacts({ cwdFile: pipfileName, extraEnv: { PIPENV_CACHE_DIR: await ensureCacheDir('pipenv'), + PIP_CACHE_DIR: await ensureCacheDir('pip'), }, docker: { image: 'sidecar', diff --git a/lib/modules/manager/poetry/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/poetry/__snapshots__/artifacts.spec.ts.snap index 8667b513212163..dd7b68266df979 100644 --- a/lib/modules/manager/poetry/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/poetry/__snapshots__/artifacts.spec.ts.snap @@ -27,6 +27,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", "POETRY_HTTP_BASIC_FOUR_OH_FOUR_PASSWORD": "passwordFour", "POETRY_HTTP_BASIC_ONE_PASSWORD": "passwordOne", "POETRY_HTTP_BASIC_ONE_USERNAME": "usernameOne", @@ -54,6 +55,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", "POETRY_HTTP_BASIC_ONE_PASSWORD": "scoped-password", }, "maxBuffer": 10485760, @@ -78,6 +80,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -101,6 +104,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -124,7 +128,7 @@ Array [ }, }, Object { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 1.2.0 && pip install --user 'poetry>=1.0' && poetry update --lock --no-interaction dep1\\"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e PIP_CACHE_DIR -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 1.2.0 && pip install --user 'poetry>=1.0' && poetry update --lock --no-interaction dep1\\"", "options": Object { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -137,6 +141,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -160,7 +165,7 @@ Array [ }, }, Object { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 1.2.0 && pip install --user 'poetry>=1.0' && poetry update --lock --no-interaction dep1\\"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \\"/tmp/github/some/repo\\":\\"/tmp/github/some/repo\\" -v \\"/tmp/cache\\":\\"/tmp/cache\\" -e PIP_CACHE_DIR -e BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 1.2.0 && pip install --user 'poetry>=1.0' && poetry update --lock --no-interaction dep1\\"", "options": Object { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -173,6 +178,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -196,6 +202,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, @@ -219,6 +226,7 @@ Array [ "LC_ALL": "en_US", "NO_PROXY": "localhost", "PATH": "/tmp/path", + "PIP_CACHE_DIR": "/tmp/cache/others/pip", }, "maxBuffer": 10485760, "timeout": 900000, diff --git a/lib/modules/manager/poetry/artifacts.ts b/lib/modules/manager/poetry/artifacts.ts index 385e8f6040e5e9..8666fb2ef9c9f2 100644 --- a/lib/modules/manager/poetry/artifacts.ts +++ b/lib/modules/manager/poetry/artifacts.ts @@ -8,6 +8,7 @@ import { exec } from '../../../util/exec'; import type { ExecOptions } from '../../../util/exec/types'; import { deleteLocalFile, + ensureCacheDir, getSiblingFileName, readLocalFile, writeLocalFile, @@ -175,10 +176,10 @@ export async function updateArtifacts({ const constraint = getPythonConstraint(existingLockFileContent, config); const poetryVersion = config.constraints?.poetry ?? getPoetryRequirement(newPackageFileContent); - const extraEnv = getSourceCredentialVars( - newPackageFileContent, - packageFileName - ); + const extraEnv = { + ...getSourceCredentialVars(newPackageFileContent, packageFileName), + PIP_CACHE_DIR: await ensureCacheDir('pip'), + }; const execOptions: ExecOptions = { cwdFile: packageFileName,