fix(ci): add Redis service to test and build jobs to resolve connection refused errors
This commit is contained in:
@@ -52,6 +52,17 @@ jobs:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
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
|
needs: lint
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -73,11 +84,35 @@ jobs:
|
|||||||
- name: Download Go modules
|
- name: Download Go modules
|
||||||
run: go mod download
|
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
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
REDIS_ADDR: localhost:6379
|
||||||
run: go test ./... -v -race -cover
|
run: go test ./... -v -race -cover
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
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
|
needs: test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -99,7 +134,21 @@ jobs:
|
|||||||
- name: Download Go modules
|
- name: Download Go modules
|
||||||
run: go mod download
|
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
|
- name: Build binary
|
||||||
|
env:
|
||||||
|
REDIS_ADDR: localhost:6379
|
||||||
run: go build -o api ./cmd/api
|
run: go build -o api ./cmd/api
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
@@ -132,4 +181,3 @@ jobs:
|
|||||||
gitea.mrixs.me/mrixs/trip-planner:${{ github.sha }}
|
gitea.mrixs.me/mrixs/trip-planner:${{ github.sha }}
|
||||||
cache-from: type=registry,ref=gitea.mrixs.me/mrixs/trip-planner:buildcache
|
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
|
cache-to: type=registry,ref=gitea.mrixs.me/mrixs/trip-planner:buildcache,mode=max
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user