Skip to content

Commit

Permalink
feat(pip_requirements): allow override hashin constraints (#26037)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Nov 29, 2023
1 parent 4b7a5e7 commit 591b572
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lib/modules/manager/pip_requirements/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' +
'"',
Expand Down Expand Up @@ -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' },
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/pip_requirements/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion lib/modules/manager/pipenv/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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' } },
]);
});
Expand Down
9 changes: 9 additions & 0 deletions lib/util/exec/containerbase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down

0 comments on commit 591b572

Please sign in to comment.