rewrite retry logic
This commit is contained in:
+23
-29
@@ -490,40 +490,34 @@ function delay(ms) {
|
|||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function getComparison(baseRef, headRef, opts) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const comparison = yield dependencyGraph.compare({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
baseRef,
|
||||||
|
headRef
|
||||||
|
});
|
||||||
|
if (comparison.snapshot_warnings.trim() !== '' && opts.retries > 0) {
|
||||||
|
core.info(comparison.snapshot_warnings);
|
||||||
|
core.info('Retrying in 10 seconds...');
|
||||||
|
yield delay(opts.retryDelay);
|
||||||
|
return getComparison(baseRef, headRef, Object.assign(Object.assign({}, opts), { retries: opts.retries - 1 }));
|
||||||
|
}
|
||||||
|
return comparison;
|
||||||
|
});
|
||||||
|
}
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const config = yield (0, config_1.readConfig)();
|
const config = yield (0, config_1.readConfig)();
|
||||||
const refs = (0, git_refs_1.getRefs)(config, github.context);
|
const refs = (0, git_refs_1.getRefs)(config, github.context);
|
||||||
let changes;
|
const comparison = yield getComparison(refs.base, refs.head, {
|
||||||
let snapshot_warnings;
|
retries: 10,
|
||||||
let i = 0;
|
retryDelay: 10000
|
||||||
while (true) {
|
});
|
||||||
const comparison = yield dependencyGraph.compare({
|
const changes = comparison.changes;
|
||||||
owner: github.context.repo.owner,
|
const snapshot_warnings = comparison.snapshot_warnings;
|
||||||
repo: github.context.repo.repo,
|
|
||||||
baseRef: refs.base,
|
|
||||||
headRef: refs.head
|
|
||||||
});
|
|
||||||
if (i >= 12) {
|
|
||||||
core.info(comparison.snapshot_warnings);
|
|
||||||
core.info('Proceeding...');
|
|
||||||
changes = comparison.changes;
|
|
||||||
snapshot_warnings = comparison.snapshot_warnings;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (comparison.snapshot_warnings.trim() !== '') {
|
|
||||||
core.info(comparison.snapshot_warnings);
|
|
||||||
core.info('Retrying in 10 seconds...');
|
|
||||||
yield delay(10000);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changes = comparison.changes;
|
|
||||||
snapshot_warnings = comparison.snapshot_warnings;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (!changes) {
|
if (!changes) {
|
||||||
core.info('No Dependency Changes found. Skipping Dependency Review.');
|
core.info('No Dependency Changes found. Skipping Dependency Review.');
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+30
-27
@@ -21,39 +21,42 @@ async function delay(ms: number): Promise<void> {
|
|||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
return new Promise(resolve => setTimeout(resolve, ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getComparison(
|
||||||
|
baseRef: string,
|
||||||
|
headRef: string,
|
||||||
|
opts: {
|
||||||
|
retries: number
|
||||||
|
retryDelay: number
|
||||||
|
}
|
||||||
|
): ReturnType<typeof dependencyGraph.compare> {
|
||||||
|
const comparison = await dependencyGraph.compare({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
baseRef,
|
||||||
|
headRef
|
||||||
|
})
|
||||||
|
if (comparison.snapshot_warnings.trim() !== '' && opts.retries > 0) {
|
||||||
|
core.info(comparison.snapshot_warnings)
|
||||||
|
core.info('Retrying in 10 seconds...')
|
||||||
|
await delay(opts.retryDelay)
|
||||||
|
return getComparison(baseRef, headRef, {...opts, retries: opts.retries - 1})
|
||||||
|
}
|
||||||
|
return comparison
|
||||||
|
}
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const config = await readConfig()
|
const config = await readConfig()
|
||||||
|
|
||||||
const refs = getRefs(config, github.context)
|
const refs = getRefs(config, github.context)
|
||||||
|
|
||||||
let changes
|
const comparison = await getComparison(refs.base, refs.head, {
|
||||||
let snapshot_warnings
|
retries: 10,
|
||||||
let i = 0
|
retryDelay: 10_000
|
||||||
while (true) {
|
})
|
||||||
const comparison = await dependencyGraph.compare({
|
|
||||||
owner: github.context.repo.owner,
|
const changes = comparison.changes
|
||||||
repo: github.context.repo.repo,
|
const snapshot_warnings = comparison.snapshot_warnings
|
||||||
baseRef: refs.base,
|
|
||||||
headRef: refs.head
|
|
||||||
})
|
|
||||||
if (i >= 12) {
|
|
||||||
core.info(comparison.snapshot_warnings)
|
|
||||||
core.info('Proceeding...')
|
|
||||||
changes = comparison.changes
|
|
||||||
snapshot_warnings = comparison.snapshot_warnings
|
|
||||||
break
|
|
||||||
} else if (comparison.snapshot_warnings.trim() !== '') {
|
|
||||||
core.info(comparison.snapshot_warnings)
|
|
||||||
core.info('Retrying in 10 seconds...')
|
|
||||||
await delay(10000)
|
|
||||||
} else {
|
|
||||||
changes = comparison.changes
|
|
||||||
snapshot_warnings = comparison.snapshot_warnings
|
|
||||||
break
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!changes) {
|
if (!changes) {
|
||||||
core.info('No Dependency Changes found. Skipping Dependency Review.')
|
core.info('No Dependency Changes found. Skipping Dependency Review.')
|
||||||
|
|||||||
Reference in New Issue
Block a user