fix: gen-migrations workflow
Some checks failed
gen-migrations / gen-migrations (push) Failing after 7s

This commit is contained in:
Orion Kindel 2023-07-20 00:35:54 -05:00
parent 7613dc8749
commit 3a14f001f6
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719
3 changed files with 10 additions and 8 deletions

View File

@ -8,6 +8,11 @@ services:
env_file: ['./.env.schema'] env_file: ['./.env.schema']
volumes: ['/var/run/postgresql:/var/run/postgresql'] volumes: ['/var/run/postgresql:/var/run/postgresql']
command: '-p 5432' command: '-p 5432'
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s
timeout: 5s
retries: 5
head: head:
container_name: 'head' container_name: 'head'
network_mode: 'host' network_mode: 'host'
@ -16,3 +21,8 @@ services:
env_file: ['./.env.schema'] env_file: ['./.env.schema']
volumes: ['/var/run/postgresql:/var/run/postgresql'] volumes: ['/var/run/postgresql:/var/run/postgresql']
command: '-p 5433' command: '-p 5433'
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s
timeout: 5s
retries: 5

View File

@ -18,10 +18,6 @@ db() {
echo -n "postgresql:///$1?port=$port&user=$POSTGRES_USER&password=$POSTGRES_PASSWORD" echo -n "postgresql:///$1?port=$port&user=$POSTGRES_USER&password=$POSTGRES_PASSWORD"
} }
isready() {
until psql $(db postgres) -c "select 1" &>/dev/null; do true; done;
}
initdb() { initdb() {
dropdb=$(mktemp) dropdb=$(mktemp)
echo "drop database dnim with (force);" > "$dropdb" echo "drop database dnim with (force);" > "$dropdb"
@ -31,7 +27,6 @@ initdb() {
if [[ "$rev" = "empty" ]]; then if [[ "$rev" = "empty" ]]; then
docker compose up -d "$base_or_head" docker compose up -d "$base_or_head"
isready
initdb initdb
exit 0 exit 0
fi fi
@ -46,6 +41,5 @@ cp .env.schema "./$base_or_head/.env.schema"
cd "./$base_or_head" cd "./$base_or_head"
docker compose up -d "$base_or_head" docker compose up -d "$base_or_head"
isready
initdb || (docker compose logs "$base_or_head" && exit 1) initdb || (docker compose logs "$base_or_head" && exit 1)
ls ./schema/ | xargs -I{} bash -c "set -e; $(declare -f query_file); query_file \"$(db dnim)\" ./schema/{}" || (docker compose logs "$base_or_head" && exit 1) ls ./schema/ | xargs -I{} bash -c "set -e; $(declare -f query_file); query_file \"$(db dnim)\" ./schema/{}" || (docker compose logs "$base_or_head" && exit 1)

View File

@ -28,8 +28,6 @@ if [[ ! -f "$migration" ]]; then
./scripts/build.sh base "$base" 1>&2 || (echo "base failed to build" && exit 1) ./scripts/build.sh base "$base" 1>&2 || (echo "base failed to build" && exit 1)
./scripts/build.sh head "$head" 1>&2 || (echo "head failed to build" && exit 1) ./scripts/build.sh head "$head" 1>&2 || (echo "head failed to build" && exit 1)
until pg_isready -p 5432 1>/dev/null && pg_isready -p 5433 1>/dev/null; do true; done;
migra --unsafe "$(db 5432)" "$(db 5433)" || echo "migra exited with code $?. this is /probably/ fine" 1>&2 migra --unsafe "$(db 5432)" "$(db 5433)" || echo "migra exited with code $?. this is /probably/ fine" 1>&2
else else
cat "$migration" cat "$migration"