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_USER: turash
|
||||||
POSTGRES_PASSWORD: turash123
|
POSTGRES_PASSWORD: turash123
|
||||||
POSTGRES_DB: postgres
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd pg_isready
|
--health-cmd "pg_isready -U turash"
|
||||||
--health-interval 10s
|
--health-interval 10s
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_HOST: localhost
|
POSTGRES_HOST: localhost
|
||||||
POSTGRES_PORT: 5432
|
POSTGRES_PORT: 5432
|
||||||
@ -194,24 +194,32 @@ jobs:
|
|||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
GOPROXY: https://proxy.golang.org,direct
|
GOPROXY: https://proxy.golang.org,direct
|
||||||
GOSUMDB: sum.golang.org
|
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
|
- name: Wait for PostgreSQL to be ready
|
||||||
run: |
|
run: |
|
||||||
echo "Waiting for PostgreSQL to be ready..."
|
echo "Waiting for PostgreSQL to be ready..."
|
||||||
for i in {1..30}; do
|
# Use bash built-in TCP check (works without external tools)
|
||||||
if pg_isready -h localhost -p 5432 -U turash 2>/dev/null || nc -z localhost 5432 2>/dev/null; then
|
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!"
|
echo "PostgreSQL is ready!"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
sleep 2
|
||||||
done
|
done
|
||||||
echo "PostgreSQL did not become ready in time"
|
echo "⚠ PostgreSQL did not become ready in time"
|
||||||
exit 1
|
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
|
continue-on-error: true
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: bugulma/backend
|
working-directory: bugulma/backend
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user