Skip to content

Commit

Permalink
fix docs, rename printWarnings to printRunnerWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cardinalby committed Mar 6, 2023
1 parent 1c51964 commit 2d3d565
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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);
assert(result.runnerWarnings.length === 0);
// changes were isolated inside a function run
assert(process.exitCode !== 1);
assert(result.commands.errors === ['err1']);
Expand Down
8 changes: 4 additions & 4 deletions docs/run-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const options = RunOptions.create({
// stdoutTransform: undefined // stays default
// stderrTransform: undefined // stays default
// printRunnerDebug: false // stays default
// printWarnings: true // stays default
// printRunnerWarnings: true // stays default
// }
outputOptions: { printStderr: false }
});
Expand Down Expand Up @@ -202,7 +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` |
| printRunnerWarnings | boolean | Print [runner warnings](./run-result-warnings.md) to stderr (similar to GitHub Runner) at the end of an action run | `true` |

#### stdoutTransform and stderrTransform options

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

Expand Down
6 changes: 3 additions & 3 deletions docs/run-result-warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Starting from release **2.3.0** the library produces **warnings** emulating the
**By default**, warnings are **printed to stderr** at the end of the run.

If you want to check them by yourself, you can **disable** this behavior by
passing `{printWarnings: false}` to [`RunOptions.setOutputOptions()`](./run-options.md#-setoutputoptions).
passing `{printRunnerWarnings: false}` to [`RunOptions.setOutputOptions()`](./run-options.md#-setoutputoptions).

You can **access** the produced warnings via [`runResult.warnings`](./run-result.md#-warnings) field.
The property is an array of [`Warning`](../src/runResult/warnings/RunnerWarning.ts)) objects
You can **access** the produced warnings via [`runResult.runnerWarnings`](./run-result.md#-runnerwarnings) field.
The property is an array of [`RunnerWarning`](../src/runResult/warnings/RunnerWarning.ts)) objects
and contains typed warnings so that you can handle them selectively.

Pay attention and update your actions!
Expand Down
6 changes: 3 additions & 3 deletions docs/run-result.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ 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`
### 🔹 `runnerWarnings`

The property is an array of [`Warning`](../src/runResult/warnings/RunnerWarning.ts)) objects
The property is an array of [`RunnerWarning`](../src/runResult/warnings/RunnerWarning.ts)) objects
and contains warnings similar to ones produced by GitHub Runner.

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})`.
`options.setOutputOptions({printRunnerWarnings: false})`.

Read detailed description [here](./run-result-warnings.md).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-action-ts-run-api",
"version": "3.0.0",
"version": "3.0.1",
"description": "Library for GitHub Action integration and unit testing",
"main": "./dist",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/runOptions/OutputOptionsInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ export interface OutputOptionsInterface {
/**
* Print warnings to stderr (similar to GitHub Runner) at the end of an action run
*/
printWarnings: boolean;
printRunnerWarnings: boolean;
}
2 changes: 1 addition & 1 deletion src/runOptions/RunOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class RunOptions
stdoutTransform: undefined,
stderrTransform: undefined,
printRunnerDebug: false,
printWarnings: true
printRunnerWarnings: true
}
return new RunOptions(
new InputsStore(init.inputs || {}),
Expand Down
2 changes: 1 addition & 1 deletion src/runResult/RunResultInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface RunResultInterface {
* Array of structured Warnings, similar messages produced by GitHub Runner
* By default these warnings 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})`
* `options.setOutputOptions({printRunnerWarnings: false})`
**/
readonly runnerWarnings: RunnerWarning[];
/**
Expand Down
6 changes: 3 additions & 3 deletions src/runResult/warnings/WarningsCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class WarningsCollector {
}

/**
* Get collected warnings and print if options.outputOptions.data.printWarnings is set
* Get collected warnings and print if options.outputOptions.data.printRunnerWarnings is set
*/
getAndPrint(): RunnerWarning[] {
this.print()
Expand All @@ -34,10 +34,10 @@ export class WarningsCollector {
}

/**
* Print if options.outputOptions.data.printWarnings is set
* Print if options.outputOptions.data.printRunnerWarnings is set
*/
print(): void {
if (this.runOptions.outputOptions.data.printWarnings) {
if (this.runOptions.outputOptions.data.printRunnerWarnings) {
this.warnings.forEach(warning => process.stderr.write(os.EOL + warning.message))
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/DockerTarget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('DockerTarget', () => {
dockerActionYml, { runUnderCurrentLinuxUser: runUnderCurrentLinuxUser }
).run(RunOptions.create()
.setInputs({input1: 'abc', action: 'user_out'})
.setOutputOptions({printWarnings: false})
.setOutputOptions({printRunnerWarnings: false})
);
expect(res.isSuccess).toEqual(true);
const expectedUser = runUnderCurrentLinuxUser
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/FnTarget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('SyncFnTarget', () => {
return 32;
}).run(RunOptions.create({
env: {CCC: 'x'},
outputOptions: {printWarnings: false}
outputOptions: {printRunnerWarnings: false}
}));
expect(process.cwd()).toEqual(initialProcessCwd);
expect(process.env.AAA).toEqual('aaa');
Expand All @@ -64,7 +64,7 @@ describe('SyncFnTarget', () => {
});

it('should parse stdout commands', () => {
const options = RunOptions.create({outputOptions: {printWarnings: false}});
const options = RunOptions.create({outputOptions: {printRunnerWarnings: false}});
const res = RunTarget.syncFn(() => {
core.error('err%msg1');
core.error('err%msg2');
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('SyncFnTarget', () => {

test.each([5, 6])('should set github service envs', async runNumber => {
jest.resetModules();
const options = RunOptions.create({outputOptions: {printWarnings: false}});
const options = RunOptions.create({outputOptions: {printRunnerWarnings: false}});
let fnContext: Context = new Context();
let fnRepo: any = undefined;
const res = await RunTarget.asyncFn(async () => {
Expand All @@ -158,7 +158,7 @@ describe('SyncFnTarget', () => {

it('should fake github service envs', async () => {
jest.resetModules();
const options = RunOptions.create({outputOptions: {printWarnings: false}});
const options = RunOptions.create({outputOptions: {printRunnerWarnings: false}});
let fnEnv: EnvInterface = {};
let fnContext: Context = new Context();
const res = await RunTarget.asyncFn(async () => {
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('SyncFnTarget', () => {
}).run(RunOptions.create()
.setOutputOptions({
parseStdoutCommands: parseStdoutCommands,
printWarnings: fakeFileCommands || !parseStdoutCommands
printRunnerWarnings: fakeFileCommands || !parseStdoutCommands
})
.setFakeFsOptions({fakeCommandFiles: fakeFileCommands})
);
Expand Down Expand Up @@ -413,7 +413,7 @@ describe('SyncFnTarget', () => {
.syncFn(() => { return 5; }, node12ActionActionYml)
.run(RunOptions.create({
outputOptions: {
printWarnings: false
printRunnerWarnings: false
}
}));
expect(res.exitCode).toBeUndefined();
Expand Down Expand Up @@ -507,7 +507,7 @@ describe('AsyncFnTarget', () => {
.asyncFn(async () => { return 5; }, node12ActionActionYml)
.run(RunOptions.create({
outputOptions: {
printWarnings: false
printRunnerWarnings: false
}
}));
expect(res.exitCode).toBeUndefined();
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/JsFileTarget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('JsActionScriptTarget', () => {
printStderr: true,
stdoutTransform: OutputTransform.SANITIZE_COMMANDS,
stderrTransform: OutputTransform.SANITIZE_COMMANDS,
printWarnings: false
printRunnerWarnings: false
})
);
} finally {
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('JsActionScriptTarget', () => {
RunOptions.create()
.setInputs({sendStdoutCommands: 'true', sendFileCommands: 'true', failAtTheEnd: 'true'})
.setFakeFsOptions({fakeCommandFiles: false})
.setOutputOptions({printWarnings: false})
.setOutputOptions({printRunnerWarnings: false})
);
expect(res.commands.errors).toEqual(['err%msg1', 'err%msg2', 'failed_msg']);
expect(res.commands.warnings).toEqual(["warning\rmsg"]);
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('JsFilePathTarget', () => {
RunOptions.create()
.setInputs({sendFileCommands: 'true', sendStdoutCommands: 'false', failAtTheEnd: 'false'})
.setFakeFsOptions({fakeCommandFiles: fakeFileCommands})
.setOutputOptions({printWarnings: fakeFileCommands})
.setOutputOptions({printRunnerWarnings: fakeFileCommands})
);
expect(res.commands.errors).toEqual([]);
expect(res.commands.warnings).toEqual([]);
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('JsFilePathTarget', () => {
.setFakeFsOptions({fakeCommandFiles: fakeFileCommands})
.setOutputOptions({
parseStdoutCommands: parseStdoutCommands,
printWarnings: fakeFileCommands || !parseStdoutCommands
printRunnerWarnings: fakeFileCommands || !parseStdoutCommands
})
);
expect(res.commands.warnings).toEqual(expectedWarnings);
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('JsFilePathTarget', () => {
.run(RunOptions.create()
.setInputs({setState: 'stateVal'})
.setOutputOptions({
printWarnings: false
printRunnerWarnings: false
})
);
expect(res.commands.warnings).toEqual([]);
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/runOptions/RunOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('RunOptions', () => {
stderrTransform: undefined,
printStderr: true,
printRunnerDebug: false,
printWarnings: true
printRunnerWarnings: true
} as OutputOptionsInterface);
expect(o.timeoutMs).toEqual(123);
expect(o.env.data).toEqual({e1: 'v1'});
Expand All @@ -71,7 +71,7 @@ describe('RunOptions', () => {
parseStdoutCommands: true,
parseStderrCommands: true,
printRunnerDebug: false,
printWarnings: false
printRunnerWarnings: false
}, false);

expect(cloned.fakeFsOptions.data).toEqual({
Expand All @@ -93,7 +93,7 @@ describe('RunOptions', () => {
parseStdoutCommands: true,
parseStderrCommands: true,
printRunnerDebug: false,
printWarnings: false
printRunnerWarnings: false
});

expect(options.shouldAddProcessEnv).toEqual(false);
Expand All @@ -108,7 +108,7 @@ describe('RunOptions', () => {
stderrTransform: undefined,
printStderr: true,
printRunnerDebug: false,
printWarnings: true
printRunnerWarnings: true
} as OutputOptionsInterface);
expect(options.fakeFsOptions.data).toEqual({
fakeCommandFiles: false,
Expand All @@ -130,7 +130,7 @@ describe('RunOptions', () => {
parseStdoutCommands: true,
parseStderrCommands: true,
printRunnerDebug: false,
printWarnings: true
printRunnerWarnings: true
} as OutputOptionsInterface);
expect(options.timeoutMs).toEqual(undefined);
expect(options.env.data).toEqual({});
Expand Down

0 comments on commit 2d3d565

Please sign in to comment.