2 Commits
v1.5 ... v1.7

View File

@@ -101,7 +101,7 @@ jobs:
POSTGRES_PASSWORD: ${{ inputs.postgres_password }}
POSTGRES_DB: ${{ inputs.postgres_db }}
ports:
- 5432:5432
- 5432
options: >-
--health-cmd="${{ inputs.postgres_health_cmd }}"
--health-interval=${{ inputs.postgres_health_interval }}
@@ -123,6 +123,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Configure DB env
run: |
if [ "${ACT:-}" = "true" ] || [ "${GITEA_ACTIONS:-}" = "true" ]; then
host="postgres"
port="5432"
else
host="127.0.0.1"
port="${{ job.services.postgres.ports['5432'] }}"
fi
echo "POSTGRES_HOST=$host" >> "$GITHUB_ENV"
echo "POSTGRES_PORT=$port" >> "$GITHUB_ENV"
echo "POSTGRES_USER=${{ inputs.postgres_user }}" >> "$GITHUB_ENV"
echo "POSTGRES_PASSWORD=${{ inputs.postgres_password }}" >> "$GITHUB_ENV"
echo "POSTGRES_DB=${{ inputs.postgres_db }}" >> "$GITHUB_ENV"
echo "DATABASE_URL=postgres://${{ inputs.postgres_user }}:${{ inputs.postgres_password }}@$host:$port/${{ inputs.postgres_db }}" >> "$GITHUB_ENV"
- name: Load env vars
if: ${{ inputs.env != '' }}
run: |
@@ -189,6 +205,28 @@ jobs:
echo "$line" >> "$GITHUB_ENV"
done <<< "${{ inputs.test_env }}"
- name: Wait for postgres
run: |
python - <<'PY'
import os
import socket
import time
host = os.getenv("POSTGRES_HOST", "127.0.0.1")
port = int(os.getenv("POSTGRES_PORT", "5432"))
deadline = time.time() + 60
while True:
try:
with socket.create_connection((host, port), timeout=2):
print(f"Postgres reachable at {host}:{port}")
break
except OSError:
if time.time() > deadline:
raise
time.sleep(1)
PY
- name: Run format check
if: ${{ inputs.format_command != '' }}
run: ${{ inputs.format_command }}