From 4449bb85884330957de315adff34b0a4c72292ef Mon Sep 17 00:00:00 2001 From: Michael J Mulligan Date: Wed, 7 Apr 2021 21:10:35 +0100 Subject: [PATCH] Failover debugging. It is indicating it is not getting Check Suite Information, which is unlikely. --- dist/post_run/index.js | 23 +++++++++++++---------- dist/pre/index.js | 23 +++++++++++++---------- dist/run/index.js | 23 +++++++++++++---------- src/run.ts | 25 +++++++++++++++---------- 4 files changed, 54 insertions(+), 40 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 6506a8b..173bc7f 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -6767,18 +6767,22 @@ function fetchCheckSuiteId(runId) { .catch((e) => { throw `Unable to fetch Workflow Run: ${e}`; }); - if (currentRun.status === `in_progress`) { - // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` - currentCheckSuiteId = (_a = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`)))) !== null && _a !== void 0 ? _a : -1; - // The following SHOULD work, but alas - // currentCheckSuiteId = currentRun.check_suite_id - if (currentCheckSuiteId <= 0) { - throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}`; - } + if (!currentRun) { + throw `Unexpected error: No run returned`; + } + if (currentRun.status !== `in_progress`) { + throw `Unexpected error: Expected status of 'in_progress', got '${currentRun.status}': ` + util_1.inspect(currentRun); + } + // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` + currentCheckSuiteId = (_a = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`)))) !== null && _a !== void 0 ? _a : -1; + // The following SHOULD work, but alas + // currentCheckSuiteId = currentRun.check_suite_id + if (currentCheckSuiteId <= 0) { + throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}`; } } catch (e) { - core.info(`::error::Error Fetching Current Run: ${e}`); + core.info(`::error::Error Fetching Current Run (${runId}): ${e}`); } } return currentCheckSuiteId; @@ -6890,7 +6894,6 @@ function resolveCheckRunId(checkRunIdent) { } catch (e) { core.info(`::error::Unable to resolve Check Run ID: ${e}`); - core.info(`checkRunIdent = ` + util_1.inspect(checkRunIdent)); } } } diff --git a/dist/pre/index.js b/dist/pre/index.js index 242ad11..8c67cff 100644 --- a/dist/pre/index.js +++ b/dist/pre/index.js @@ -6767,18 +6767,22 @@ function fetchCheckSuiteId(runId) { .catch((e) => { throw `Unable to fetch Workflow Run: ${e}`; }); - if (currentRun.status === `in_progress`) { - // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` - currentCheckSuiteId = (_a = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`)))) !== null && _a !== void 0 ? _a : -1; - // The following SHOULD work, but alas - // currentCheckSuiteId = currentRun.check_suite_id - if (currentCheckSuiteId <= 0) { - throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}`; - } + if (!currentRun) { + throw `Unexpected error: No run returned`; + } + if (currentRun.status !== `in_progress`) { + throw `Unexpected error: Expected status of 'in_progress', got '${currentRun.status}': ` + util_1.inspect(currentRun); + } + // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` + currentCheckSuiteId = (_a = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`)))) !== null && _a !== void 0 ? _a : -1; + // The following SHOULD work, but alas + // currentCheckSuiteId = currentRun.check_suite_id + if (currentCheckSuiteId <= 0) { + throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}`; } } catch (e) { - core.info(`::error::Error Fetching Current Run: ${e}`); + core.info(`::error::Error Fetching Current Run (${runId}): ${e}`); } } return currentCheckSuiteId; @@ -6890,7 +6894,6 @@ function resolveCheckRunId(checkRunIdent) { } catch (e) { core.info(`::error::Unable to resolve Check Run ID: ${e}`); - core.info(`checkRunIdent = ` + util_1.inspect(checkRunIdent)); } } } diff --git a/dist/run/index.js b/dist/run/index.js index 37e0ba2..fab5406 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -6777,18 +6777,22 @@ function fetchCheckSuiteId(runId) { .catch((e) => { throw `Unable to fetch Workflow Run: ${e}`; }); - if (currentRun.status === `in_progress`) { - // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` - currentCheckSuiteId = (_a = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`)))) !== null && _a !== void 0 ? _a : -1; - // The following SHOULD work, but alas - // currentCheckSuiteId = currentRun.check_suite_id - if (currentCheckSuiteId <= 0) { - throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}`; - } + if (!currentRun) { + throw `Unexpected error: No run returned`; + } + if (currentRun.status !== `in_progress`) { + throw `Unexpected error: Expected status of 'in_progress', got '${currentRun.status}': ` + util_1.inspect(currentRun); + } + // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` + currentCheckSuiteId = (_a = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`)))) !== null && _a !== void 0 ? _a : -1; + // The following SHOULD work, but alas + // currentCheckSuiteId = currentRun.check_suite_id + if (currentCheckSuiteId <= 0) { + throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}`; } } catch (e) { - core.info(`::error::Error Fetching Current Run: ${e}`); + core.info(`::error::Error Fetching Current Run (${runId}): ${e}`); } } return currentCheckSuiteId; @@ -6900,7 +6904,6 @@ function resolveCheckRunId(checkRunIdent) { } catch (e) { core.info(`::error::Unable to resolve Check Run ID: ${e}`); - core.info(`checkRunIdent = ` + util_1.inspect(checkRunIdent)); } } } diff --git a/src/run.ts b/src/run.ts index eaef497..e65612f 100644 --- a/src/run.ts +++ b/src/run.ts @@ -117,17 +117,23 @@ async function fetchCheckSuiteId(runId: number): Promise { throw `Unable to fetch Workflow Run: ${e}` }) - if (currentRun.status === `in_progress`) { - // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` - currentCheckSuiteId = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`))) ?? -1 - // The following SHOULD work, but alas - // currentCheckSuiteId = currentRun.check_suite_id - if (currentCheckSuiteId <= 0) { - throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}` - } + if (!currentRun) { + throw `Unexpected error: No run returned` + } + + if (currentRun.status !== `in_progress`) { + throw `Unexpected error: Expected status of 'in_progress', got '${currentRun.status}': ` + inspect(currentRun) + } + + // The GitHub API it's self does present the `check_suite_id` property, but it is not documented or present returned object's `type` + currentCheckSuiteId = parseInt(currentRun.check_suite_url.substr(1 + currentRun.check_suite_url.lastIndexOf(`/`))) ?? -1 + // The following SHOULD work, but alas + // currentCheckSuiteId = currentRun.check_suite_id + if (currentCheckSuiteId <= 0) { + throw `Error extracting Check Suite ID from: ${currentRun.check_suite_url}` } } catch (e) { - core.info(`::error::Error Fetching Current Run: ${e}`) + core.info(`::error::Error Fetching Current Run (${runId}): ${e}`) } } return currentCheckSuiteId @@ -260,7 +266,6 @@ async function resolveCheckRunId(checkRunIdent: CheckRunIdent): Promise } } catch (e) { core.info(`::error::Unable to resolve Check Run ID: ${e}`) - core.info(`checkRunIdent = ` + inspect(checkRunIdent)) } } } else {