File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1212jobs :
1313 test-backend :
1414 runs-on : ubuntu-latest
15+ env :
16+ POSTGRES_USER : postgres
17+ POSTGRES_PASSWORD : changethis
18+ POSTGRES_DB : app
1519 steps :
1620 - name : Checkout
1721 uses : actions/checkout@v6
@@ -25,13 +29,29 @@ jobs:
2529 version : " 0.4.15"
2630 enable-cache : true
2731 - run : docker compose down -v --remove-orphans
28- - run : docker compose up -d db mailcatcher
32+ - name : Build DB image
33+ run : docker compose build --pull --no-cache db
34+ - name : Start DB and mailcatcher
35+ run : docker compose up -d db mailcatcher
36+ - name : Wait for DB to be ready
37+ run : |
38+ echo "Waiting for PostgreSQL to accept connections..."
39+ for i in $(seq 1 60); do
40+ docker compose exec db pg_isready -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" >/dev/null 2>&1 && { echo "DB ready"; exit 0; }
41+ sleep 2
42+ done
43+ echo "DB did not become ready in time, printing logs:"
44+ docker compose logs --no-color db || true
45+ exit 1
2946 - name : Migrate DB
3047 run : docker compose run --rm prestart
3148 - name : Run tests
3249 run : uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
3350 working-directory : backend
3451 - run : docker compose down -v --remove-orphans
52+ - name : Print DB logs on failure
53+ if : failure()
54+ run : docker compose logs --no-color db || true
3555 - name : Store coverage files
3656 uses : actions/upload-artifact@v5
3757 with :
You can’t perform that action at this time.
0 commit comments