Skip to content

Commit

Permalink
update deps, add deprecation warnings, update tests, 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cardinalby committed Oct 30, 2022
1 parent 79668bf commit 8fba9c3
Show file tree
Hide file tree
Showing 41 changed files with 736 additions and 469 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ Install for use in tests
```
npm i github-action-ts-run-api --save-dev
```
## News
Starting from release **2.3.0** the library will produce **warnings** regarding **deprecation of some commands**
([1](https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/),
[2](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/))
like GitHub Runner does. By default, warnings are printed to stderr and are accessible via `runResult.warnings` field.

Pay attention and update your actions!

## Documentation

Expand Down Expand Up @@ -108,6 +115,7 @@ assert(result.durationMs >= 1000);
assert(result.commands.outputs === {out1: 'abc', out2: 'def'});
assert(result.commands.exportedVars === {v3: 'ghi'});
assert(result.exitCode === 1);
assert(result.warnings.length === 0);
// changes were isolated inside a function run
assert(process.exitCode !== 1);
assert(result.commands.errors === ['err1']);
Expand Down
5 changes: 4 additions & 1 deletion docs/run-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const options = RunOptions.create({
// stdoutTransform: undefined // stays default
// stderrTransform: undefined // stays default
// printRunnerDebug: false // stays default
// printWarnings: true // stays default
// }
outputOptions: { printStderr: false }
});
Expand Down Expand Up @@ -201,6 +202,7 @@ want to update only some properties.
| printStderr | boolean | Print action stderr to process stderr | `true` |
| stderrTransform | [OutputTransform](../src/runOptions/OutputTransform.ts) | undefined; | The way stderr will be transformed before printing. If `undefined`, behavior depends on `process.env.GITHUB_ACTIONS` | `undefined` |
| printRunnerDebug | boolean | Print additional debug information | `false` |
| printWarnings | boolean | Print warnings to stderr (similar to GitHub Runner) at the end of an action run | `true` |

#### stdoutTransform and stderrTransform options

Expand Down Expand Up @@ -229,7 +231,8 @@ const options = RunOptions.create()
stdoutTransform: OutputTransform.SANITIZE_COMMANDS,
printStderr: true,
stderrTransform: OutputTransform.SANITIZE_COMMANDS,
printRunnerDebug: true
printRunnerDebug: true,
printWarnings: false
}, false);
```

Expand Down
22 changes: 16 additions & 6 deletions docs/run-result.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ result object).

### 🔹 `commands.outputs`

Object with action outputs parsed from stdout.
Object with action outputs (parsed both from stdout and from $GITHUB_OUTPUT file).
<details>
<summary>Example</summary>

Expand All @@ -26,7 +26,7 @@ core.setOutput('out1', 'val1');
```
Output set in bash script (Docker action):
```bash
echo "::set-output name=out1::val1"
echo "out1=val1" >> "$GITHUB_OUTPUT"
```
Read outputs:
```ts
Expand Down Expand Up @@ -141,7 +141,7 @@ result.commands.secrets // ["password"]

### 🔹 `commands.savedState`

Object with saved state values parsed from stdout.
Object with saved state values (parsed both from stdout and from $GITHUB_STATE file)

<details>
<summary>Example</summary>
Expand All @@ -153,7 +153,7 @@ core.saveState('stateName', 'value');
```
State saved in bash script (Docker action):
```bash
echo "::save-state name=stateName::value"
echo "stateName=value" >> $GITHUB_STATE
```
Read saved state names and values:
```ts
Expand Down Expand Up @@ -185,7 +185,7 @@ result.commands.echo // 'on'

### 🔹 `commands.addedPaths`

Array of "add path" commands parsed from GITHUB_PATH file or from stdout.
Array of "add path" commands (parsed both from stdout and from $GITHUB_PATH file).

<details>
<summary>Example</summary>
Expand All @@ -207,7 +207,7 @@ result.commands.addedPaths // ['some/path']

### 🔹 `commands.exportedVars`

Object with variables exported to workflow env parsed from GITHUB_ENV file or from stdout.
Object with variables exported to workflow env (parsed both from stdout and from $GITHUB_ENV file).

<details>
<summary>Example</summary>
Expand Down Expand Up @@ -288,6 +288,16 @@ Can have value in case of:
You are supposed to call `result.cleanUpFakedDirs()` at the end of a test by yourself.
2. You set existing directory as action temp dir: `options.setWorkspaceDir('existing/path')`.

### 🔹 `warnings`

An array of [`Warning`](../src/runResult/warnings/Warning.ts)s containing warnings similar to ones produced by
GitHub Runner. Currently, contains only warnings about deprecation
([1](https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/),
[2](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/))
of some stdout commands. By default, warning messages are printed to stderr at the end of the run.
If you want to check them by yourself, you can disable this behavior by
`options.setOutputOptions({printWarnings: false})`.

### 🔹 `cleanUpFakedDirs()` method

Delete faked directories that still exist after run. It will not delete existing dirs set explicitly by
Expand Down
Loading

0 comments on commit 8fba9c3

Please sign in to comment.