From b4ff6c992a9555818d2b24075d9dcd4c69de4be6 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Fri, 15 Sep 2023 10:16:33 -0700 Subject: [PATCH 1/4] feat: Add --async flag --- README.md | 3 +++ action.yml | 12 ++++++++---- src/config.js | 2 ++ src/helpers.js | 1 - src/run.js | 3 +++ tests/run.spec.js | 4 +++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7196d59..629b82c 100644 --- a/README.md +++ b/README.md @@ -63,4 +63,7 @@ the `env` field, or you may face an `API rate limit exceeded` error. # Includes the contents of the suite's console.log in the output of the command regardless of the test results. By default, the console log contents are shown for failed test suites only. # Default: false show-console-log: false + + # Launches tests without awaiting outcomes; operates in a fire-and-forget manner. + async: false ``` diff --git a/action.yml b/action.yml index 58e8dbd..8e28dd5 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: Saucectl Run Action -description: A GitHub action to run your tests locally or on Sauce Labs +description: A GitHub action to run your tests locally or on Sauce Labs. author: devx@saucelabs.com branding: icon: check-circle @@ -30,7 +30,7 @@ inputs: description: Controls how many suites run in parallel. required: false sauceignore: - description: Specifies the path to the .sauceignore file + description: Specifies the path to the .sauceignore file. required: false timeout: description: Global timeout that limits how long saucectl can run in total. @@ -49,10 +49,14 @@ inputs: description: Specifies a test suite to execute by name rather than all suites defined in the config file. required: false env: - description: Environment variables to pass to saucectl + description: Environment variables to pass to saucectl. required: false showConsoleLog: - description: Display console.log when tests succeed + description: Display console.log when tests succeed. + required: false + default: "false" + async: + description: Launches tests without waiting for test results. required: false default: "false" runs: diff --git a/src/config.js b/src/config.js index c0a984e..746ef89 100644 --- a/src/config.js +++ b/src/config.js @@ -17,6 +17,7 @@ const defaultConfig = { tunnelOwner: undefined, showConsoleLog: false, env: [], + async: false, }; const getEnvVariables = function(keys) { @@ -62,6 +63,7 @@ const get = function() { tunnelOwner: getSettingString(['tunnel-owner'], defaultConfig.tunnelOwner), env: getEnvVariables(['env']), showConsoleLog: getSettingBool(['show-console-log'], defaultConfig.showConsoleLog), + async: getSettingBool(['async'], defaultConfig.async) }; if (sauceConfig.saucectlVersion != "latest") { diff --git a/src/helpers.js b/src/helpers.js index b2afa6c..58b8a4f 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,4 +1,3 @@ - const core = require("@actions/core"); async function sleep(duration) { diff --git a/src/run.js b/src/run.js index 0cb54ac..734d684 100644 --- a/src/run.js +++ b/src/run.js @@ -38,6 +38,9 @@ function buildSaucectlArgs(opts) { for (const env of opts.env || []) { args.push('-e', env); } + if (opts.async) { + args.push('--async'); + } return args; } diff --git a/tests/run.spec.js b/tests/run.spec.js index 10f8c49..bf46497 100644 --- a/tests/run.spec.js +++ b/tests/run.spec.js @@ -1,4 +1,3 @@ - jest.mock("child_process"); jest.mock("../src/helpers.js"); const childProcess = require("child_process"); @@ -38,6 +37,9 @@ it("Argument builds", async () => { }, { input: { ...config.defaultConfig, env: ['key1=val1', 'key2=val2']}, expected: ['run', '-e', 'key1=val1', '-e', 'key2=val2'] + }, { + input: { ...config.defaultConfig, async: true}, + expect: ['run', '--async'] }]; for (let i = 0; i < testCases.length; i++) { From 30e0fe9cef59ddff77a2d1870d2b51132fb2b7f9 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Fri, 15 Sep 2023 10:18:10 -0700 Subject: [PATCH 2/4] remove outdated doc --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8e28dd5..50f935b 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: Saucectl Run Action -description: A GitHub action to run your tests locally or on Sauce Labs. +description: A GitHub action to run your tests on Sauce Labs. author: devx@saucelabs.com branding: icon: check-circle From 8a70e1658ed6784b596b51331b332aaf850c9072 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Fri, 15 Sep 2023 10:20:29 -0700 Subject: [PATCH 3/4] oops --- tests/run.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.spec.js b/tests/run.spec.js index bf46497..eac0a6b 100644 --- a/tests/run.spec.js +++ b/tests/run.spec.js @@ -39,7 +39,7 @@ it("Argument builds", async () => { expected: ['run', '-e', 'key1=val1', '-e', 'key2=val2'] }, { input: { ...config.defaultConfig, async: true}, - expect: ['run', '--async'] + expected: ['run', '--async'] }]; for (let i = 0; i < testCases.length; i++) { From 9364966b377e864cb775cbfb2ff6a0b79d0513e5 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Fri, 15 Sep 2023 10:49:50 -0700 Subject: [PATCH 4/4] fix test --- dist/main/index.js | 6 +++++- src/config.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/main/index.js b/dist/main/index.js index 80282f6..bde8445 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -16217,6 +16217,7 @@ const defaultConfig = { tunnelOwner: undefined, showConsoleLog: false, env: [], + async: false, }; const getEnvVariables = function(keys) { @@ -16262,6 +16263,7 @@ const get = function() { tunnelOwner: getSettingString(['tunnel-owner'], defaultConfig.tunnelOwner), env: getEnvVariables(['env']), showConsoleLog: getSettingBool(['show-console-log'], defaultConfig.showConsoleLog), + async: getSettingBool(['async'], defaultConfig.async), }; if (sauceConfig.saucectlVersion != "latest") { @@ -16281,7 +16283,6 @@ module.exports = { get, defaultConfig, getSettingBool, getSettingString, getEnvV /***/ 8505: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - const core = __nccwpck_require__(2186); async function sleep(duration) { @@ -16472,6 +16473,9 @@ function buildSaucectlArgs(opts) { for (const env of opts.env || []) { args.push('-e', env); } + if (opts.async) { + args.push('--async'); + } return args; } diff --git a/src/config.js b/src/config.js index 746ef89..fd1f82d 100644 --- a/src/config.js +++ b/src/config.js @@ -63,7 +63,7 @@ const get = function() { tunnelOwner: getSettingString(['tunnel-owner'], defaultConfig.tunnelOwner), env: getEnvVariables(['env']), showConsoleLog: getSettingBool(['show-console-log'], defaultConfig.showConsoleLog), - async: getSettingBool(['async'], defaultConfig.async) + async: getSettingBool(['async'], defaultConfig.async), }; if (sauceConfig.saucectlVersion != "latest") {