Skip to content

Commit

Permalink
Remove obsolete flags (#24)
Browse files Browse the repository at this point in the history
* Remove deprecated flags

* Update README
  • Loading branch information
alexplischke authored Feb 9, 2023
1 parent 889cc23 commit 044f158
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 196 deletions.
176 changes: 60 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,120 +3,64 @@
This action installs [saucectl](https://github.com/saucelabs/saucectl/) and launches tests. \
You can use it to run your tests on Sauce Labs !

## Example

### Basic

```
jobs:
test:
runs-on: ubuntu-latest
name: Action Test
steps:
# ...
- uses: saucelabs/saucectl-run-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
# ...
```

:warning: To avoid reaching `API rate limit exceeded` due to unauthenticated requests, be sure to provide `GITHUB_TOKEN` through `env` field.

### Advanced

```
jobs:
test:
runs-on: ubuntu-latest
name: Action Test
steps:
- uses: saucelabs/saucectl-run-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
sauce-username: ${{ secrets.SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }}
saucectl-version: v0.109.0
working-directory: ./testrunner-toolkit/cypress/
testing-environment: sauce
```

## Inputs

## saucectl-version

Version of saucectl to use. \
Default: latest

## sauce-username

Sauce Labs user name.

## sauce-access-key

Sauce Labs Access Key.

## working-directory

Folder in-which saucectl will be run.\
Default: `.`

## config-file

Configuration file to use with saucectl.\
Default: `.sauce/config.yml`

> This value is relative to `working-directory`.

## region

Region flag to pass to saucectl.

> Similar to `--region <region>` parameter available in saucectl.
## skip-run

Skip execution of saucectl (only install binary).

## select-suite

Select the suite to run.

> Similar to `--select-suite <suite>` parameter available in saucectl.
## concurrency

Concurency to use.

> Similar to `--ccy <ccy>` parameter available in saucectl.
## env

Environement variables to add.

> Similar to `-e` parameter available in saucectl.
Due to github actions limitation, environement variables needs to be passed as a string. \
Example:
```
- uses: saucelabs/saucectl-run-action@v2
with:
sauce-username: ${{ secrets.SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }}
env: |
MY_FIRST_VAR=VALUE
MY_SECOND_VAR=VALUE
## Usage

:warning: Avoid being throttled by GitHub. Be sure to provide `GITHUB_TOKEN` through
the `env` field, or you may face an `API rate limit exceeded` error.

```yaml
- uses: saucelabs/saucectl-run-action@v3
env:
GITHUB_TOKEN: ${{ github.token }}
with:
# Which version of saucectl.
# Default: latest
saucectl-version: v0.123.0

# Sauce Labs Credentials.
sauce-username: ${{ secrets.SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }}

# Install saucectl, but don't run it.
# Default: false
skip-run: false

# Relative path under $GITHUB_WORKSPACE to use as the new working directory.
working-directory: ""

# An environment variable key-value pair that may be referenced in the tests executed by this command.
# Currently not supported by espresso/xcuitest.
env: |
MY_FIRST_VAR=VALUE
MY_SECOND_VAR=VALUE
# Specify an alternative configuration file for this execution.
# Default: .sauce/config.yml
config-file: .sauce/myconfig.yml

# Specifies the Sauce Labs data center through which tests will run.
# Valid values are us-west-1 or eu-central-1.
# Default: us-west-1
region: us-west-1

# Controls how many suites run in parallel.
# Default: 1
concurrency: 1

# Global timeout that limits how long saucectl can run in total.
# Supports duration values like '10s', '30m' etc.
timeout: 5m

# Identifies an active Sauce Connect tunnel to use for secure connectivity to the Sauce Labs cloud.
tunnel-name: ""

# Identifies the Sauce Labs user who created the specified tunnel, which is required if the user running the tests did not create the tunnel.
tunnel-owner: ""

# Specifies a test suite to execute by name rather than all suites defined in the config file.
select-suite: ""

# 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
```

## show-console-log

Display console.log when tests succeed. Set to `true` to enable.

> Similar to `--show-console-log` parameter available in saucectl.
## logDir

Path where to store logs.

> Similar to `--logDir <path>` parameter available in saucectl.
29 changes: 10 additions & 19 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ inputs:
description: Sauce Labs API Key.
required: false
working-directory:
description: Folder in-which saucectl will be run.
description: Folder in which saucectl will be run.
default: .
required: false
config-file:
description: Configuration file to use with saucectl
description: Specify an alternative configuration file to the default .sauce/config.yml for this execution.
default: .sauce/config.yml
required: false
region:
description: The Sauce Labs region.
required: false
testing-environment:
description: "[deprecated] Testing Environment"
description: Specifies the Sauce Labs data center through which tests will run. Valid values are us-west-1 (default) or eu-central-1.
required: false
concurrency:
description: Controls how many suites run in parallel.
Expand All @@ -36,23 +33,20 @@ inputs:
description: Specifies the path to the .sauceignore file
required: false
timeout:
description: test timeout in seconds
description: Global timeout that limits how long saucectl can run in total.
required: false
tunnel-id:
description: Sets the sauce-connect tunnel ID to be used for the run
tunnel-name:
description: Identifies an active Sauce Connect tunnel to use for secure connectivity to the Sauce Labs cloud.
required: false
tunnel-parent:
description: Sets the sauce-connect tunnel parent to be used for the run
tunnel-owner:
description: Identifies the Sauce Labs user who created the specified tunnel, which is required if the user running the tests did not create the tunnel.
required: false
skip-run:
description: Skip execution of saucectl (only install binary)
description: Skip execution of saucectl (only install binary).
default: "false"
required: false
suite:
description: "[deprecated] Suite to be tested"
required: false
select-suite:
description: Suite to be tested
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
Expand All @@ -61,9 +55,6 @@ inputs:
description: Display console.log when tests succeed
required: false
default: "false"
logDir:
description: Path where to store logs
required: false
runs:
using: 'node16'
main: 'dist/main/index.js'
33 changes: 8 additions & 25 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16208,17 +16208,14 @@ const defaultConfig = {
workingDirectory: ".",
configurationFile: undefined,
runRegion: undefined,
runEnvironment: undefined,
concurrency: undefined,
timeout: undefined,
sauceignore: undefined,
skipRun: false,
suite: undefined,
selectSuite: undefined,
tunnelId: undefined,
tunnelParent: undefined,
tunnelName: undefined,
tunnelOwner: undefined,
showConsoleLog: false,
logDir: undefined,
env: [],
};

Expand Down Expand Up @@ -16256,18 +16253,15 @@ const get = function() {
workingDirectory: getSettingString(['working-directory'], defaultConfig.workingDirectory),
configurationFile: getSettingString(['config-file', 'configuration-file'], defaultConfig.configurationFile),
runRegion: getSettingString(['region'], defaultConfig.runRegion),
runEnvironment: getSettingString(['testing-environment', 'test-environment', 'environment'], defaultConfig.runEnvironment),
concurrency: getSettingString(['concurrency'], defaultConfig.concurrency),
timeout: getSettingString(['timeout'], defaultConfig.timeout),
sauceignore: getSettingString(['sauceignore'], defaultConfig.sauceignore),
skipRun: getSettingBool(['skip-run'], defaultConfig.skipRun),
suite: getSettingString(['suite'], defaultConfig.suite),
selectSuite: getSettingString(['select-suite'], defaultConfig.selectSuite),
tunnelId: getSettingString(['tunnel-id'], defaultConfig.tunnelId),
tunnelParent: getSettingString(['tunnel-parent'], defaultConfig.tunnelParent),
tunnelName: getSettingString(['tunnel-name'], defaultConfig.tunnelName),
tunnelOwner: getSettingString(['tunnel-owner'], defaultConfig.tunnelOwner),
env: getEnvVariables(['env']),
showConsoleLog: getSettingBool(['show-console-log'], defaultConfig.showConsoleLog),
logDir: getSettingString(['logDir'], defaultConfig.logDir),
};

if (sauceConfig.saucectlVersion != "latest") {
Expand Down Expand Up @@ -16440,38 +16434,27 @@ function buildSaucectlArgs(opts) {
if (opts.runRegion) {
args.push('--region', opts.runRegion);
}
if (opts.runEnvironment) {
core.warning(`testing-environment is deprecated. It won't worke with saucectl v0.53.0 and above.`);
args.push('--test-env', opts.runEnvironment);
}
if (opts.concurrency) {
args.push('--ccy', opts.concurrency);
}
if (opts.suite) {
core.warning(`suite is deprecated. It won't work with saucectl v0.53.0 and above. You should use select-suite parameter.`);
args.push('--suite', opts.suite);
}
if (opts.selectSuite) {
args.push('--select-suite', opts.selectSuite);
}
if (opts.timeout) {
args.push('--timeout', opts.timeout);
}
if (opts.tunnelId) {
args.push('--tunnel-id', opts.tunnelId);
if (opts.tunnelName) {
args.push('--tunnel-name', opts.tunnelName);
}
if (opts.tunnelParent) {
args.push('--tunnel-parent', opts.tunnelParent);
if (opts.tunnelOwner) {
args.push('--tunnel-owner', opts.tunnelOwner);
}
if (opts.sauceignore) {
args.push('--sauceignore', opts.sauceignore);
}
if (opts.showConsoleLog) {
args.push('--show-console-log');
}
if (opts.logDir) {
args.push('--logDir', opts.logDir)
}
for (const env of opts.env || []) {
args.push('-e', env);
}
Expand Down
14 changes: 4 additions & 10 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ const defaultConfig = {
workingDirectory: ".",
configurationFile: undefined,
runRegion: undefined,
runEnvironment: undefined,
concurrency: undefined,
timeout: undefined,
sauceignore: undefined,
skipRun: false,
suite: undefined,
selectSuite: undefined,
tunnelId: undefined,
tunnelParent: undefined,
tunnelName: undefined,
tunnelOwner: undefined,
showConsoleLog: false,
logDir: undefined,
env: [],
};

Expand Down Expand Up @@ -56,18 +53,15 @@ const get = function() {
workingDirectory: getSettingString(['working-directory'], defaultConfig.workingDirectory),
configurationFile: getSettingString(['config-file', 'configuration-file'], defaultConfig.configurationFile),
runRegion: getSettingString(['region'], defaultConfig.runRegion),
runEnvironment: getSettingString(['testing-environment', 'test-environment', 'environment'], defaultConfig.runEnvironment),
concurrency: getSettingString(['concurrency'], defaultConfig.concurrency),
timeout: getSettingString(['timeout'], defaultConfig.timeout),
sauceignore: getSettingString(['sauceignore'], defaultConfig.sauceignore),
skipRun: getSettingBool(['skip-run'], defaultConfig.skipRun),
suite: getSettingString(['suite'], defaultConfig.suite),
selectSuite: getSettingString(['select-suite'], defaultConfig.selectSuite),
tunnelId: getSettingString(['tunnel-id'], defaultConfig.tunnelId),
tunnelParent: getSettingString(['tunnel-parent'], defaultConfig.tunnelParent),
tunnelName: getSettingString(['tunnel-name'], defaultConfig.tunnelName),
tunnelOwner: getSettingString(['tunnel-owner'], defaultConfig.tunnelOwner),
env: getEnvVariables(['env']),
showConsoleLog: getSettingBool(['show-console-log'], defaultConfig.showConsoleLog),
logDir: getSettingString(['logDir'], defaultConfig.logDir),
};

if (sauceConfig.saucectlVersion != "latest") {
Expand Down
Loading

0 comments on commit 044f158

Please sign in to comment.