-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
242 lines (222 loc) · 10.5 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: "Eggplant Runner"
description: "Triggers a run from DAI test configuration."
inputs:
serverURL:
description: "The URL of Eggplant DAI server, http(s)://dai_server_hostname:portnumber"
required: true
testConfigID:
description: "The ID of the Eggplant DAI test configuration that you want to run, e.g. 09c48b7d-fc5b-481d-af80-fcffad5d9587"
required: false
testConfigName:
description: "The name of the test config that you want to run"
required: false
modelName:
description: "DAI model name for the specified test configuration.(Use this argument if only testConfigName are provided)"
required: false
suiteName:
description: "DAI suite name for the specified test configuration.(Use this argument if only testConfigName are provided)"
required: false
clientID:
description: "The client ID to use to authenticate with the Eggplant DAI server"
required: true
clientSecret:
description: "The client secret to use to authenticate with the Eggplant DAI server [env var: DAI_CLIENT_SECRET; required]"
required: true
requestTimeout:
description: "The timeout in seconds for each HTTP request to the Eggplant DAI server [default: 30]"
required: false
type: integer
default: 30
requestRetries:
description: "The number of times to attempt each HTTP request to the Eggplant DAI server [default: 5]"
required: false
type: integer
default: 5
backoffFactor:
description: "The exponential backoff factor between each HTTP request [default: 0.5]"
required: false
type: float
default: 0.5
logLevel:
description: "The logging level [default: INFO]"
required: false
default: "INFO"
CACertPath:
description: "The path to an alternative Certificate Authority pem file"
required: false
testResultPath:
description: "Location to store the test results generated from test configuration execution"
required: false
eggplantRunnerPath:
description: "The path to eggplant runner CLI executable"
required: false
parameters:
description: "The global parameter(s) to override in the format parameter_name=parameter_value"
required: false
dryRun:
description: "Perform a dry run only"
required: false
default: false
gitlabAccessToken:
description: "Engineering/Development only: Personal Access Token to download CLI exe from GitLab Packages."
required: false
branding:
icon: 'chevron-right'
color: 'purple'
runs:
using: "composite"
steps:
- name: Setup environment variables
run: |
EXE_VERSION="$(echo "$DAI_VERSION" | tr [:upper:] [:lower:])"
EXE_FILENAME=""
if [ "$RUNNER_OS" == "Windows" ]; then
EXE_FILENAME=eggplant-runner-Windows-$EXE_VERSION.exe
elif [ "$RUNNER_OS" == "Linux" ]; then
EXE_FILENAME=eggplant-runner-Linux-$EXE_VERSION
elif [ "$RUNNER_OS" == "macOS" ]; then
EXE_FILENAME=eggplant-runner-MacOS-$EXE_VERSION
else
echo "Unexpected OS: $RUNNER_OS";exit 1;
fi
if [ -n "${{ inputs.clientSecret }}" ]; then
echo "DAI_CLIENT_SECRET=${{ inputs.clientSecret }}" >> $GITHUB_ENV
fi
echo "CLI_FILENAME=$EXE_FILENAME" >> $GITHUB_ENV
echo "DAI_VERSION=$DAI_VERSION" >> $GITHUB_ENV
echo "DOWNLOAD_URL=https://assets.eggplantsoftware.com/EggplantRunner/$EXE_FILENAME" >> $GITHUB_ENV
shell: bash
env:
DAI_VERSION: 25.1.0+3 # AUB-13519_CICD_Junit_file_implementation
- name: Fetch CLI
if: ${{ inputs.eggplantRunnerPath }}
run: |
echo ">> Checking runner..."
[[ "${{ inputs.eggplantRunnerPath }}" = *[!\ ]* ]] || [[ "${{ inputs.eggplantRunnerPath }}" = *[\?\"\*\<\>\|]* ]] || { echo "Error: Invalid Eggplant Runner Path" ; exit 1; }
if [[ ("$RUNNER_OS" == "Windows") && ("${{ inputs.eggplantRunnerPath }}" != *.exe) ]] || [ ! -r "${{ inputs.eggplantRunnerPath }}" ]; then
echo "Error: No such file or permission denied. Eggplant Runner Path: ${{ inputs.eggplantRunnerPath }}"; exit 1;
fi
[ -d "${{ inputs.eggplantRunnerPath }}" ] && { echo "Error: Path provided must not be a directory. Eggplant Runner Path: ${{ inputs.eggplantRunnerPath }}"; exit 1; }
filename=$(basename "${{ inputs.eggplantRunnerPath }}")
filename_minor=""
CLI_minor=""
pattern="eggplant-runner-(Windows|Linux|MacOS)-([0-9]{1,2}\\.[0-9])"
if [[ "$CLI_FILENAME" =~ $pattern ]]; then
CLI_minor="${BASH_REMATCH[0]}"
else
CLI_minor=not correct file format
fi
if [[ "$filename" =~ $pattern ]]; then
filename_minor="${BASH_REMATCH[0]}"
else
filename_minor=not match
fi
if [[ "$filename_minor" != "$CLI_minor" ]]; then
echo "Error: File found is invalid. Required: $CLI_FILENAME. Please download from $DOWNLOAD_URL"; exit 1;
fi
echo "Fetching runner from ${{ inputs.eggplantRunnerPath }}"
CLI_DIR="$RUNNER_TEMP/downloads"
mkdir -p "$CLI_DIR"
cp -f "${{ inputs.eggplantRunnerPath }}" $CLI_DIR
echo "CLI_PATH=$CLI_DIR/$filename" >> $GITHUB_ENV
echo "Fetch complete."
shell: bash
- name: Download CLI
if: ${{ inputs.eggplantRunnerPath == null }}
run: |
echo ">> Downloading runner..."
if [ -n "${{ inputs.gitlabAccessToken }}" ]; then
# Engineering URL download
CLI_DIR="$RUNNER_TEMP/downloads/eng"
mkdir -p "$CLI_DIR"
DOWNLOAD_URL="https://gitlab.com/api/v4/projects/22402994/packages/generic/$DAI_VERSION/0.0.0/$CLI_FILENAME"
echo "Downloading $DOWNLOAD_URL..."
code="$(curl --header "PRIVATE-TOKEN: ${{ inputs.gitlabAccessToken }}" --output "$CLI_DIR/$CLI_FILENAME" --write-out %{http_code} --silent $DOWNLOAD_URL)"
if [ $code -ne 200 ]; then
echo "Error: Download failed. Unable to download from url: $DOWNLOAD_URL. Error details: HTTP Error $code"; exit 1;
fi
echo "CLI_PATH=$CLI_DIR/$CLI_FILENAME" >> $GITHUB_ENV
echo "Download successfully."
else
CLI_DIR="$RUNNER_TEMP/downloads"
if [ -f "$CLI_DIR/$CLI_FILENAME" ]; then
echo "Runner found in default directory, skipping download."
echo "CLI_PATH=$CLI_DIR/$CLI_FILENAME" >> $GITHUB_ENV
else
# Public URL download
mkdir -p "$CLI_DIR"
echo "Downloading $DOWNLOAD_URL..."
code=$(curl -I -s -L "$DOWNLOAD_URL" | awk '/HTTP\/1.1/ {print $2}')
if [ $code -eq 200 ]; then
curl -L "$DOWNLOAD_URL" --silent --output "$CLI_DIR/$CLI_FILENAME"
else
echo "Error: Download failed. Unable to download from url: $DOWNLOAD_URL. Error details: HTTP Error $code"; exit 1;
fi
echo "CLI_PATH=$CLI_DIR/$CLI_FILENAME" >> $GITHUB_ENV
echo "Download successfully."
fi
fi
shell: bash
- name: Set permissions on Eggplant runner executable
run: |
chmod 0755 $CLI_PATH
shell: bash
- name: Run Eggplant DAI Test Configuration
run: |
echo ">> Validating DAI test config parameters..."
[[ "${{ inputs.serverURL }}" ]] || { echo "Error: Missing server URL" ; exit 1; }
[[ "${{ inputs.serverURL }}" = *[!\ ]* ]] || { echo "Error: Server URL consists of empty spaces only." ; exit 1; }
echo "serverURL=${{ inputs.serverURL }}"
if [[ -n "${{ inputs.testConfigID }}" ]]; then
echo "testConfigID=${{ inputs.testConfigID }}"
COMMANDARGS=("${{ inputs.serverURL }}" "${{ inputs.testConfigID }}")
elif [[ -n "${{ inputs.testConfigName }}" ]]; then
echo "testConfigName=${{ inputs.testConfigName }}"
if [[ ( -n "${{ inputs.modelName }}" ) && ( -n "${{ inputs.suiteName }}" ) ]]; then
echo "modelName=${{ inputs.modelName }}"
echo "suiteName=${{ inputs.suiteName }}"
echo "Error: modelName and suiteName found, Use testConfigName with only suiteName or modelName to continue."; exit 1;
elif [[ -n "${{ inputs.modelName }}" ]]; then
echo "modelName=${{ inputs.modelName }}"
COMMANDARGS=("modelbased" "${{ inputs.serverURL }}" "--test-config-name=${{ inputs.testConfigName }}" "--model-name=${{ inputs.modelName }}")
elif [[ -n "${{ inputs.suiteName }}" ]]; then
echo "suiteName=${{ inputs.suiteName }}"
COMMANDARGS=("scriptbased" "${{ inputs.serverURL }}" "--test-config-name=${{ inputs.testConfigName }}" "--suite-name=${{ inputs.suiteName }}")
else
echo "Error: testConfigName found, suiteName or modelName is required."; exit 1;
fi
else
echo "Error: testConfigID and testConfigName not found. Use only testConfigID or testConfigName (with modelName or suiteName) to continue."; exit 1;
fi
echo "Test config data validation complete."
if [ -n "${{ inputs.clientID }}" ]; then
COMMANDARGS+=("--client-id=${{ inputs.clientID }}")
fi
COMMANDARGS+=("--request-timeout=${{ inputs.requestTimeout }}" "--request-retries=${{ inputs.requestRetries }}" "--backoff-factor=${{ inputs.backoffFactor }}" "--log-level=${{ inputs.logLevel }}")
if [ -n "${{ inputs.CACertPath }}" ]; then
if [ ! -e "${{ inputs.CACertPath }}" ]; then
echo "Error: Invalid CA Cert Path"; exit 1;
fi
COMMANDARGS+=("--ca-cert-path=${{ inputs.CACertPath }}")
fi
if [ -n "${{ inputs.testResultPath }}" ]; then
if [ "${{ inputs.testResultPath }}" = *[!\ ]* ] || [[ "${{ inputs.testResultPath }}" = *[\?\"\*\<\>\|]* ]] || [[ "${{ inputs.testResultPath }}" != *.xml ]]; then
echo "Error: Invalid Test Result Path"; exit 1;
fi
COMMANDARGS+=("--test-result-path=${{ inputs.testResultPath }}")
fi
if [ ${{ inputs.dryRun }} == true ]; then
COMMANDARGS+=("--dry-run")
fi
if [ -n "${{ inputs.parameters}}" ]; then
IFS=';;' read -ra values <<< "${{ inputs.parameters }}"
for value in "${values[@]}"; do
if [ -n "$value" ]; then
COMMANDARGS+=("--param")
COMMANDARGS+=("$value")
fi
done
fi
echo "Executing: $CLI_PATH ${COMMANDARGS[@]}"
"$CLI_PATH" "${COMMANDARGS[@]}"
shell: bash