feat(manager): enable pipenv lockfile maintance (#6096)

This commit is contained in:
Daniel Barrett 2020-04-30 20:06:37 +10:00 committed by GitHub
parent 317a41a43e
commit 84b7eede50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 1 deletions

View file

@ -57,6 +57,29 @@ Array [
]
`;
exports[`.updateArtifacts() returns updated Pipenv.lock when doing lockfile maintenance 1`] = `
Array [
Object {
"cmd": "pipenv lock",
"options": Object {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": Object {
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
"LANG": "en_US.UTF-8",
"LC_ALL": "en_US",
"NO_PROXY": "localhost",
"PATH": "/tmp/path",
"PIPENV_CACHE_DIR": "/tmp/renovate/cache/others/pipenv",
},
"timeout": 900000,
},
},
]
`;
exports[`.updateArtifacts() returns updated Pipfile.lock 1`] = `
Array [
Object {

View file

@ -34,6 +34,7 @@ const config = {
};
const dockerConfig = { ...config, binarySource: BinarySource.Docker };
const lockMaintenceConfig = { ...config, isLockFileMaintenance: true };
describe('.updateArtifacts()', () => {
let pipFileLock;
@ -139,4 +140,21 @@ describe('.updateArtifacts()', () => {
})
).toMatchSnapshot();
});
it('returns updated Pipenv.lock when doing lockfile maintenance', async () => {
platform.getFile.mockResolvedValueOnce('Current Pipfile.lock');
const execSnapshots = mockExecAll(exec);
platform.getRepoStatus.mockResolvedValue({
modified: ['Pipfile.lock'],
} as StatusResult);
fs.readFile.mockReturnValueOnce('New Pipfile.lock' as any);
expect(
await pipenv.updateArtifacts({
packageFileName: 'Pipfile',
updatedDeps: [],
newPackageFileContent: '{}',
config: lockMaintenceConfig,
})
).not.toBeNull();
expect(execSnapshots).toMatchSnapshot();
});
});

View file

@ -1,4 +1,4 @@
import { ensureDir, outputFile, readFile } from 'fs-extra';
import { ensureDir, outputFile, readFile, remove } from 'fs-extra';
import { join } from 'upath';
import { exec, ExecOptions } from '../../util/exec';
import { logger } from '../../logger';
@ -56,6 +56,9 @@ export async function updateArtifacts({
const localPipfileFileName = join(config.localDir, pipfileName);
await outputFile(localPipfileFileName, newPipfileContent);
const localLockFileName = join(config.localDir, lockFileName);
if (config.isLockFileMaintenance) {
await remove(localLockFileName);
}
const cmd = 'pipenv lock';
const tagConstraint = getPythonConstraint(existingLockFileContent, config);
const execOptions: ExecOptions = {

View file

@ -4,6 +4,7 @@ export { extractPackageFile } from './extract';
export { updateArtifacts } from './artifacts';
export const language = LANGUAGE_PYTHON;
export const supportsLockFileMaintenance = true;
export const defaultConfig = {
fileMatch: ['(^|/)Pipfile$'],