-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
129 lines (124 loc) · 4.07 KB
/
action.yml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: 'Run runn'
description: 'GitHub Action for runn, a tool for api scenario testing.'
branding:
icon: 'octagon'
color: 'gray-dark'
inputs:
command:
description: run or list or loadt
required: true
default: 'run'
path_pattern:
description: Path pattern
required: true
github-token:
description: The GitHub token
default: ${{ github.token }}
required: false
version:
description: Specify runn version
required: false
default: "v0.122.2"
debug:
description: Filter runbooks to be executed
required: false
default: false
verbose:
description: Verbose mode
required: false
default: false
fail-fast:
description: Fail fast mode
required: false
default: false
skip-test:
description: Skip test mode
required: false
default: false
shuffle:
description: Shuffle mode
required: false
default: false
concurrent:
description: Concurrent mode
required: false
default: false
enable-read-parent-scope:
description: Required for reading parent files.(`--scopes read:parent`)
required: false
default: false
enable-read-remote-scope:
description: Required for reading remote files.(`--scopes read:remote`)
required: false
default: false
enable-run-exec-scope:
description: Required for running Exec runner.(`--scopes run:exec`)
required: false
default: false
labels:
description: To filter execution targets, specify labels separated by commas.(For example, `foo,bar` would be `--label "foo,bar"`)
required: false
runs:
using: 'composite'
steps:
- name: 'Check input parameter'
shell: 'bash'
run: |
#
# subcommand check
#
if [[ ! "${{ inputs.command }}" =~ ^(run|list|loadt)$ ]]; then
echo "Error: Invalid command ${{ inputs.command }} is not supported. Please specify run or list or loadt."
exit 1
fi
#
# version check
#
if [[ "${{ inputs.version }}" == "latest" ]]; then
exit 0
fi
# vx.y.z -> x.y.z
input_version=$(echo "${{ inputs.version }}" | sed 's/^v//')
compatible_version=$(echo "v0.64.0" | sed 's/^v//')
# x.y.z -> [x, y, z]
IFS='.' read -r -a splitted_input_version <<< "$input_version"
IFS='.' read -r -a splitted_compatible_version <<< "$compatible_version"
for i in {0..2}; do
# check if number
if [[ ! ${splitted_input_version[i]} =~ ^[0-9]+$ ]]; then
echo "Error: $input_version is invalid version."
exit 1
fi
# compare version
if ((10#${splitted_input_version[i]} < 10#${splitted_compatible_version[i]})); then
echo "Error: runn version $input_version is not supported. Please use $compatible_version or higher."
exit 1
fi
done
- name: Setup k1LoW/runn
uses: k1LoW/gh-setup@v1
with:
github-token: ${{ inputs.github-token }}
repo: k1LoW/runn
version: ${{ inputs.version }}
- name: 'Run runn'
shell: 'bash'
run: |
if [ -n "${{ inputs.labels }}" ]; then
LABEL_OPTIONS="--label \"${{ inputs.labels }}\""
fi
echo "label options: $LABEL_OPTIONS"
shopt -s globstar
runn \
${{ inputs.command }} \
${{ inputs.path_pattern }} \
${{ (inputs.debug == 'true' && '--debug') || '' }} \
${{ (inputs.verbose == 'true' && '--verbose') || '' }} \
${{ (inputs.fail-fast == 'true' && '--fail-fast') || '' }} \
${{ (inputs.skip-test == 'true' && '--skip-test') || '' }} \
${{ (inputs.shuffle == 'true' && '--shuffle on') || '' }} \
${{ (inputs.concurrent == 'true' && '--concurrent on') || '' }} \
${{ (inputs.enable-read-parent-scope == 'true' && '--scopes read:parent') || '' }} \
${{ (inputs.enable-read-remote-scope == 'true' && '--scopes read:remote') || '' }} \
${{ (inputs.enable-run-exec-scope == 'true' && '--scopes run:exec') || '' }} \
$LABEL_OPTIONS