mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat: restart renovation after github error
When 404 or 422 errors are encountered writing updates, Renovate will now restart in an attempt to fix it. Usually this is because branches/PRs have been edited or closed while Renovate is running. Closes #1299
This commit is contained in:
parent
f8b78ac347
commit
eb579ff388
5 changed files with 20 additions and 0 deletions
|
@ -116,6 +116,11 @@ async function processBranch(branchConfig) {
|
||||||
config.forcePr = true;
|
config.forcePr = true;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// istanbul ignore if
|
||||||
|
if (err.statusCode === 404 || err.statusCode === 422) {
|
||||||
|
logger.warn({ err }, `Error updating branch: ${err.message}`);
|
||||||
|
return 'platform-error';
|
||||||
|
}
|
||||||
logger.error({ err }, `Error updating branch: ${err.message}`);
|
logger.error({ err }, `Error updating branch: ${err.message}`);
|
||||||
// Don't throw here - we don't want to stop the other renovations
|
// Don't throw here - we don't want to stop the other renovations
|
||||||
return 'error';
|
return 'error';
|
||||||
|
|
|
@ -32,6 +32,10 @@ async function renovateRepository(repoConfig, token, loop = 1) {
|
||||||
logger.info('Restarting repo renovation after automerge');
|
logger.info('Restarting repo renovation after automerge');
|
||||||
return renovateRepository(repoConfig, token, loop + 1);
|
return renovateRepository(repoConfig, token, loop + 1);
|
||||||
}
|
}
|
||||||
|
if (res === 'platform-error') {
|
||||||
|
logger.info('Restarting renovation after platform error');
|
||||||
|
return renovateRepository(repoConfig, token, loop + 1);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return handleError(config, err);
|
return handleError(config, err);
|
||||||
|
|
|
@ -21,6 +21,9 @@ async function writeUpdates(config) {
|
||||||
// Stop procesing other branches because base branch has been changed by an automerge
|
// Stop procesing other branches because base branch has been changed by an automerge
|
||||||
return 'automerged';
|
return 'automerged';
|
||||||
}
|
}
|
||||||
|
if (res === 'platform-error') {
|
||||||
|
return 'platform-error';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 'done';
|
return 'done';
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -28,6 +28,7 @@ describe('workers/repository', () => {
|
||||||
it('writes', async () => {
|
it('writes', async () => {
|
||||||
determineUpdates.mockReturnValue({ repoIsOnboarded: true });
|
determineUpdates.mockReturnValue({ repoIsOnboarded: true });
|
||||||
writeUpdates.mockReturnValueOnce('automerged');
|
writeUpdates.mockReturnValueOnce('automerged');
|
||||||
|
writeUpdates.mockReturnValueOnce('platform-error');
|
||||||
writeUpdates.mockReturnValueOnce('onboarded');
|
writeUpdates.mockReturnValueOnce('onboarded');
|
||||||
const res = await renovateRepository(config, 'some-token');
|
const res = await renovateRepository(config, 'some-token');
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
|
|
|
@ -25,5 +25,12 @@ describe('workers/repository/write', () => {
|
||||||
expect(res).toEqual('automerged');
|
expect(res).toEqual('automerged');
|
||||||
expect(branchWorker.processBranch.mock.calls).toHaveLength(2);
|
expect(branchWorker.processBranch.mock.calls).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
it('stops after platform error', async () => {
|
||||||
|
config.branches = [{}, {}];
|
||||||
|
branchWorker.processBranch.mockReturnValueOnce('platform-error');
|
||||||
|
const res = await writeUpdates(config);
|
||||||
|
expect(res).toEqual('platform-error');
|
||||||
|
expect(branchWorker.processBranch.mock.calls).toHaveLength(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue