forked from FreeRTOS/CI-CD-Github-Actions
-
Notifications
You must be signed in to change notification settings - Fork 0
392 lines (356 loc) · 14.3 KB
/
executableMonitorTests.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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
name: Executable Monitor Tests
on:
push:
branches: ["**"]
pull_request:
branches: [main, v2]
workflow_dispatch:
env:
# The bash escape character is \033
bashPass: \033[32;1mPASSED -
bashInfo: \033[33;1mINFO -
bashFail: \033[31;1mFAILED -
bashEnd: \033[0m
jobs:
test-exe-monitor-success-cases:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- env:
stepName: Install Windows Build tools
name: ${{ env.stepName }}
if: runner.os == 'Windows'
id: install-windows-build-tools
uses: microsoft/[email protected]
- env:
stepName: Install Ubuntu Build Tools
name: ${{ env.stepName }}
if: runner.os == 'Linux'
id: install-ubuntu-build--tools
run: |
# ${{ env.stepName }}
echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}"
sudo apt install build-essential
exitStatus=$?
echo -e "::endgroup::"
if [ $exitStatus -eq 0 ]; then
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
exit 1
fi
- env:
stepName: Compile Executable Monitor Test Files
name: ${{ env.stepName }}
id: compile-executable-monitor-test-files
shell: bash
run: |
# ${{ env.stepName }}
echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}"
gcc executable-monitor/test.c -o executable-monitor/test.out
gcc -DEXIT_WITH_MINUTES executable-monitor/test.c -o executable-monitor/test_exit_current_minutes.out
readlink -f executable-monitor/test.out
readlink -f executable-monitor/test_exit_current_minutes.out
exitStatus=$?
echo -e "::endgroup::"
if [ $exitStatus -eq 0 ]; then
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
exit 1
fi
# Get future times from now, then look for that in the executable
- env:
stepName: Get Future Times
name: ${{ env.stepName }}
id: future-time
shell: bash
run: |
# ${{ env.stepName }}
set -x
echo -e "${{ env.bashInfo }} Getting Future Times to Compare Against ${{ env.bashEnd }}"
echo "exitCodeThreeMinutes=$(date --date='3 minutes' +%M)" >> "$GITHUB_ENV"
echo "successLineFourMinutes=$(date --date='4 minutes' +%H:%M)" >> "$GITHUB_ENV"
echo "successLineFiveMinutes=$(date --date='5 minutes' +%H:%M)" >> "$GITHUB_ENV"
echo "exitCodeSixMinutes=$(date --date='6 minutes' +%M)" >> "$GITHUB_ENV"
- env:
stepName: "Functional | Exit Code | Exit Code Found"
name: ${{ env.stepName }}
id: exe-monitor-exit-code
uses: ./executable-monitor
with:
exe-path: executable-monitor/test.out
success-exit-code: 0
log-dir: logDirectory
timeout-seconds: 60
- env:
stepName: "Functional | Success Line | Success Line Found"
name: ${{ env.stepName }}
id: exe-monitor-success-line
uses: ./executable-monitor
with:
exe-path: executable-monitor/test.out
success-line: "SLEEPING FOR 6 SECONDS"
log-dir: logDirectory
timeout-seconds: 30
- env:
stepName: "Functional | Exit Code and Success Line | Exit Code Found"
name: ${{ env.stepName }}
id: exe-monitor-find-exit-code
uses: ./executable-monitor
with:
exe-path: executable-monitor/test.out
success-line: "LINE_THAT_WILL_NOT_PRINT"
success-exit-code: 0
timeout-seconds: 60
- env:
stepName: "Functional | Exit Code and Success Line | Success Line Found"
name: ${{ env.stepName }}
id: exe-monitor-find-success-line
uses: ./executable-monitor
with:
exe-path: executable-monitor/test.out
success-line: "SLEEPING FOR 6 SECONDS"
success-exit-code: 0
timeout-seconds: 30
- env:
stepName: "Functional | Retry Needed | Exit Code Found"
name: ${{ env.stepName }}
id: exe-monitor-retry-find-exit-code
uses: ./executable-monitor
with:
exe-path: executable-monitor/test_exit_current_minutes.out
success-exit-code: ${{ env.exitCodeThreeMinutes }}
retry-attempts: 10
timeout-seconds: 60
- env:
stepName: "Functional | Retry Needed | Success Line Found"
name: ${{ env.stepName }}
id: exe-monitor-retry-find-success-line
uses: ./executable-monitor
with:
exe-path: executable-monitor/test_exit_current_minutes.out
success-line: ${{ env.successLineFourMinutes }}
retry-attempts: 10
timeout-seconds: 60
- env:
stepName: "Functional | Retry Needed | Exit Code and Success Line | Success Line Found"
name: ${{ env.stepName }}
id: exe-monitor-retry-both-inputs-find-success-line
uses: ./executable-monitor
with:
# Use the EXE that doesn't exit with the current minutes
exe-path: executable-monitor/test.out
success-line: ${{ env.successLineFiveMinutes }}
success-exit-code: 1
retry-attempts: 10
timeout-seconds: 60
- env:
stepName: "Functional | Retry Needed | Exit Code and Success Line | Exit Code Found"
name: ${{ env.stepName }}
id: exe-monitor-retry-both-inputs-find-exit
uses: ./executable-monitor
with:
exe-path: executable-monitor/test_exit_current_minutes.out
success-line: "LINE_THAT_WILL_NOT_PRINT"
success-exit-code: ${{ env.exitCodeSixMinutes }}
retry-attempts: 10
timeout-seconds: 60
test-exe-monitor-failure-cases:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- env:
stepName: Install Windows Build tools
name: ${{ env.stepName }}
if: runner.os == 'Windows'
id: install-windows-build-tools
uses: microsoft/[email protected]
- env:
stepName: Install Ubuntu Build Tools
name: ${{ env.stepName }}
if: runner.os == 'Linux'
id: install-ubuntu-build--tools
run: |
# Install Ubuntu Build Tools
echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}"
sudo apt install build-essential
exitStatus=$?
echo -e "::endgroup::"
if [ $exitStatus -eq 0 ]; then
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
exit 1
fi
- env:
stepName: Compile Executable Monitor Test Files
name: ${{ env.stepName }}
id: compile-executable-monitor-test-files
shell: bash
run: |
# ${{ env.stepName }}
echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}"
gcc executable-monitor/test.c -o executable-monitor/test.out
gcc -DEXIT_WITH_MINUTES executable-monitor/test.c -o executable-monitor/test_exit_current_minutes.out
readlink -f executable-monitor/test.out
readlink -f executable-monitor/test_exit_current_minutes.out
exitStatus=$?
echo -e "::endgroup::"
if [ $exitStatus -eq 0 ]; then
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
exit 1
fi
- env:
stepName: "API | Failure | No Executable Provided"
id: exe-monitor-fail-no-exe
uses: ./executable-monitor
continue-on-error: true
with:
timeout-seconds: 30
- env:
stepName: "API | Failure | No Success Condition Provided"
name: ${{ env.stepName }}
id: exe-monitor-fail-no-success-condition
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
log-dir: logDirectory
timeout-seconds: 30
- env:
stepName: "Functional | Failure | Timeout Cause No Success Line To Print"
name: ${{ env.stepName }}
id: exe-monitor-fail-timeout-no-success-line
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
# This is a line that would print if not for timeout
success-line: "SLEEPING FOR 9 SECONDS"
timeout-seconds: 2
- env:
stepName: "Functional | Failure | Timeout Cause No Exit Code"
name: ${{ env.stepName }}
id: exe-monitor-fail-timeout-no-exit-code
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
# This is an exit status that should be met if not for timeou
success-exit-code: 0
timeout-seconds: 2
- env:
stepName: "Functional | Failure | Timeout Cause Neither Condition"
name: ${{ env.stepName }}
id: exe-monitor-fail-timeout-no-condition
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
# These are exit conditions that should be met if not for timeout
success-line: "SLEEPING FOR 9 SECONDS"
success-exit-code: 0
timeout-seconds: 2
- env:
stepName: "Functional | Failure | Retries Timeout Cause No Success Line To Print"
name: ${{ env.stepName }}
id: exe-monitor-fail-retries-timeout-no-success-line
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
# This is a line that would print if not for timeout
success-line: "SLEEPING FOR 9 SECONDS"
timeout-seconds: 2
retry-attempts: 2
- env:
stepName: "Functional | Failure | Retries Timeout Cause No Exit Code"
name: ${{ env.stepName }}
id: exe-monitor-fail-retries-no-exit-code
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
# This is an exit status that should be met if not for timeout
success-exit-code: 0
timeout-seconds: 2
retry-attempts: 2
- env:
stepName: "Functional | Failure | Retries Timeout Cause Neither Condition "
name: ${{ env.stepName }}
id: exe-monitor-fail-retries-no-success-condition
uses: ./executable-monitor
continue-on-error: true
with:
exe-path: executable-monitor/test.out
# These are exit conditions that should be met if not for timeout
success-line: "SLEEPING FOR 9 SECONDS"
success-exit-code: 0
timeout-seconds: 2
retry-attempts: 2
- env:
stepName: Check Failure Test Cases
name: ${{ env.stepName }}
id: check-failure-test-cases
shell: bash
run: |
# ${{ env.stepName }}
if [ "${{ steps.exe-monitor-fail-no-exe.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | No Executable Provided | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | No Executable Provided | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-no-success-condition.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | No Success Condition Provided | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | No Success Condition Provided | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-timeout-no-success-line.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | Timeout Cause No Success Line To Print | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | Timeout Cause No Success Line To Print | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-timeout-no-exit-code.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | Timeout Cause No Exit Code | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | Timeout Cause No Exit Code | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-timeout-no-condition.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | Timeout Cause Neither Condition | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | Timeout Cause Neither Condition | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-retries-timeout-no-success-line.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | Retries Timeout Cause No Success Line To Print | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | Retries Timeout Cause No Success Line To Print | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-retries-no-exit-code.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | Retries Timeout Cause No Exit Code | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | Retries Timeout Cause No Exit Code | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi
if [ "${{ steps.exe-monitor-fail-retries-no-success-condition.outcome}}" = "failure" ]; then
echo -e "${{ env.bashPass }} | Retries Timeout Cause Neither Condition | Failed As Intended ${{ env.bashEnd }}"
else
echo -e "${{ env.bashFail }} | Retries Timeout Cause Neither Condition | Had Unexpected Pass ${{ env.bashEnd }}"
exit 1
fi