mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
chore: refactor E2E tests workflow to start Postgres as a container and add readiness check
This commit is contained in:
parent
288c18bdf7
commit
548e574f1a
1 changed files with 35 additions and 16 deletions
51
.github/workflows/e2e-tests.yml
vendored
51
.github/workflows/e2e-tests.yml
vendored
|
|
@ -21,20 +21,9 @@ jobs:
|
||||||
if: github.event.pull_request.draft == false
|
if: github.event.pull_request.draft == false
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
|
|
||||||
|
# Postgres runs as a step (not a service) so we can pass `-c wal_level=logical`,
|
||||||
|
# required for migration 117's zero-cache publications.
|
||||||
services:
|
services:
|
||||||
postgres:
|
|
||||||
image: pgvector/pgvector:pg17
|
|
||||||
env:
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
POSTGRES_DB: surfsense_e2e
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
options: >-
|
|
||||||
--health-cmd "pg_isready -U postgres -d surfsense_e2e"
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:8-alpine
|
image: redis:8-alpine
|
||||||
ports:
|
ports:
|
||||||
|
|
@ -81,6 +70,21 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
# Started early so it warms up while Python deps install.
|
||||||
|
- name: Start Postgres
|
||||||
|
run: |
|
||||||
|
docker run -d \
|
||||||
|
--name surfsense_postgres \
|
||||||
|
-p 5432:5432 \
|
||||||
|
-e POSTGRES_USER=postgres \
|
||||||
|
-e POSTGRES_PASSWORD=postgres \
|
||||||
|
-e POSTGRES_DB=surfsense_e2e \
|
||||||
|
pgvector/pgvector:pg17 \
|
||||||
|
postgres \
|
||||||
|
-c wal_level=logical \
|
||||||
|
-c max_wal_senders=10 \
|
||||||
|
-c max_replication_slots=10
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
|
|
@ -109,6 +113,19 @@ jobs:
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
run: uv sync
|
run: uv sync
|
||||||
|
|
||||||
|
- name: Wait for Postgres readiness
|
||||||
|
run: |
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if docker exec surfsense_postgres pg_isready -U postgres -d surfsense_e2e > /dev/null 2>&1; then
|
||||||
|
echo "Postgres ready after ${i} attempts"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "::error::Postgres failed to become ready within 60s"
|
||||||
|
docker logs surfsense_postgres --tail 100
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Run database migrations
|
- name: Run database migrations
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
run: uv run alembic upgrade head
|
run: uv run alembic upgrade head
|
||||||
|
|
@ -127,9 +144,7 @@ jobs:
|
||||||
> backend.log 2>&1 &
|
> backend.log 2>&1 &
|
||||||
echo $! > backend.pid
|
echo $! > backend.pid
|
||||||
|
|
||||||
# Worker runs in a separate interpreter, so the hijack must be
|
# Worker is a separate interpreter, so the composio hijack must be reapplied.
|
||||||
# reapplied here. Without it, indexing tasks queue but never run.
|
|
||||||
# Same proxy-scoping rationale as the backend step above.
|
|
||||||
- name: Start Celery worker (E2E entrypoint)
|
- name: Start Celery worker (E2E entrypoint)
|
||||||
working-directory: surfsense_backend
|
working-directory: surfsense_backend
|
||||||
env:
|
env:
|
||||||
|
|
@ -270,3 +285,7 @@ jobs:
|
||||||
kill "$(cat $f)" 2>/dev/null || true
|
kill "$(cat $f)" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
- name: Stop Postgres
|
||||||
|
if: always()
|
||||||
|
run: docker rm -f surfsense_postgres 2>/dev/null || true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue