Skip to content

Commit 98b41df

Browse files
feat: update container structure test configurations to use temporary files
1 parent bfaa468 commit 98b41df

1 file changed

Lines changed: 97 additions & 13 deletions

File tree

.github/workflows/e2e-action-container-structure-test.yml

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,26 @@ jobs:
6666
- name: Pull Alpine test image
6767
run: docker pull alpine:3.23.4
6868

69+
- name: Prepare shared temp directory
70+
run: mkdir -p .tmp
71+
72+
- name: Create CST config
73+
run: |
74+
cat > .tmp/cst-alpine.yml << 'EOF'
75+
schemaVersion: "2.0.0"
76+
fileExistenceTests:
77+
- name: Busybox present
78+
path: /bin/sh
79+
shouldExist: true
80+
EOF
81+
6982
- name: Run container structure tests with text output
7083
if: ${{ inputs.mode == 'ref' }}
7184
id: cst
7285
uses: devops-infra/action-container-structure-test@v1
7386
with:
7487
image: alpine:3.23.4
75-
config: tests/docker/local-image.yml
88+
config: .tmp/cst-alpine.yml
7689
output: text
7790

7891
- name: Run container structure tests via docker image (preview)
@@ -106,13 +119,26 @@ jobs:
106119
- name: Pull Alpine test image
107120
run: docker pull alpine:3.23.4
108121

122+
- name: Prepare shared temp directory
123+
run: mkdir -p .tmp
124+
125+
- name: Create CST config
126+
run: |
127+
cat > .tmp/cst-alpine.yml << 'EOF'
128+
schemaVersion: "2.0.0"
129+
fileExistenceTests:
130+
- name: Busybox present
131+
path: /bin/sh
132+
shouldExist: true
133+
EOF
134+
109135
- name: Run container structure tests with JSON output
110136
if: ${{ inputs.mode == 'ref' }}
111137
id: cst
112138
uses: devops-infra/action-container-structure-test@v1
113139
with:
114140
image: alpine:3.23.4
115-
config: tests/docker/local-image.yml
141+
config: .tmp/cst-alpine.yml
116142
output: json
117143

118144
- name: Run container structure tests via docker image (preview)
@@ -144,13 +170,26 @@ jobs:
144170
- name: Pull Alpine test image
145171
run: docker pull alpine:3.23.4
146172

173+
- name: Prepare shared temp directory
174+
run: mkdir -p .tmp
175+
176+
- name: Create CST config
177+
run: |
178+
cat > .tmp/cst-alpine.yml << 'EOF'
179+
schemaVersion: "2.0.0"
180+
fileExistenceTests:
181+
- name: Busybox present
182+
path: /bin/sh
183+
shouldExist: true
184+
EOF
185+
147186
- name: Run container structure tests with JUnit output
148187
if: ${{ inputs.mode == 'ref' }}
149188
id: cst
150189
uses: devops-infra/action-container-structure-test@v1
151190
with:
152191
image: alpine:3.23.4
153-
config: tests/docker/local-image.yml
192+
config: .tmp/cst-alpine.yml
154193
output: junit
155194
junit_suite_name: e2e-alpine-tests
156195

@@ -183,15 +222,28 @@ jobs:
183222
- name: Pull Alpine test image
184223
run: docker pull alpine:3.23.4
185224

225+
- name: Prepare shared temp directory
226+
run: mkdir -p .tmp
227+
228+
- name: Create CST config
229+
run: |
230+
cat > .tmp/cst-alpine.yml << 'EOF'
231+
schemaVersion: "2.0.0"
232+
fileExistenceTests:
233+
- name: Busybox present
234+
path: /bin/sh
235+
shouldExist: true
236+
EOF
237+
186238
- name: Run container structure tests saving report to file
187239
if: ${{ inputs.mode == 'ref' }}
188240
id: cst
189241
uses: devops-infra/action-container-structure-test@v1
190242
with:
191243
image: alpine:3.23.4
192-
config: tests/docker/local-image.yml
244+
config: .tmp/cst-alpine.yml
193245
output: json
194-
test_report: /tmp/cst-report.json
246+
test_report: .tmp/cst-report.json
195247

196248
- name: Run container structure tests via docker image (preview)
197249
if: ${{ inputs.mode == 'image' }}
@@ -205,7 +257,7 @@ jobs:
205257
206258
- name: Verify report file was created
207259
if: ${{ inputs.mode == 'ref' }}
208-
run: test -f /tmp/cst-report.json
260+
run: test -f .tmp/cst-report.json
209261

210262
- name: Verify test result outputs
211263
if: ${{ inputs.mode == 'ref' }}
@@ -226,8 +278,26 @@ jobs:
226278
- name: Pull Alpine test image
227279
run: docker pull alpine:3.23.4
228280

229-
- name: Create secondary CST config
230-
run: cp tests/docker/local-image.yml tests/docker/local-image-secondary.yml
281+
- name: Prepare shared temp directory
282+
run: mkdir -p .tmp
283+
284+
- name: Create CST configs
285+
run: |
286+
cat > .tmp/cst-alpine.yml << 'EOF'
287+
schemaVersion: "2.0.0"
288+
fileExistenceTests:
289+
- name: Busybox present
290+
path: /bin/sh
291+
shouldExist: true
292+
EOF
293+
cat > .tmp/cst-alpine-secondary.yml << 'EOF'
294+
schemaVersion: "2.0.0"
295+
fileExistenceTests:
296+
- name: Busybox present
297+
path: /bin/sh
298+
shouldExist: true
299+
EOF
300+
231301
232302
- name: Run container structure tests with multiple config files
233303
if: ${{ inputs.mode == 'ref' }}
@@ -236,8 +306,8 @@ jobs:
236306
with:
237307
image: alpine:3.23.4
238308
config: |
239-
tests/docker/local-image.yml
240-
tests/docker/local-image-secondary.yml
309+
.tmp/cst-alpine.yml
310+
.tmp/cst-alpine-secondary.yml
241311
output: text
242312

243313
- name: Run container structure tests via docker image (preview)
@@ -271,9 +341,23 @@ jobs:
271341
- name: Pull Alpine test image
272342
run: docker pull alpine:3.23.4
273343

344+
- name: Prepare shared temp directory
345+
run: mkdir -p .tmp
346+
347+
- name: Create CST config
348+
run: |
349+
cat > .tmp/cst-alpine.yml << 'EOF'
350+
schemaVersion: "2.0.0"
351+
fileExistenceTests:
352+
- name: Echo hello
353+
command: echo
354+
args: ["hello"]
355+
expectedOutput: ["hello"]
356+
EOF
357+
274358
- name: Create metadata file
275359
run: |
276-
cat > /tmp/cst-metadata.json << 'EOF'
360+
cat > .tmp/cst-metadata.json << 'EOF'
277361
{
278362
"config": {
279363
"Env": ["FOO=bar"]
@@ -287,11 +371,11 @@ jobs:
287371
uses: devops-infra/action-container-structure-test@v1
288372
with:
289373
image: alpine:3.23.4
290-
config: tests/docker/local-image.yml
374+
config: .tmp/cst-alpine.yml
291375
driver: docker
292376
platform: linux/amd64
293377
runtime: runc
294-
metadata: /tmp/cst-metadata.json
378+
metadata: .tmp/cst-metadata.json
295379
output: text
296380

297381
- name: Run container structure tests via docker image (preview)

0 commit comments

Comments
 (0)