From 22bb90dc850cc340aca2a232e7c739003295292a Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:28:19 +0530 Subject: [PATCH 1/4] checking default --- action.yml | 27 ++++++++++++++------------- index.js | 6 +++--- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/action.yml b/action.yml index 809a4ba..1cd527d 100644 --- a/action.yml +++ b/action.yml @@ -1,27 +1,28 @@ -name: 'WebPageTest GitHub Action' -author: 'WebPageTest' -description: 'Automatically test code changes in WebPageTest and enforce performance budgets' +name: "WebPageTest GitHub Action" +author: "WebPageTest" +description: "Automatically test code changes in WebPageTest and enforce performance budgets" inputs: apiKey: - description: 'WebPageTest API Token' + description: "WebPageTest API Token" required: true urls: - description: 'List of URL(s) to test' + description: "List of URL(s) to test" required: true budget: - description: 'Path to WebPageTest testspecs.json file' + description: "Path to WebPageTest testspecs.json file" required: false label: - description: 'Label for test (shows up in WebPageTest)' + description: "Label for test (shows up in WebPageTest)" required: false wptOptions: - description: 'Path to JSON file with WebPageTest test options (see https://github.com/marcelduran/webpagetest-api#test-works-for-runtest-method-only)' + description: "Path to JSON file with WebPageTest test options (see https://github.com/marcelduran/webpagetest-api#test-works-for-runtest-method-only)" required: false GITHUB_TOKEN: - description: 'Secret GitHub Token (automatically provided by GitHub)' + description: "Secret GitHub Token (automatically provided by GitHub)" + default: ${{ github.token }} runs: - using: 'node12' - main: 'index.js' + using: "node12" + main: "index.js" branding: - icon: 'bar-chart-2' - color: 'blue' \ No newline at end of file + icon: "bar-chart-2" + color: "blue" diff --git a/index.js b/index.js index dfbc7bb..e32d065 100644 --- a/index.js +++ b/index.js @@ -80,7 +80,7 @@ async function renderComment(data) { body: markdown, }); } catch (e) { - console.log(e); + console.log(e.Error); core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); } } @@ -192,12 +192,12 @@ async function run() { return; } } catch (e) { - console.log(e); + console.log(e.Error); core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); } }); } catch (e) { - console.log(e); + console.log(e.Error); core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); } }) From e3100b8a0d9e960e74139b9025824a841dcab549 Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:30:37 +0530 Subject: [PATCH 2/4] checking without default --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 1cd527d..97b51db 100644 --- a/action.yml +++ b/action.yml @@ -19,7 +19,6 @@ inputs: required: false GITHUB_TOKEN: description: "Secret GitHub Token (automatically provided by GitHub)" - default: ${{ github.token }} runs: using: "node12" main: "index.js" From d99fc2556be8437d949b43b51e47faed4af2fedd Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:34:11 +0530 Subject: [PATCH 3/4] checking without default --- index.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index e32d065..0368f57 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ const runTest = (wpt, url, options) => { return reject(err); } } catch (e) { - core.info(e.statusText || JSON.stringify(e)); + core.info(e || JSON.stringify(e)); } }); }); @@ -80,8 +80,7 @@ async function renderComment(data) { body: markdown, }); } catch (e) { - console.log(e.Error); - core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); + core.setFailed(`Action failed with error: ${JSON.stringify(e)}`); } } function collectData(results, runData) { @@ -192,13 +191,11 @@ async function run() { return; } } catch (e) { - console.log(e.Error); - core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); + core.setFailed(`Action failed with error: ${JSON.stringify(e)}`); } }); } catch (e) { - console.log(e.Error); - core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); + core.setFailed(`Action failed with error: ${JSON.stringify(e)}`); } }) ).then(() => { From 4e761dd103788d825c4adda38ce8b2dba8eb0285 Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:36:48 +0530 Subject: [PATCH 4/4] checking without default --- action.yml | 1 + index.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 97b51db..1cd527d 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,7 @@ inputs: required: false GITHUB_TOKEN: description: "Secret GitHub Token (automatically provided by GitHub)" + default: ${{ github.token }} runs: using: "node12" main: "index.js" diff --git a/index.js b/index.js index 0368f57..dfbc7bb 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ const runTest = (wpt, url, options) => { return reject(err); } } catch (e) { - core.info(e || JSON.stringify(e)); + core.info(e.statusText || JSON.stringify(e)); } }); }); @@ -80,7 +80,8 @@ async function renderComment(data) { body: markdown, }); } catch (e) { - core.setFailed(`Action failed with error: ${JSON.stringify(e)}`); + console.log(e); + core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); } } function collectData(results, runData) { @@ -191,11 +192,13 @@ async function run() { return; } } catch (e) { - core.setFailed(`Action failed with error: ${JSON.stringify(e)}`); + console.log(e); + core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); } }); } catch (e) { - core.setFailed(`Action failed with error: ${JSON.stringify(e)}`); + console.log(e); + core.setFailed(`Action failed with error: ${e.statusText || JSON.stringify(e)}`); } }) ).then(() => {