mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Refactor CI workflow to manage PostgreSQL service with Docker
Some checks failed
CI/CD Pipeline / backend-lint (push) Failing after 27s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-lint (push) Successful in 1m37s
CI/CD Pipeline / frontend-build (push) Failing after 35s
CI/CD Pipeline / e2e-test (push) Has been skipped
Some checks failed
CI/CD Pipeline / backend-lint (push) Failing after 27s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-lint (push) Successful in 1m37s
CI/CD Pipeline / frontend-build (push) Failing after 35s
CI/CD Pipeline / e2e-test (push) Has been skipped
- Remove inline PostgreSQL service configuration and replace it with a Docker run command for better control - Implement a more robust readiness check for PostgreSQL using Docker commands - Enhance output messages for clarity during the PostgreSQL startup process
This commit is contained in:
parent
df2ce48c9e
commit
10219a966a
@ -74,20 +74,6 @@ jobs:
|
|||||||
|
|
||||||
backend-lint:
|
backend-lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgis/postgis:16-3.4
|
|
||||||
env:
|
|
||||||
POSTGRES_USER: turash
|
|
||||||
POSTGRES_PASSWORD: turash123
|
|
||||||
POSTGRES_DB: postgres
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
options: >-
|
|
||||||
--health-cmd "pg_isready -U turash"
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_HOST: localhost
|
POSTGRES_HOST: localhost
|
||||||
POSTGRES_PORT: 5432
|
POSTGRES_PORT: 5432
|
||||||
@ -96,6 +82,38 @@ jobs:
|
|||||||
POSTGRES_DB: postgres
|
POSTGRES_DB: postgres
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
- name: Start PostgreSQL with PostGIS
|
||||||
|
run: |
|
||||||
|
# Stop any existing PostgreSQL containers
|
||||||
|
docker stop postgres-test 2>/dev/null || true
|
||||||
|
docker rm postgres-test 2>/dev/null || true
|
||||||
|
|
||||||
|
# Start PostgreSQL with PostGIS
|
||||||
|
docker run -d \
|
||||||
|
--name postgres-test \
|
||||||
|
-e POSTGRES_USER=turash \
|
||||||
|
-e POSTGRES_PASSWORD=turash123 \
|
||||||
|
-e POSTGRES_DB=postgres \
|
||||||
|
-p 5432:5432 \
|
||||||
|
postgis/postgis:16-3.4
|
||||||
|
|
||||||
|
echo "PostgreSQL container started, waiting for it to be ready..."
|
||||||
|
# Wait for PostgreSQL to be ready
|
||||||
|
for i in {1..60}; do
|
||||||
|
if docker exec postgres-test pg_isready -U turash >/dev/null 2>&1; then
|
||||||
|
echo "✓ PostgreSQL is ready!"
|
||||||
|
# Grant CREATEDB privilege (required for pgtestdb)
|
||||||
|
docker exec postgres-test psql -U turash -d postgres -c "ALTER USER turash CREATEDB;" 2>/dev/null || true
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Waiting for PostgreSQL... (attempt $i/60)"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✗ PostgreSQL failed to start in time"
|
||||||
|
echo "Container logs:"
|
||||||
|
docker logs postgres-test || true
|
||||||
|
exit 1
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
@ -194,33 +212,6 @@ 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: Wait for PostgreSQL to be ready
|
|
||||||
run: |
|
|
||||||
echo "Waiting for PostgreSQL to be ready..."
|
|
||||||
# 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
|
|
||||||
# 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"
|
|
||||||
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
|
- name: Test
|
||||||
working-directory: bugulma/backend
|
working-directory: bugulma/backend
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user