Files

28 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
run_id="veyra-ci-$(date +%s)-${RANDOM}"
network="$run_id"
postgres="$run_id-postgres"
cleanup() {
docker rm -f "$postgres" >/dev/null 2>&1 || true
docker network rm "$network" >/dev/null 2>&1 || true
docker image rm "veyra-mobile-check:$run_id" "veyra-test:$run_id" >/dev/null 2>&1 || true
}
trap cleanup EXIT
docker build --target mobile-check -t "veyra-mobile-check:$run_id" .
docker build --target test -t "veyra-test:$run_id" .
docker run --rm --entrypoint python3 "veyra-test:$run_id" /src/deploy/tests/test_release.py
docker network create "$network" >/dev/null
docker run -d --name "$postgres" --network "$network" --network-alias postgres \
-e POSTGRES_USER=veyra_test -e POSTGRES_PASSWORD=test_only -e POSTGRES_DB=veyra_test postgres:17 >/dev/null
ready=false
for ((i=0; i<60; i++)); do
if docker exec "$postgres" pg_isready -U veyra_test -d veyra_test >/dev/null 2>&1; then ready=true; break; fi
sleep 1
done
if [[ "$ready" != true ]]; then echo 'CI PostgreSQL did not become ready' >&2; exit 1; fi
docker run --rm --network "$network" \
-v veyra-go-test-cache:/root/.cache/go-build \
-e VEYRA_TEST_DATABASE_URL='postgres://veyra_test:test_only@postgres:5432/veyra_test?sslmode=disable' \
"veyra-test:$run_id"