-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
76 lines (64 loc) · 2.14 KB
/
Copy pathaction.yml
File metadata and controls
76 lines (64 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: "Run Bash Command with Options"
description: "Run Bash commands in CI. Optionally enforce a time limit and treat timeout as success. Supports Linux/macOS runners."
author: "ZHANG Zaikun (https://www.zhangzk.net)"
branding:
icon: "clock"
color: "blue"
inputs:
timelimit:
description: "Time limit passed to (g)timeout (e.g., 300s, 45m, 2h)."
required: true
command:
description: "Command(s) to run (multiline supported)."
required: true
signal:
description: "Signal sent when the time limit is reached."
required: false
default: "TERM"
kill-after:
description: "Delay before SIGKILL after sending --signal (e.g., 30s)."
required: false
default: "30s"
working-directory:
description: "Working directory for running the command(s)."
required: false
default: ""
install-coreutils:
description: "On macOS, install coreutils to provide gtimeout if missing."
required: false
default: "true"
quiet:
description: "If true, reduce log output."
required: false
default: "false"
outputs:
timed_out:
description: "true if the command hit the time limit (and was treated as success)."
value: ${{ steps.rbc.outputs.timed_out }}
exit_code:
description: "The underlying command exit code (124 means timeout in coreutils semantics)."
value: ${{ steps.rbc.outputs.exit_code }}
runs:
using: "composite"
steps:
- name: Ensure gtimeout exists (macOS)
if: runner.os == 'macOS' && inputs.install-coreutils == 'true'
shell: bash
run: |
set -Eeuo pipefail
if ! command -v gtimeout >/dev/null 2>&1; then
export HOMEBREW_NO_AUTO_UPDATE=1
brew install coreutils
fi
- id: rbc
name: Run with (g)timeout; timeout => success
shell: bash
env:
INPUT_TIMELIMIT: ${{ inputs.timelimit }}
INPUT_COMMAND: ${{ inputs.command }}
INPUT_SIGNAL: ${{ inputs.signal }}
INPUT_KILL_AFTER: ${{ inputs.kill-after }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}
INPUT_QUIET: ${{ inputs.quiet }}
run: |
bash "${{ github.action_path }}/run.sh"