mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(pip-compile): Correctly report errors when a lock file is unchanged (#29363)
This commit is contained in:
parent
4313b9b329
commit
635854e321
2 changed files with 42 additions and 12 deletions
|
@ -1,7 +1,11 @@
|
|||
import { codeBlock } from 'common-tags';
|
||||
import { mockDeep } from 'jest-mock-extended';
|
||||
import { join } from 'upath';
|
||||
import { envMock, mockExecAll } from '../../../../test/exec-util';
|
||||
import {
|
||||
envMock,
|
||||
mockExecAll,
|
||||
mockExecSequence,
|
||||
} from '../../../../test/exec-util';
|
||||
import { Fixtures } from '../../../../test/fixtures';
|
||||
import { env, fs, git, mocked, partial } from '../../../../test/util';
|
||||
import { GlobalConfig } from '../../../config/global';
|
||||
|
@ -80,7 +84,7 @@ describe('modules/manager/pip-compile/artifacts', () => {
|
|||
expect(execSnapshots).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns null if unchanged', async () => {
|
||||
it('returns null if all unchanged', async () => {
|
||||
fs.readLocalFile.mockResolvedValueOnce(simpleHeader);
|
||||
const execSnapshots = mockExecAll();
|
||||
fs.readLocalFile.mockResolvedValueOnce('new lock');
|
||||
|
@ -615,5 +619,32 @@ describe('modules/manager/pip-compile/artifacts', () => {
|
|||
'pip-compile --output-file=requirements.txt requirements.in --upgrade-package=foo==1.0.2 --upgrade-package=bar==2.0.0',
|
||||
);
|
||||
});
|
||||
|
||||
it('reports errors when a lock file is unchanged', async () => {
|
||||
fs.readLocalFile.mockResolvedValue(simpleHeader);
|
||||
mockExecSequence([
|
||||
new Error('Oh noes!'),
|
||||
{ stdout: 'This one worked', stderr: '' },
|
||||
]);
|
||||
git.getRepoStatus.mockResolvedValue(
|
||||
partial<StatusResult>({
|
||||
modified: [],
|
||||
}),
|
||||
);
|
||||
const results = await updateArtifacts({
|
||||
packageFileName: 'requirements.in',
|
||||
updatedDeps: [],
|
||||
newPackageFileContent: 'some new content',
|
||||
config: {
|
||||
...config,
|
||||
lockFiles: ['requirements1.txt', 'requirements2.txt'],
|
||||
},
|
||||
});
|
||||
expect(results).toMatchObject([
|
||||
{
|
||||
artifactError: { lockFile: 'requirements1.txt', stderr: 'Oh noes!' },
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -125,16 +125,15 @@ export async function updateArtifacts({
|
|||
logger.trace({ env: execOptions.extraEnv }, 'pip-compile extra env vars');
|
||||
await exec(cmd, execOptions);
|
||||
const status = await getRepoStatus();
|
||||
if (!status?.modified.includes(outputFileName)) {
|
||||
return null;
|
||||
if (status?.modified.includes(outputFileName)) {
|
||||
result.push({
|
||||
file: {
|
||||
type: 'addition',
|
||||
path: outputFileName,
|
||||
contents: await readLocalFile(outputFileName, 'utf8'),
|
||||
},
|
||||
});
|
||||
}
|
||||
result.push({
|
||||
file: {
|
||||
type: 'addition',
|
||||
path: outputFileName,
|
||||
contents: await readLocalFile(outputFileName, 'utf8'),
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
// istanbul ignore if
|
||||
if (err.message === TEMPORARY_ERROR) {
|
||||
|
@ -150,5 +149,5 @@ export async function updateArtifacts({
|
|||
}
|
||||
}
|
||||
logger.debug('pip-compile: Returning updated output file(s)');
|
||||
return result;
|
||||
return result.length === 0 ? null : result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue