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..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 @@ -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/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 c0a984e..fd1f82d 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..eac0a6b 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}, + expected: ['run', '--async'] }]; for (let i = 0; i < testCases.length; i++) {