From 1fdaa47b9f39fe290ab2255c4a59589194ce87b9 Mon Sep 17 00:00:00 2001 From: jonataspinto Date: Sun, 1 May 2022 01:09:11 -0300 Subject: [PATCH] feat: add suport to receive path of result --- action.yml | 5 +++++ dist/index.js | 6 ++++-- index.js | 6 ++++-- package-lock.json | 29 +++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 package-lock.json diff --git a/action.yml b/action.yml index b7b7f82..ee89f03 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,10 @@ name: "Read Result of tests" description: "Greet someone and record the time" +inputs: + resultPath: # id of input + description: "Path to result file" + required: false + default: "./result.json" outputs: resultOfOutputTests: description: "A result of tests parsed to string" diff --git a/dist/index.js b/dist/index.js index cf68ccd..361bd21 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1969,10 +1969,12 @@ var __webpack_exports__ = {}; (() => { const fs = __nccwpck_require__(147); const core = __nccwpck_require__(469); -const jestOuputFile = fs.readFileSync("./result.json"); -const data = JSON.parse(jestOuputFile) + try { + const resultPath = core.getInput('resultPath'); + const jestOuputFile = fs.readFileSync(resultPath); + const data = JSON.parse(jestOuputFile) core.setOutput("resultOfOutputTests", JSON.stringify(data)); } catch (error) { core.setFailed(error.message); diff --git a/index.js b/index.js index 13ea2a7..8f6acc4 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ const fs = require("fs"); const core = require('@actions/core'); -const jestOuputFile = fs.readFileSync("./result.json"); -const data = JSON.parse(jestOuputFile) + try { + const resultPath = core.getInput('resultPath'); + const jestOuputFile = fs.readFileSync(resultPath); + const data = JSON.parse(jestOuputFile) core.setOutput("resultOfOutputTests", JSON.stringify(data)); } catch (error) { core.setFailed(error.message); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..548ba6f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,29 @@ +{ + "name": "capture-test-result-action", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@actions/core": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz", + "integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==", + "requires": { + "@actions/http-client": "^1.0.11" + } + }, + "@actions/http-client": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", + "requires": { + "tunnel": "0.0.6" + } + }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + } + } +}