Files
asciinema-deployment/test.sh
T
feedc0de 9fd543ddcb
Validate and deploy asciinema / Validate manifests (push) Successful in 13s
Validate and deploy asciinema / Deploy to Kubernetes (push) Successful in 1m6s
Fix asciinema S3 deployment
2026-10-04 17:17:46 +02:00

76 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
project_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
bash -n "${project_dir}/install.sh"
bash -n "${project_dir}/create-ci-kubeconfig.sh"
bash -n "${project_dir}/test.sh"
image=$(sed -n 's|^[[:space:]]*image: \(ghcr.io/asciinema/asciinema-server[^[:space:]]*\)$|\1|p' \
"${project_dir}/asciinema.yaml")
if [[ -z "${image}" || "${image}" == *:latest || "${image}" != *@sha256:* ]]; then
echo "The asciinema server image must use a non-latest tag pinned by digest." >&2
exit 1
fi
postgres_image=$(sed -n 's|^[[:space:]]*image: \(postgres:[^[:space:]]*\)$|\1|p' \
"${project_dir}/infrastructure.yaml")
if [[ -z "${postgres_image}" || "${postgres_image}" == *:latest || "${postgres_image}" != *@sha256:* ]]; then
echo "The PostgreSQL image must use a non-latest tag pinned by digest." >&2
exit 1
fi
if ! grep -Fq 'storageClassName: rook-ceph-block-ec' "${project_dir}/infrastructure.yaml"; then
echo "The dedicated PostgreSQL claim must use retained Ceph block storage." >&2
exit 1
fi
if grep -Eqi 'redis|valkey' \
"${project_dir}/asciinema.yaml" "${project_dir}/bootstrap.yaml"; then
echo "asciinema should not use Redis/Valkey." >&2
exit 1
fi
if grep -Eq 'S3_PUBLIC_ENDPOINT|SplitEndpointS3|asciinema-custom-config' \
"${project_dir}/asciinema.yaml"; then
echo "asciinema must use the cluster-local RGW endpoint for server-side reads." >&2
exit 1
fi
if ! grep -Fq 'S3_ENDPOINT: http://rook-ceph-rgw-my-store.rook-ceph.svc.cluster.local' \
"${project_dir}/asciinema.yaml"; then
echo "asciinema must use the cluster-local RGW Service." >&2
exit 1
fi
validate_file() {
local manifest=$1
shift
if command -v kubeconform >/dev/null 2>&1; then
kubeconform -strict -summary "$@" "${manifest}"
elif command -v docker >/dev/null 2>&1; then
docker run --rm --interactive \
ghcr.io/yannh/kubeconform:v0.7.0@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c \
-strict -summary "$@" < "${manifest}"
elif command -v podman >/dev/null 2>&1; then
podman run --rm --interactive \
ghcr.io/yannh/kubeconform:v0.7.0@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c \
-strict -summary "$@" < "${manifest}"
else
echo "Required command not found: install kubeconform, Docker, or Podman" >&2
exit 1
fi
}
validate_file "${project_dir}/asciinema.yaml"
validate_file "${project_dir}/bootstrap.yaml"
validate_file "${project_dir}/infrastructure.yaml"
validate_file "${project_dir}/namespace.yaml"
validate_file "${project_dir}/ceph-object-user.yaml" -ignore-missing-schemas
validate_file "${project_dir}/ci-deployer.yaml"
echo "asciinema scripts and Kubernetes resources are valid for ${image}."