style: make ci test more expressive
CI / Test Setup Trivy amd64 (pull_request) Successful in 9s
CI / Test Setup DB (pull_request) Successful in 15s
CI / Test Get Images From Files (pull_request) Successful in 47s
CI / Test Setup Trivy arm64 (pull_request) Successful in 1m4s

This commit is contained in:
2026-02-05 14:45:44 +01:00
parent a30bdc5e8e
commit b41c75e76f
+20 -11
View File
@@ -48,16 +48,25 @@ jobs:
run: |
images="${{ steps.giff.outputs.images }}"
echo "Extracted: $images"
# Dockerfile-only: registry with tag, registry with digest
echo "$images" | grep -q 'example.com/library/nginx:v1'
echo "$images" | grep -q 'example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
# K8s-only: registry with tag, registry with digest
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 ""
check() { echo -n " $1: "; echo "$images" | grep -q "$2" && echo "OK" || { echo "FAIL (not found)"; exit 1; }; }
# Dockerfile-only refs
check "Dockerfile registry+tag (nginx:v1)" "example.com/library/nginx:v1"
check "Dockerfile registry+digest (base@sha256:...)" "example.com/library/base@sha256:aaaaaaaa"
# K8s-only refs
check "K8s registry+tag (app:v2)" "example.com/library/app:v2"
check "K8s registry+digest (helper@sha256:...)" "example.com/myproject/helper@sha256:bbbbbbbb"
# Shared ref (in both files) — must appear exactly once
check "Shared ref present (distroless/static:nonroot)" "example.com/distroless/static:nonroot"
count=$(echo "$images" | tr ',' '\n' | grep -c 'example.com/distroless/static:nonroot' || true)
[ "$count" -eq 1 ] || { echo "expected shared ref once, got: $count"; exit 1; }
# Total unique refs: 5
echo -n " Shared ref appears once (no duplicates): "
[ "$count" -eq 1 ] && echo "OK (count=$count)" || { echo "FAIL (count=$count, expected 1)"; exit 1; }
total=$(echo "$images" | tr ',' '\n' | grep -c . || true)
[ "$total" -eq 5 ] || { echo "expected 5 unique refs, got: $total"; exit 1; }
echo -n " Total unique refs: "
[ "$total" -eq 5 ] && echo "OK ($total)" || { echo "FAIL (got $total, expected 5)"; exit 1; }
echo ""
echo "All checks passed."