test: make test cases unique and test de-duplication
This commit is contained in:
@@ -49,13 +49,16 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
images="${{ steps.giff.outputs.images }}"
|
images="${{ steps.giff.outputs.images }}"
|
||||||
echo "Extracted: $images"
|
echo "Extracted: $images"
|
||||||
# Registry with tag
|
# Dockerfile-only: registry with tag, registry with digest
|
||||||
echo "$images" | grep -q 'example.com/library/nginx:latest'
|
echo "$images" | grep -q 'example.com/library/nginx:v1'
|
||||||
echo "$images" | grep -q 'example.com/library/redis:7-alpine'
|
echo "$images" | grep -q 'example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||||
echo "$images" | grep -q 'example.com/library/app:1.25-alpine'
|
# K8s-only: registry with tag, registry with digest
|
||||||
# Registry path with tag
|
echo "$images" | grep -q 'example.com/library/app:v2'
|
||||||
|
echo "$images" | grep -q 'example.com/myproject/helper@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
||||||
|
# Shared ref (in both Dockerfile and K8s) — must appear exactly once
|
||||||
echo "$images" | grep -q 'example.com/distroless/static:nonroot'
|
echo "$images" | grep -q 'example.com/distroless/static:nonroot'
|
||||||
# Registry with digest
|
count=$(echo "$images" | tr ',' '\n' | grep -c 'example.com/distroless/static:nonroot' || true)
|
||||||
echo "$images" | grep -q 'example.com/distroless/static@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd'
|
[ "$count" -eq 1 ] || { echo "expected shared ref once, got: $count"; exit 1; }
|
||||||
echo "$images" | grep -q 'example.com/library/alpine@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
|
# Total unique refs: 5
|
||||||
echo "$images" | grep -q 'example.com/myproject/myimg@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd'
|
total=$(echo "$images" | tr ',' '\n' | grep -c . || true)
|
||||||
|
[ "$total" -eq 5 ] || { echo "expected 5 unique refs, got: $total"; exit 1; }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Used by CI to test get-images-from-files action (K8s manifest, registry refs only)
|
# Used by CI to test get-images-from-files action (K8s, distinct from Dockerfile)
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@@ -9,12 +9,11 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: app
|
- name: app
|
||||||
image: example.com/library/app:1.25-alpine
|
# Registry with tag (K8s)
|
||||||
- name: sidecar
|
image: example.com/library/app:v2
|
||||||
image: example.com/library/redis:7-alpine
|
- name: shared
|
||||||
- name: distroless
|
# Same ref as in test.Dockerfile — tests deduplication
|
||||||
image: example.com/distroless/static:nonroot
|
image: example.com/distroless/static:nonroot
|
||||||
- name: by-digest
|
- name: by-digest
|
||||||
image: example.com/library/alpine@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
|
# Registry with digest (K8s)
|
||||||
- name: fqdn-digest
|
image: example.com/myproject/helper@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||||
image: example.com/myproject/myimg@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
# Used by CI to test get-images-from-files action (varied image formats, registry refs only)
|
# Used by CI to test get-images-from-files action (registry refs only, distinct from K8s)
|
||||||
# Short repo:tag (ignored by design; only registry refs are extracted)
|
# Registry with tag (Dockerfile)
|
||||||
FROM nginx:3.19
|
FROM example.com/library/nginx:v1
|
||||||
# Fully qualified with host and tag
|
# Registry path with tag — shared with K8s to test deduplication
|
||||||
FROM example.com/library/nginx:latest
|
|
||||||
# Registry path with tag
|
|
||||||
FROM example.com/distroless/static:nonroot
|
FROM example.com/distroless/static:nonroot
|
||||||
# With digest only but no registry (ignored)
|
# Registry with digest (Dockerfile)
|
||||||
|
FROM example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
|
||||||
|
# Ignored tags
|
||||||
|
## Short repo:tag (ignored by design; only registry refs are extracted)
|
||||||
|
FROM nginx:3.19
|
||||||
|
## With digest only but no registry (ignored)
|
||||||
FROM nginx@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
|
FROM nginx@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
|
||||||
# Fully qualified with digest
|
|
||||||
FROM example.com/distroless/static@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd
|
|
||||||
|
|||||||
Reference in New Issue
Block a user