-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e-action-container-structure-test.yml
More file actions
386 lines (338 loc) · 12.3 KB
/
Copy pathe2e-action-container-structure-test.yml
File metadata and controls
386 lines (338 loc) · 12.3 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
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
name: (T) Action Container Structure Test
on:
workflow_call:
inputs:
mode:
description: Execution mode (ref or image)
required: false
type: string
default: ref
image_tag:
description: Image tag for docker mode (for example v1.2.3-test or v1.2.3-rc)
required: false
type: string
default: v1
workflow_dispatch:
inputs:
mode:
description: Execution mode (ref or image)
required: false
default: ref
type: choice
options:
- ref
- image
image_tag:
description: Image tag for docker mode (for example v1.2.3-test or v1.2.3-rc)
required: false
default: v1
type: string
permissions:
contents: read
jobs:
preflight:
name: Validate workflow inputs
runs-on: ubuntu-24.04-arm
steps:
- name: Validate mode input
run: |
case "${{ inputs.mode }}" in
ref|image) ;;
*)
echo "Unsupported mode '${{ inputs.mode }}'. Expected 'ref' or 'image'."
exit 1
;;
esac
- name: Enforce organization caller for reusable workflow
if: ${{ github.event_name == 'workflow_call' }}
run: |
if [ "${{ github.repository }}" != "devops-infra/triglav" ]; then
echo "This reusable workflow can only be called by devops-infra/triglav."
exit 1
fi
text-output:
name: Basic test with text output format
needs: [preflight]
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Pull Alpine test image
run: docker pull alpine:3.23.4
- name: Prepare shared temp directory
run: mkdir -p .tmp
- name: Create CST config
run: |
cat > .tmp/cst-alpine.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
- name: Run container structure tests with text output
if: ${{ inputs.mode == 'ref' }}
id: cst
uses: devops-infra/action-container-structure-test@v1
with:
image: alpine:3.23.4
config: .tmp/cst-alpine.yml
output: text
- name: Run container structure tests via docker image (preview)
if: ${{ inputs.mode == 'image' }}
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "image_tag is required when mode=image"
exit 1
fi
echo "Image mode placeholder for devopsinfra/action-container-structure-test:${{ inputs.image_tag }}"
echo "Use ref mode for authoritative validation until image-mode harness is finalized."
- name: Verify test result outputs
if: ${{ inputs.mode == 'ref' }}
run: |
echo "total=${{ steps.cst.outputs.total }}"
echo "passed=${{ steps.cst.outputs.passed }}"
echo "failed=${{ steps.cst.outputs.failed }}"
echo "exit_code=${{ steps.cst.outputs.exit_code }}"
test "${{ steps.cst.outputs.exit_code }}" = "0"
test "${{ steps.cst.outputs.failed }}" = "0"
json-output:
name: Test with JSON output format
needs: [preflight]
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Pull Alpine test image
run: docker pull alpine:3.23.4
- name: Prepare shared temp directory
run: mkdir -p .tmp
- name: Create CST config
run: |
cat > .tmp/cst-alpine.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
- name: Run container structure tests with JSON output
if: ${{ inputs.mode == 'ref' }}
id: cst
uses: devops-infra/action-container-structure-test@v1
with:
image: alpine:3.23.4
config: .tmp/cst-alpine.yml
output: json
- name: Run container structure tests via docker image (preview)
if: ${{ inputs.mode == 'image' }}
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "image_tag is required when mode=image"
exit 1
fi
echo "Image mode placeholder for devopsinfra/action-container-structure-test:${{ inputs.image_tag }}"
echo "Use ref mode for authoritative validation until image-mode harness is finalized."
- name: Verify test result outputs
if: ${{ inputs.mode == 'ref' }}
run: |
echo "total=${{ steps.cst.outputs.total }}"
echo "passed=${{ steps.cst.outputs.passed }}"
echo "exit_code=${{ steps.cst.outputs.exit_code }}"
test "${{ steps.cst.outputs.exit_code }}" = "0"
junit-output:
name: Test with JUnit output format and suite name
needs: [preflight]
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Pull Alpine test image
run: docker pull alpine:3.23.4
- name: Prepare shared temp directory
run: mkdir -p .tmp
- name: Create CST config
run: |
cat > .tmp/cst-alpine.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
- name: Run container structure tests with JUnit output
if: ${{ inputs.mode == 'ref' }}
id: cst
uses: devops-infra/action-container-structure-test@v1
with:
image: alpine:3.23.4
config: .tmp/cst-alpine.yml
output: junit
junit_suite_name: e2e-alpine-tests
- name: Run container structure tests via docker image (preview)
if: ${{ inputs.mode == 'image' }}
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "image_tag is required when mode=image"
exit 1
fi
echo "Image mode placeholder for devopsinfra/action-container-structure-test:${{ inputs.image_tag }}"
echo "Use ref mode for authoritative validation until image-mode harness is finalized."
- name: Verify test result outputs
if: ${{ inputs.mode == 'ref' }}
run: |
echo "total=${{ steps.cst.outputs.total }}"
echo "passed=${{ steps.cst.outputs.passed }}"
echo "exit_code=${{ steps.cst.outputs.exit_code }}"
test "${{ steps.cst.outputs.exit_code }}" = "0"
test-report-file:
name: Test with report written to file
needs: [preflight]
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Pull Alpine test image
run: docker pull alpine:3.23.4
- name: Prepare shared temp directory
run: mkdir -p .tmp
- name: Create CST config
run: |
cat > .tmp/cst-alpine.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
- name: Run container structure tests saving report to file
if: ${{ inputs.mode == 'ref' }}
id: cst
uses: devops-infra/action-container-structure-test@v1
with:
image: alpine:3.23.4
config: .tmp/cst-alpine.yml
output: json
test_report: .tmp/cst-report.json
- name: Run container structure tests via docker image (preview)
if: ${{ inputs.mode == 'image' }}
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "image_tag is required when mode=image"
exit 1
fi
echo "Image mode placeholder for devopsinfra/action-container-structure-test:${{ inputs.image_tag }}"
echo "Use ref mode for authoritative validation until image-mode harness is finalized."
- name: Verify report file was created
if: ${{ inputs.mode == 'ref' }}
run: test -f .tmp/cst-report.json
- name: Verify test result outputs
if: ${{ inputs.mode == 'ref' }}
run: |
echo "total=${{ steps.cst.outputs.total }}"
echo "passed=${{ steps.cst.outputs.passed }}"
echo "exit_code=${{ steps.cst.outputs.exit_code }}"
test "${{ steps.cst.outputs.exit_code }}" = "0"
multiple-config-files:
name: Test with multiple config files
needs: [preflight]
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Pull Alpine test image
run: docker pull alpine:3.23.4
- name: Prepare shared temp directory
run: mkdir -p .tmp
- name: Create CST configs
run: |
cat > .tmp/cst-alpine.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
cat > .tmp/cst-alpine-secondary.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
- name: Run container structure tests with multiple config files
if: ${{ inputs.mode == 'ref' }}
id: cst
uses: devops-infra/action-container-structure-test@v1
with:
image: alpine:3.23.4
config: |
.tmp/cst-alpine.yml
.tmp/cst-alpine-secondary.yml
output: text
- name: Run container structure tests via docker image (preview)
if: ${{ inputs.mode == 'image' }}
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "image_tag is required when mode=image"
exit 1
fi
echo "Image mode placeholder for devopsinfra/action-container-structure-test:${{ inputs.image_tag }}"
echo "Use ref mode for authoritative validation until image-mode harness is finalized."
- name: Verify combined test results
if: ${{ inputs.mode == 'ref' }}
run: |
echo "total=${{ steps.cst.outputs.total }}"
echo "passed=${{ steps.cst.outputs.passed }}"
echo "failed=${{ steps.cst.outputs.failed }}"
echo "exit_code=${{ steps.cst.outputs.exit_code }}"
test "${{ steps.cst.outputs.exit_code }}" = "0"
test "${{ steps.cst.outputs.failed }}" = "0"
metadata-platform-runtime:
name: Test with platform and runtime inputs
needs: [preflight]
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Pull Alpine test image
run: docker pull alpine:3.23.4
- name: Prepare shared temp directory
run: mkdir -p .tmp
- name: Create CST config
run: |
cat > .tmp/cst-alpine.yml << 'EOF'
schemaVersion: "2.0.0"
fileExistenceTests:
- name: Busybox present
path: /bin/sh
shouldExist: true
EOF
- name: Run container structure tests with platform/runtime
if: ${{ inputs.mode == 'ref' }}
id: cst
uses: devops-infra/action-container-structure-test@v1
with:
image: alpine:3.23.4
config: .tmp/cst-alpine.yml
driver: docker
platform: linux/amd64
runtime: runc
output: text
- name: Run container structure tests via docker image (preview)
if: ${{ inputs.mode == 'image' }}
run: |
if [ -z "${{ inputs.image_tag }}" ]; then
echo "image_tag is required when mode=image"
exit 1
fi
echo "Image mode placeholder for devopsinfra/action-container-structure-test:${{ inputs.image_tag }}"
echo "Use ref mode for authoritative validation until image-mode harness is finalized."
- name: Verify test result outputs
if: ${{ inputs.mode == 'ref' }}
run: |
echo "total=${{ steps.cst.outputs.total }}"
echo "passed=${{ steps.cst.outputs.passed }}"
echo "failed=${{ steps.cst.outputs.failed }}"
echo "exit_code=${{ steps.cst.outputs.exit_code }}"
test "${{ steps.cst.outputs.exit_code }}" = "0"