in robomaker-sample-app-ci/src/aws-robomaker-sample-application-ci.ts [141:178]
async function run() {
let delay_ms = 1000 * MINIMUM_BACKOFF_TIME_SECONDS;
console.log(`ROS_DISTRO: ${ROS_DISTRO}`);
console.log(`WORKSPACE_DIRECTORY: ${WORKSPACE_DIRECTORY}`);
console.log(`GENERATE_SOURCES: ${GENERATE_SOURCES}`);
console.log(`RETRIES: ${RETRIES}`);
// check if RETRIES is valid (i.e. 0<) and not too large (i.e. <10)
if (RETRIES<0 || 9<RETRIES){
core.setFailed(`Invalid number of retries. Must be between 0-9 inclusive`);
return;
}
for (let i = 0; i <= RETRIES; i++) {
try {
await setup();
if (GENERATE_SOURCES == 'true') {
await prepare_sources();
}
await installPyparsing();
await build();
await bundle();
core.setOutput('ros-distro', ROS_DISTRO)
core.setOutput('sample-app-version', SAMPLE_APP_VERSION);
break; //Break out of retry loop if successful.
} catch (error) {
await exec.exec("rm", ["-rf", "bundle"], getWorkingDirExecOptions()); // remove erred bundle assets
if (i == RETRIES){
core.setFailed(error.message); // set action to Failed after RETRIES number of retries
break;
}
console.log(`Action failed.. retrying in ${delay_ms} milliseconds`);
await delay(delay_ms); // wait for next retry per the current exponential backoff delay
delay_ms = Math.min(delay_ms * 2, 1000 * MAXIMUM_BACKOFF_TIME_SECONDS); // double the delay for the next retry, truncate if required
}
}
}