Skip to content

Commit 0288bf0

Browse files
authored
feat(step): Support timeout-minutes (#34)
1 parent de24249 commit 0288bf0

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/package/step.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ describe("stepJSON", () => {
4848
},
4949
{ "continue-on-error": "${{ foo }}", run: "echo 'Hello, world!'" },
5050
],
51+
[
52+
{ kind: "run", timeoutMinutes: 10, command: "echo 'Hello, world!'" },
53+
{ "timeout-minutes": 10, run: "echo 'Hello, world!'" },
54+
],
55+
[
56+
{
57+
kind: "run",
58+
timeoutMinutes: "${{ foo }}",
59+
command: "echo 'Hello, world!'",
60+
},
61+
{ "timeout-minutes": "${{ foo }}", run: "echo 'Hello, world!'" },
62+
],
5163
])("stepJSON(%j) -> %j", (input, expected) => {
5264
expect(stepJSON(input)).toEqual(expected);
5365
});
@@ -95,6 +107,18 @@ describe("stepJSON", () => {
95107
},
96108
{ "continue-on-error": "${{ foo }}", uses: "actions/checkout@v4" },
97109
],
110+
[
111+
{ kind: "uses", timeoutMinutes: 10, action: "actions/checkout@v4" },
112+
{ "timeout-minutes": 10, uses: "actions/checkout@v4" },
113+
],
114+
[
115+
{
116+
kind: "uses",
117+
timeoutMinutes: "${{ foo }}",
118+
action: "actions/checkout@v4",
119+
},
120+
{ "timeout-minutes": "${{ foo }}", uses: "actions/checkout@v4" },
121+
],
98122
])("stepJSON(%j) -> %j", (input, expected) => {
99123
expect(stepJSON(input)).toEqual(expected);
100124
});

lib/package/step.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type StepBase = {
77
env?: Record<string, string>;
88
if?: string | boolean | number;
99
continueOnError?: boolean | Expression;
10-
// TODO: timeout-minutes
10+
timeoutMinutes?: number | Expression;
1111
};
1212

1313
export type RunStep = StepBase & {
@@ -34,6 +34,9 @@ export function stepJSON(step: Step): Record<string, unknown> {
3434
...(step.continueOnError != null && {
3535
"continue-on-error": step.continueOnError,
3636
}),
37+
...(step.timeoutMinutes != null && {
38+
"timeout-minutes": step.timeoutMinutes,
39+
}),
3740
};
3841

3942
switch (step.kind) {

0 commit comments

Comments
 (0)