From 1c22c4a1fd9b16a765c3d0167ed3dd24a7a43c68 Mon Sep 17 00:00:00 2001 From: Andrew Goldis Date: Mon, 16 Dec 2024 10:04:36 -0800 Subject: [PATCH 1/2] feat: add use-api option --- action.yml | 6 +++++- src/index.ts | 7 +++++-- src/post.ts | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 09c942d..1c38277 100644 --- a/action.yml +++ b/action.yml @@ -1,7 +1,7 @@ name: 'Playwright Last Failed' description: 'The action helps to run last failed Playwright tests using Currents cache' -author: 'vCaisim' +author: 'Currents Software Inc' inputs: key: @@ -36,6 +36,10 @@ inputs: description: 'The total number of matrices available' required: false default: '1' + use-api: + description: 'Use Currents API for obtaining the list of failed tests' + required: false + default: 'false' or8n: description: 'Enable or8n integration' required: false diff --git a/src/index.ts b/src/index.ts index b182dd1..5708f42 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import { parseIntSafe, parseTemplate, parseYamlBoolean } from './utils' // Define interface for inputs interface ActionInputs { + useAPI: boolean or8n: boolean debug: boolean matrixIndex: string @@ -22,6 +23,7 @@ interface ActionInputs { // Get inputs with types function getInputs(): ActionInputs { return { + useAPI: parseYamlBoolean(core.getInput('use-api')) ?? false, or8n: parseYamlBoolean(core.getInput('or8n')) ?? false, debug: parseYamlBoolean(core.getInput('debug')) ?? false, apiKey: core.getInput('api-key') ?? process.env.CURRENTS_API_KEY, @@ -43,8 +45,9 @@ async function run(): Promise { await exec.exec('npm install -g @currents/cmd') - core.saveState('or8n', inputs.or8n) - if (inputs.or8n) { + const useAPI = inputs.useAPI || inputs.or8n; + core.saveState('or8n', useAPI) + if (useAPI) { await or8n(inputs) return } diff --git a/src/post.ts b/src/post.ts index c60840e..794890f 100644 --- a/src/post.ts +++ b/src/post.ts @@ -14,7 +14,7 @@ interface PostState { function getPostState(): PostState { return { - or8n: core.getState('or8n') === 'true', + or8n: core.getState('or8n') === 'true' || core.getState('useAPI') === 'true', key: core.getState('key') ?? process.env.CURRENTS_RECORD_KEY, debug: core.getState('debug') === 'true', id: core.getState('id'), From 55f677aa7cb2acbf25c1c1d0520a2cff13101815 Mon Sep 17 00:00:00 2001 From: Andrew Goldis Date: Mon, 16 Dec 2024 10:07:40 -0800 Subject: [PATCH 2/2] .. --- badges/coverage.svg | 2 +- dist/index.js | 6 ++++-- dist/post.js | 2 +- src/index.ts | 2 +- src/post.ts | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index 320ca33..862b132 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 18.39%Coverage18.39% \ No newline at end of file +Coverage: 18.18%Coverage18.18% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index e917e11..84b1f45 100644 --- a/dist/index.js +++ b/dist/index.js @@ -42889,6 +42889,7 @@ const utils_1 = __nccwpck_require__(1798); // Get inputs with types function getInputs() { return { + useAPI: (0, utils_1.parseYamlBoolean)(core.getInput('use-api')) ?? false, or8n: (0, utils_1.parseYamlBoolean)(core.getInput('or8n')) ?? false, debug: (0, utils_1.parseYamlBoolean)(core.getInput('debug')) ?? false, apiKey: core.getInput('api-key') ?? process.env.CURRENTS_API_KEY, @@ -42907,8 +42908,9 @@ async function run() { try { const inputs = getInputs(); await exec.exec('npm install -g @currents/cmd'); - core.saveState('or8n', inputs.or8n); - if (inputs.or8n) { + const useAPI = inputs.useAPI || inputs.or8n; + core.saveState('or8n', useAPI); + if (useAPI) { await or8n(inputs); return; } diff --git a/dist/post.js b/dist/post.js index 112d837..a02a49f 100644 --- a/dist/post.js +++ b/dist/post.js @@ -25669,7 +25669,7 @@ const core = __importStar(__nccwpck_require__(7484)); const exec = __importStar(__nccwpck_require__(5236)); function getPostState() { return { - or8n: core.getState('or8n') === 'true', + or8n: core.getState('or8n') === 'true' || core.getState('useAPI') === 'true', key: core.getState('key') ?? process.env.CURRENTS_RECORD_KEY, debug: core.getState('debug') === 'true', id: core.getState('id'), diff --git a/src/index.ts b/src/index.ts index 5708f42..423c01e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,7 +45,7 @@ async function run(): Promise { await exec.exec('npm install -g @currents/cmd') - const useAPI = inputs.useAPI || inputs.or8n; + const useAPI = inputs.useAPI || inputs.or8n core.saveState('or8n', useAPI) if (useAPI) { await or8n(inputs) diff --git a/src/post.ts b/src/post.ts index 794890f..c3e048c 100644 --- a/src/post.ts +++ b/src/post.ts @@ -14,7 +14,8 @@ interface PostState { function getPostState(): PostState { return { - or8n: core.getState('or8n') === 'true' || core.getState('useAPI') === 'true', + or8n: + core.getState('or8n') === 'true' || core.getState('useAPI') === 'true', key: core.getState('key') ?? process.env.CURRENTS_RECORD_KEY, debug: core.getState('debug') === 'true', id: core.getState('id'),