From 6396f4e6abce833e6ce8587a6edab0f73604f5c8 Mon Sep 17 00:00:00 2001 From: Vladimir Zagainov Date: Thu, 20 Aug 2026 17:40:37 +0300 Subject: [PATCH] fix(ci): add Redis service to test and build jobs to resolve connection refused errors --- .gitea/workflows/deploy.yml | 50 ++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 18a31ef..e50e340 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -52,6 +52,17 @@ jobs: test: runs-on: ubuntu-latest + services: + redis: + image: redis:7-alpine + ports: + - 6379:6379 + # Set health checks to wait until redis is ready + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 needs: lint steps: - uses: actions/checkout@v4 @@ -73,11 +84,35 @@ jobs: - name: Download Go modules run: go mod download + - name: Set up Redis + run: | + # Wait for Redis to be ready + for i in {1..30}; do + if redis-cli ping | grep -q PONG; then + echo "Redis is ready" + break + fi + echo "Waiting for Redis..." + sleep 1 + done + - name: Run tests + env: + REDIS_ADDR: localhost:6379 run: go test ./... -v -race -cover build: runs-on: ubuntu-latest + services: + redis: + image: redis:7-alpine + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 needs: test steps: - uses: actions/checkout@v4 @@ -99,7 +134,21 @@ jobs: - name: Download Go modules run: go mod download + - name: Set up Redis + run: | + # Wait for Redis to be ready + for i in {1..30}; do + if redis-cli ping | grep -q PONG; then + echo "Redis is ready" + break + fi + echo "Waiting for Redis..." + sleep 1 + done + - name: Build binary + env: + REDIS_ADDR: localhost:6379 run: go build -o api ./cmd/api docker: @@ -132,4 +181,3 @@ jobs: gitea.mrixs.me/mrixs/trip-planner:${{ github.sha }} cache-from: type=registry,ref=gitea.mrixs.me/mrixs/trip-planner:buildcache cache-to: type=registry,ref=gitea.mrixs.me/mrixs/trip-planner:buildcache,mode=max -