Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add --async flag #28

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
12 changes: 8 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16217,6 +16217,7 @@ const defaultConfig = {
tunnelOwner: undefined,
showConsoleLog: false,
env: [],
async: false,
};

const getEnvVariables = function(keys) {
Expand Down Expand Up @@ -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") {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const defaultConfig = {
tunnelOwner: undefined,
showConsoleLog: false,
env: [],
async: false,
};

const getEnvVariables = function(keys) {
Expand Down Expand Up @@ -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") {
Expand Down
1 change: 0 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const core = require("@actions/core");

async function sleep(duration) {
Expand Down
3 changes: 3 additions & 0 deletions src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion tests/run.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

jest.mock("child_process");
jest.mock("../src/helpers.js");
const childProcess = require("child_process");
Expand Down Expand Up @@ -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++) {
Expand Down