Skip to content

Commit

Permalink
feat(manager/pipenv): support binarySource=install (#16828)
Browse files Browse the repository at this point in the history
* feat(manager/pipenv): support binarySource=install

* docs: update docs

* fix: linting
  • Loading branch information
viceice committed Jul 28, 2022
1 parent 16705ed commit a3d1235
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
5 changes: 5 additions & 0 deletions docs/usage/self-hosted-configuration.md
Expand Up @@ -141,11 +141,16 @@ This mode means that Renovate will dynamically install the version of tools avai

Supported tools for dynamic install are:

- `bundler`
- `cargo`
- `composer`
- `flux`
- `gradle-wrapper`
- `jb`
- `jsonnet-bundler`
- `mix`
- `npm`
- `pipenv`

Tools not on this list fall back to `binarySource=global`.

Expand Down
24 changes: 12 additions & 12 deletions lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap
Expand Up @@ -99,19 +99,19 @@ Array [
exports[`modules/manager/pipenv/artifacts supports docker mode 1`] = `
Array [
Object {
"cmd": "docker pull renovate/python:latest",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_python -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker run --rm --name=renovate_python --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/python:latest bash -l -c \\"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 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",
Expand All @@ -136,19 +136,19 @@ Array [
exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile 1`] = `
Array [
Object {
"cmd": "docker pull renovate/python",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_python -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker run --rm --name=renovate_python --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/python bash -l -c \\"pip install --user pipenv==2020.8.13 && 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 BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 3.10.2 && pip install --user pipenv==2020.8.13 && pipenv lock\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand All @@ -173,19 +173,19 @@ Array [
exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile dev packages 1`] = `
Array [
Object {
"cmd": "docker pull renovate/python",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_python -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker run --rm --name=renovate_python --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/python bash -l -c \\"pip install --user pipenv==2020.8.13 && 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 BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 3.10.2 && pip install --user pipenv==2020.8.13 && pipenv lock\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand All @@ -210,19 +210,19 @@ Array [
exports[`modules/manager/pipenv/artifacts uses pipenv version from config 1`] = `
Array [
Object {
"cmd": "docker pull renovate/python",
"cmd": "docker pull renovate/sidecar",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker ps --filter name=renovate_python -aq",
"cmd": "docker ps --filter name=renovate_sidecar -aq",
"options": Object {
"encoding": "utf-8",
},
},
Object {
"cmd": "docker run --rm --name=renovate_python --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/python bash -l -c \\"pip install --user pipenv==2020.1.1 && 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 BUILDPACK_CACHE_DIR -w \\"/tmp/github/some/repo\\" renovate/sidecar bash -l -c \\"install-tool python 3.10.2 && pip install --user pipenv==2020.1.1 && pipenv lock\\"",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
Expand Down
15 changes: 14 additions & 1 deletion lib/modules/manager/pipenv/artifacts.spec.ts
@@ -1,10 +1,11 @@
import { join } from 'upath';
import { envMock, mockExecAll } from '../../../../test/exec-util';
import { env, fs, git } from '../../../../test/util';
import { env, fs, git, mockedFunction } from '../../../../test/util';
import { GlobalConfig } from '../../../config/global';
import type { RepoGlobalConfig } from '../../../config/types';
import * as docker from '../../../util/exec/docker';
import type { StatusResult } from '../../../util/git/types';
import { getPkgReleases as _getPkgReleases } from '../../datasource';
import type { UpdateArtifactsConfig } from '../types';
import * as pipenv from '.';

Expand All @@ -13,6 +14,9 @@ jest.mock('../../../util/git');
jest.mock('../../../util/fs');
jest.mock('../../../util/host-rules');
jest.mock('../../../util/http');
jest.mock('../../datasource');

const getPkgReleases = mockedFunction(_getPkgReleases);

const adminConfig: RepoGlobalConfig = {
// `join` fixes Windows CI
Expand Down Expand Up @@ -43,6 +47,15 @@ describe('modules/manager/pipenv/artifacts', () => {
default: { pipenv: {} },
develop: { pipenv: {} },
};

// python
getPkgReleases.mockResolvedValueOnce({
releases: [
{ version: '3.8.5' },
{ version: '3.9.1' },
{ version: '3.10.2' },
],
});
});

it('returns if no Pipfile.lock found', async () => {
Expand Down
10 changes: 7 additions & 3 deletions lib/modules/manager/pipenv/artifacts.ts
Expand Up @@ -101,11 +101,15 @@ export async function updateArtifacts({
PIPENV_CACHE_DIR: await ensureCacheDir('pipenv'),
},
docker: {
image: 'python',
tagConstraint,
tagScheme: 'pep440',
image: 'sidecar',
},
preCommands: [`pip install --user ${quote(`pipenv${pipenvConstraint}`)}`],
toolConstraints: [
{
toolName: 'python',
constraint: tagConstraint,
},
],
};
logger.debug({ cmd }, 'pipenv lock command');
await exec(cmd, execOptions);
Expand Down
5 changes: 5 additions & 0 deletions lib/util/exec/buildpack.ts
Expand Up @@ -79,6 +79,11 @@ const allToolConfig: Record<string, ToolConfig> = {
depName: 'poetry',
versioning: pep440VersioningId,
},
python: {
datasource: 'github-releases',
depName: 'containerbase/python-prebuild',
versioning: pep440VersioningId,
},
yarn: {
datasource: 'npm',
depName: 'yarn',
Expand Down

0 comments on commit a3d1235

Please sign in to comment.