act-test-runner 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/ActExecStatus.d.ts +28 -0
- package/dist/ActExecStatus.js +29 -0
- package/dist/ActJobExecResult.d.ts +39 -0
- package/dist/ActJobExecResult.js +42 -0
- package/dist/ActOutputListener.d.ts +58 -0
- package/dist/ActOutputListener.js +45 -0
- package/dist/ActResourceSpec.d.ts +6 -0
- package/dist/ActRunner.d.ts +168 -0
- package/dist/ActRunner.js +304 -0
- package/dist/ActRunnerError.d.ts +25 -0
- package/dist/ActRunnerError.js +25 -0
- package/dist/ActRunnerOptions.d.ts +57 -0
- package/dist/ActRunnerOptions.js +22 -0
- package/dist/ActRunnerResult.d.ts +68 -0
- package/dist/ActRunnerResult.js +33 -0
- package/dist/ActWorkflowExecResult.d.ts +45 -0
- package/dist/ActWorkflowExecResult.js +49 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +24 -0
- package/dist/internal/ActCliParams.d.ts +57 -0
- package/dist/internal/ActCliParams.js +119 -0
- package/dist/internal/ActExecListener.d.ts +37 -0
- package/dist/internal/ActExecListener.js +98 -0
- package/dist/internal/ActJobExecResultBuilder.d.ts +33 -0
- package/dist/internal/ActJobExecResultBuilder.js +52 -0
- package/dist/internal/ActJobOutputProcessor.d.ts +40 -0
- package/dist/internal/ActJobOutputProcessor.js +101 -0
- package/dist/internal/ActJsonOutput.d.ts +39 -0
- package/dist/internal/ActJsonOutput.js +53 -0
- package/dist/internal/ActResourceSpec.d.ts +26 -0
- package/dist/internal/ActResourceSpec.js +30 -0
- package/dist/internal/ActStepOutputProcessor.d.ts +32 -0
- package/dist/internal/ActStepOutputProcessor.js +51 -0
- package/dist/internal/JobIterationTracker.d.ts +27 -0
- package/dist/internal/JobIterationTracker.js +41 -0
- package/dist/internal/JobTrackingActExecListener.d.ts +34 -0
- package/dist/internal/JobTrackingActExecListener.js +74 -0
- package/dist/internal/OutputForwardingActExecListener.d.ts +30 -0
- package/dist/internal/OutputForwardingActExecListener.js +40 -0
- package/dist/utils/checks.d.ts +23 -0
- package/dist/utils/checks.js +38 -0
- package/dist/utils/fsutils.d.ts +27 -0
- package/dist/utils/fsutils.js +43 -0
- package/dist/utils/objects.d.ts +22 -0
- package/dist/utils/objects.js +25 -0
- package/dist/utils/types.d.ts +24 -0
- package/dist/utils/types.js +22 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 original authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# act-test-runner
|
|
2
|
+
|
|
3
|
+
[](https://github.com/pshevche/act-test-runner/actions/workflows/verify.yaml)
|
|
4
|
+
|
|
5
|
+
**Convenient wrapper around [act](https://github.com/nektos/act) for implementing e2e tests for GitHub actions**
|
|
6
|
+
|
|
7
|
+
The library defines an opinionated runner interface for executing GitHub workflows locally using
|
|
8
|
+
the [act](https://github.com/nektos/act) runner.
|
|
9
|
+
|
|
10
|
+
Consumers can assert on the outcome of the workflow execution, such as the jobs run, workflow's output, or artifacts
|
|
11
|
+
persisted in the artifact server or action cache.
|
|
12
|
+
|
|
13
|
+
## Sneak preview
|
|
14
|
+
|
|
15
|
+
```JavaScript
|
|
16
|
+
test('custom workflow with event', async () => {
|
|
17
|
+
const result = await new ActRunner()
|
|
18
|
+
.withWorkflow({
|
|
19
|
+
body: `
|
|
20
|
+
name: Workflow printing the PR title
|
|
21
|
+
on:
|
|
22
|
+
pull_request:
|
|
23
|
+
types: [opened]
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
print_pr_title:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- name: Print PR title
|
|
30
|
+
if: github.event_name == 'pull_request'
|
|
31
|
+
run: |
|
|
32
|
+
echo "PR Title: ${{ github.event.pull_request.title }}"
|
|
33
|
+
`,
|
|
34
|
+
})
|
|
35
|
+
.withEvent('pull_request', {
|
|
36
|
+
pull_request: {
|
|
37
|
+
title: 'Example PR payload as object',
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
.run();
|
|
41
|
+
|
|
42
|
+
expect(result.status).toBe(ActExecStatus.SUCCESS);
|
|
43
|
+
const job = result.jobs['print_pr_title']!;
|
|
44
|
+
expect(job.status).toBe(ActExecStatus.SUCCESS);
|
|
45
|
+
expect(job.output).toContain('PR Title: Example PR payload as object');
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Useful links
|
|
50
|
+
|
|
51
|
+
- [Wiki](https://github.com/pshevche/act-test-runner/wiki): full documentation, including a walkthrough of the public API and more usage examples.
|
|
52
|
+
- [Known limitations](https://github.com/pshevche/act-test-runner/wiki/Known-limitations): constraints to be aware of before adopting the library.
|
|
53
|
+
- [Examples](https://github.com/pshevche/act-test-runner/wiki/Examples): representative test cases showing the API in action, including testing a local action under development.
|
|
54
|
+
- [nektos/act](https://github.com/nektos/act): GitHub actions runner used by the plugin.
|
|
55
|
+
- [act User Guide](https://nektosact.com): describes various configuration options that the runner provides, as well as
|
|
56
|
+
the format for input files.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
* the Software without restriction, including without limitation the rights to
|
|
7
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
* subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Outcome of the workflow or job execution.
|
|
23
|
+
*/
|
|
24
|
+
export declare enum ActExecStatus {
|
|
25
|
+
SUCCESS = 0,
|
|
26
|
+
FAILED = 1,
|
|
27
|
+
SKIPPED = 2
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
* the Software without restriction, including without limitation the rights to
|
|
7
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
* subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Outcome of the workflow or job execution.
|
|
23
|
+
*/
|
|
24
|
+
export var ActExecStatus;
|
|
25
|
+
(function (ActExecStatus) {
|
|
26
|
+
ActExecStatus[ActExecStatus["SUCCESS"] = 0] = "SUCCESS";
|
|
27
|
+
ActExecStatus[ActExecStatus["FAILED"] = 1] = "FAILED";
|
|
28
|
+
ActExecStatus[ActExecStatus["SKIPPED"] = 2] = "SKIPPED";
|
|
29
|
+
})(ActExecStatus || (ActExecStatus = {}));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
* the Software without restriction, including without limitation the rights to
|
|
7
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
* subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
import { ActExecStatus } from './ActExecStatus.js';
|
|
22
|
+
/**
|
|
23
|
+
* Job execution result for inspection.
|
|
24
|
+
*/
|
|
25
|
+
export declare class ActJobExecResult {
|
|
26
|
+
/**
|
|
27
|
+
* Name of the job run.
|
|
28
|
+
*/
|
|
29
|
+
readonly name: string;
|
|
30
|
+
/**
|
|
31
|
+
* Result of the job execution.
|
|
32
|
+
*/
|
|
33
|
+
readonly status: ActExecStatus;
|
|
34
|
+
/**
|
|
35
|
+
* Job's console output.
|
|
36
|
+
*/
|
|
37
|
+
readonly output: string;
|
|
38
|
+
constructor(name: string, status: ActExecStatus, output: string);
|
|
39
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
* the Software without restriction, including without limitation the rights to
|
|
7
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
* subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Job execution result for inspection.
|
|
23
|
+
*/
|
|
24
|
+
export class ActJobExecResult {
|
|
25
|
+
/**
|
|
26
|
+
* Name of the job run.
|
|
27
|
+
*/
|
|
28
|
+
name;
|
|
29
|
+
/**
|
|
30
|
+
* Result of the job execution.
|
|
31
|
+
*/
|
|
32
|
+
status;
|
|
33
|
+
/**
|
|
34
|
+
* Job's console output.
|
|
35
|
+
*/
|
|
36
|
+
output;
|
|
37
|
+
constructor(name, status, output) {
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.output = output;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in
|
|
12
|
+
* all copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/** Identifier of the owner of this message: job or step. */
|
|
23
|
+
export type ActJobOrStepDescriptor = {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
/** Message's log level. */
|
|
28
|
+
export declare const ActOutputLevel: {
|
|
29
|
+
readonly DEBUG: 'debug';
|
|
30
|
+
readonly INFO: 'info';
|
|
31
|
+
readonly WARNING: 'warning';
|
|
32
|
+
readonly ERROR: 'error';
|
|
33
|
+
};
|
|
34
|
+
/** Message's log level. */
|
|
35
|
+
export type ActOutputLevel = (typeof ActOutputLevel)[keyof typeof ActOutputLevel];
|
|
36
|
+
/** Single message in the act output stream. */
|
|
37
|
+
export type ActOutput = {
|
|
38
|
+
job?: ActJobOrStepDescriptor;
|
|
39
|
+
step?: ActJobOrStepDescriptor;
|
|
40
|
+
message: string;
|
|
41
|
+
level: ActOutputLevel;
|
|
42
|
+
time: Date;
|
|
43
|
+
};
|
|
44
|
+
/** Listen to the act output stream. */
|
|
45
|
+
export interface ActOutputListener {
|
|
46
|
+
/** @param output Act output represented as a structured object. */
|
|
47
|
+
onOutput(output: ActOutput): void;
|
|
48
|
+
}
|
|
49
|
+
/** Act output listener that forwards the output to the console. */
|
|
50
|
+
export declare class StdStreamOutputListener implements ActOutputListener {
|
|
51
|
+
onOutput(output: ActOutput): void;
|
|
52
|
+
}
|
|
53
|
+
/** Composite act output listener that delegates to all provided listeners. */
|
|
54
|
+
export declare class CompositeActOutputListener implements ActOutputListener {
|
|
55
|
+
private readonly listeners;
|
|
56
|
+
constructor(listeners: ActOutputListener[]);
|
|
57
|
+
onOutput(output: ActOutput): void;
|
|
58
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in
|
|
12
|
+
* all copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { formattedMessage } from './internal/ActJsonOutput.js';
|
|
23
|
+
/** Message's log level. */
|
|
24
|
+
export const ActOutputLevel = {
|
|
25
|
+
DEBUG: 'debug',
|
|
26
|
+
INFO: 'info',
|
|
27
|
+
WARNING: 'warning',
|
|
28
|
+
ERROR: 'error',
|
|
29
|
+
};
|
|
30
|
+
/** Act output listener that forwards the output to the console. */
|
|
31
|
+
export class StdStreamOutputListener {
|
|
32
|
+
onOutput(output) {
|
|
33
|
+
console.log(formattedMessage(output.message, output.job?.name));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Composite act output listener that delegates to all provided listeners. */
|
|
37
|
+
export class CompositeActOutputListener {
|
|
38
|
+
listeners;
|
|
39
|
+
constructor(listeners) {
|
|
40
|
+
this.listeners = listeners;
|
|
41
|
+
}
|
|
42
|
+
onOutput(output) {
|
|
43
|
+
this.listeners.forEach((it) => it.onOutput(output));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 original authors
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in
|
|
12
|
+
* all copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { WebhookEventMap, WebhookEventName } from '@octokit/webhooks-types';
|
|
23
|
+
import type { ActValueSource, ActWorkflowSource, ActResourceServerSpec, ActProcessOptions } from './ActRunnerOptions.js';
|
|
24
|
+
import type { ActMatrixValues, ActWorkflowExecResult } from './ActRunnerResult.js';
|
|
25
|
+
import { ActOutputListener } from './ActOutputListener.js';
|
|
26
|
+
import { PartialDeep } from './utils/types.js';
|
|
27
|
+
type EventPayload<TEventType extends WebhookEventName | undefined = undefined> = (TEventType extends WebhookEventName ? PartialDeep<WebhookEventMap[TEventType]> | string : string) | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Invokes `act`, allowing end-to-end testing of custom GitHub actions and
|
|
30
|
+
* workflows.
|
|
31
|
+
*
|
|
32
|
+
* Typically, the test code will provide a workflow file or workflow body to
|
|
33
|
+
* run, as well as required workflow inputs, such as environment variables or
|
|
34
|
+
* secrets.
|
|
35
|
+
*
|
|
36
|
+
* Assertions can then be made on the outcome of the `run()` method invocation,
|
|
37
|
+
* such as the jobs run, workflow output, or artifacts persisted in the artifact
|
|
38
|
+
* server or action cache.
|
|
39
|
+
*
|
|
40
|
+
* The runner cannot be used concurrently due to limitations on the `act` side.
|
|
41
|
+
*
|
|
42
|
+
* Each instance is single-use: calling `run()` more than once on the same
|
|
43
|
+
* instance rejects with an `ActRunnerError`. Create a new instance for each
|
|
44
|
+
* run.
|
|
45
|
+
*/
|
|
46
|
+
export declare class ActRunner<TEventType extends WebhookEventName | undefined = undefined, TEventPayload extends EventPayload<TEventType> = undefined> {
|
|
47
|
+
private actExecutable;
|
|
48
|
+
private workingDir;
|
|
49
|
+
private workflowSource;
|
|
50
|
+
private eventType;
|
|
51
|
+
private eventPayloadFileOrBody;
|
|
52
|
+
private envSource;
|
|
53
|
+
private inputsSource;
|
|
54
|
+
private secretsSource;
|
|
55
|
+
private variablesSource;
|
|
56
|
+
private matrixValues;
|
|
57
|
+
private cacheServer;
|
|
58
|
+
private artifactServer;
|
|
59
|
+
private additionalArgs;
|
|
60
|
+
private outputListener;
|
|
61
|
+
private hasRun;
|
|
62
|
+
/**
|
|
63
|
+
* Sets the path to the `act` executable (default: `act` binary on the
|
|
64
|
+
* `PATH`). Useful in the CI environments, where the executable is provisioned
|
|
65
|
+
* on demand in a controlled location.
|
|
66
|
+
*
|
|
67
|
+
* @param actExecutable - Path to the `act` executable.
|
|
68
|
+
*/
|
|
69
|
+
withActExecutable(actExecutable: string): this;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the directory to use for the runner's storage needs (default:
|
|
72
|
+
* directory in user's temp folder).
|
|
73
|
+
*
|
|
74
|
+
* @param {string} workingDir - The runner's working directory
|
|
75
|
+
*/
|
|
76
|
+
withWorkingDir(workingDir: string): this;
|
|
77
|
+
/**
|
|
78
|
+
* Specifies the GitHub workflow to run, either as a file path or an inline
|
|
79
|
+
* body.
|
|
80
|
+
*
|
|
81
|
+
* @param source - The workflow source
|
|
82
|
+
*/
|
|
83
|
+
withWorkflow(source: ActWorkflowSource): this;
|
|
84
|
+
/**
|
|
85
|
+
* Configures the event that triggers the workflow run (e.g., `push`). If
|
|
86
|
+
* unspecified, the first event type specified in the workflow definition will
|
|
87
|
+
* be used.
|
|
88
|
+
*
|
|
89
|
+
* @param type - Type of the event to trigger the workflow
|
|
90
|
+
* @param payloadFileOrBody - Event payload as plain JS object or path to the
|
|
91
|
+
* JSON file
|
|
92
|
+
*/
|
|
93
|
+
withEvent<E extends WebhookEventName, EP extends EventPayload<E>>(type: E, payloadFileOrBody?: EP): ActRunner<E, EP>;
|
|
94
|
+
/**
|
|
95
|
+
* Specifies environment variables to use when invoking the given workflow,
|
|
96
|
+
* provided via a file, inline values, or both. Replaces any environment
|
|
97
|
+
* variables set by a previous call to this method.
|
|
98
|
+
*
|
|
99
|
+
* @param source - Environment variables source
|
|
100
|
+
*/
|
|
101
|
+
withEnv(source: ActValueSource): this;
|
|
102
|
+
/**
|
|
103
|
+
* Specifies inputs values to use when invoking the given workflow, provided
|
|
104
|
+
* via a file, inline values, or both. Replaces any inputs values set by a
|
|
105
|
+
* previous call to this method.
|
|
106
|
+
*
|
|
107
|
+
* @param source - Inputs values source
|
|
108
|
+
*/
|
|
109
|
+
withInputs(source: ActValueSource): this;
|
|
110
|
+
/**
|
|
111
|
+
* Specifies secrets values to use when invoking the given workflow, provided
|
|
112
|
+
* via a file, inline values, or both. Replaces any secrets values set by a
|
|
113
|
+
* previous call to this method.
|
|
114
|
+
*
|
|
115
|
+
* @param source - Secrets values source
|
|
116
|
+
*/
|
|
117
|
+
withSecrets(source: ActValueSource): this;
|
|
118
|
+
/**
|
|
119
|
+
* Specifies workflow variables values to use when invoking the given
|
|
120
|
+
* workflow, provided via a file, inline values, or both. Replaces any
|
|
121
|
+
* variables values set by a previous call to this method.
|
|
122
|
+
*
|
|
123
|
+
* @param source - Variables values source
|
|
124
|
+
*/
|
|
125
|
+
withVariables(source: ActValueSource): this;
|
|
126
|
+
/**
|
|
127
|
+
* Set matrix values to run the workflow with. If undefined, all combinations
|
|
128
|
+
* specified in the workflow definition will be invoked. Replaces any matrix
|
|
129
|
+
* values set by a previous call to this method.
|
|
130
|
+
*
|
|
131
|
+
* @param matrixValues - Matrix values to run the workflow with
|
|
132
|
+
*/
|
|
133
|
+
withMatrix(matrixValues: ActMatrixValues): this;
|
|
134
|
+
/**
|
|
135
|
+
* Configures the cache server to be used by the given workflow.
|
|
136
|
+
*
|
|
137
|
+
* @param spec - Cache server configuration
|
|
138
|
+
*/
|
|
139
|
+
withCacheServer(spec: ActResourceServerSpec): this;
|
|
140
|
+
/**
|
|
141
|
+
* Configures the artifact server to be used by the given workflow.
|
|
142
|
+
*
|
|
143
|
+
* @param spec - Artifact server configuration
|
|
144
|
+
*/
|
|
145
|
+
withArtifactServer(spec: ActResourceServerSpec): this;
|
|
146
|
+
/**
|
|
147
|
+
* Arbitrary additional arguments to pass to the `act` execution.
|
|
148
|
+
*
|
|
149
|
+
* @param {...string} args - Additional arguments to invoke `act` with
|
|
150
|
+
*/
|
|
151
|
+
withAdditionalArgs(...args: string[]): this;
|
|
152
|
+
/**
|
|
153
|
+
* Forwards the act output to the supplied listeners. When no listener is
|
|
154
|
+
* specified, forwards the output to the console.
|
|
155
|
+
*
|
|
156
|
+
* @param listeners - Output consumers.
|
|
157
|
+
*/
|
|
158
|
+
forwardOutput(...listeners: ActOutputListener[]): this;
|
|
159
|
+
/**
|
|
160
|
+
* Invokes `act` with specified options.
|
|
161
|
+
*
|
|
162
|
+
* @param options - Options controlling this run, such as an abort signal
|
|
163
|
+
* @returns Workflow execution result for inspection
|
|
164
|
+
*/
|
|
165
|
+
run(options?: ActProcessOptions): Promise<ActWorkflowExecResult>;
|
|
166
|
+
private validateRunnerParams;
|
|
167
|
+
}
|
|
168
|
+
export {};
|