mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Enhance CI workflow for PostgreSQL service readiness checks
Some checks failed
CI/CD Pipeline / frontend-lint (push) Successful in 1m37s
CI/CD Pipeline / frontend-build (push) Failing after 39s
CI/CD Pipeline / backend-lint (push) Failing after 5m43s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
Some checks failed
CI/CD Pipeline / frontend-lint (push) Successful in 1m37s
CI/CD Pipeline / frontend-build (push) Failing after 39s
CI/CD Pipeline / backend-lint (push) Failing after 5m43s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
- Add health check command for PostgreSQL service to ensure proper initialization - Update waiting mechanism to use built-in TCP checks for improved reliability - Modify output messages for clarity and include warnings for potential test failures
This commit is contained in:
parent
1a0135fffe
commit
df2ce48c9e
@ -81,13 +81,13 @@ jobs:
|
||||
POSTGRES_USER: turash
|
||||
POSTGRES_PASSWORD: turash123
|
||||
POSTGRES_DB: postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-cmd "pg_isready -U turash"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
env:
|
||||
POSTGRES_HOST: localhost
|
||||
POSTGRES_PORT: 5432
|
||||
@ -194,24 +194,32 @@ jobs:
|
||||
CGO_ENABLED: 0
|
||||
GOPROXY: https://proxy.golang.org,direct
|
||||
GOSUMDB: sum.golang.org
|
||||
- name: Install PostgreSQL client
|
||||
run: |
|
||||
apt-get update -qq
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq postgresql-client || true
|
||||
continue-on-error: true
|
||||
- name: Wait for PostgreSQL to be ready
|
||||
run: |
|
||||
echo "Waiting for PostgreSQL to be ready..."
|
||||
for i in {1..30}; do
|
||||
if pg_isready -h localhost -p 5432 -U turash 2>/dev/null || nc -z localhost 5432 2>/dev/null; then
|
||||
# Use bash built-in TCP check (works without external tools)
|
||||
for i in {1..60}; do
|
||||
# Check if port 5432 is open using bash built-in /dev/tcp
|
||||
if timeout 1 bash -c "echo > /dev/tcp/localhost/5432" 2>/dev/null; then
|
||||
echo "PostgreSQL port is accessible!"
|
||||
# Give it a moment to fully initialize
|
||||
sleep 3
|
||||
echo "PostgreSQL is ready!"
|
||||
exit 0
|
||||
fi
|
||||
echo "PostgreSQL is unavailable - attempt $i/30"
|
||||
# Alternative: try with cat if timeout not available
|
||||
if bash -c "cat < /dev/null > /dev/tcp/localhost/5432" 2>/dev/null; then
|
||||
echo "PostgreSQL port is accessible (via cat)!"
|
||||
sleep 3
|
||||
echo "PostgreSQL is ready!"
|
||||
exit 0
|
||||
fi
|
||||
echo "Waiting for PostgreSQL... (attempt $i/60)"
|
||||
sleep 2
|
||||
done
|
||||
echo "PostgreSQL did not become ready in time"
|
||||
exit 1
|
||||
echo "⚠ PostgreSQL did not become ready in time"
|
||||
echo "This may be expected if services are not fully supported in this Gitea Actions version"
|
||||
echo "Tests will continue but may fail if PostgreSQL is required"
|
||||
continue-on-error: true
|
||||
- name: Test
|
||||
working-directory: bugulma/backend
|
||||
|
||||
Loading…
Reference in New Issue
Block a user