-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (126 loc) · 4.67 KB
/
stacks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Deployment Stacks
on:
pull_request:
paths:
- 'deploy/**'
jobs:
deploy-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install UV
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
bun install
uv venv
. .venv/bin/activate
- name: Setup config
run: |
cp config.example.yaml config.yaml
bun run build:config
- name: Create Docker network
run: docker network create eda-network || true
- name: Find and process deploy directories
run: |
# Create dirs file
touch $GITHUB_WORKSPACE/deploy_dirs.txt
for dir in deploy/*/; do
if [ -d "$dir" ]; then
echo "Processing $dir"
cd "$dir"
# Generate env from config
bun run export-config.ts > .env
# Start containers
docker compose up -d
# Store directory
echo "${dir%/}" >> $GITHUB_WORKSPACE/deploy_dirs.txt
# Wait for containers to be fully up
echo "Waiting for containers to initialize..."
sleep 15
# Check if all containers are healthy
docker compose ps --format "{{.Name}} {{.Status}}" | while read -r line; do
if [[ ! $line =~ "(healthy)" ]] && [[ ! $line =~ "Up" ]]; then
echo "Container not healthy: $line"
docker compose logs
exit 1
fi
done
cd $GITHUB_WORKSPACE
fi
done
- name: Test endpoints
run: |
while IFS= read -r dir; do
service_name=$(basename "$dir" | sed 's/-stack//')
echo "=== Testing endpoints for service: $service_name ==="
# Show container status
echo "Docker container status:"
docker ps -a | grep $service_name || true
# Show container logs
echo "Container logs:"
docker logs $service_name 2>&1 || true
# Skip config packages
if [[ "$service_name" == "config" ]]; then
echo "Skipping config package: $service_name"
continue
fi
# Get and verify port
port=$(bun run -b --bun ./tooling/scripts/get-port.ts ${service_name})
echo "Retrieved port: $port"
if [ -z "$port" ]; then
echo "No port found for $service_name in config, skipping..."
continue
fi
# Network connectivity check
echo "Testing network connectivity:"
nc -zv localhost $port 2>&1 || true
test_url="http://localhost:${port}/"
echo "Testing URL: $test_url"
# More verbose curl
curl -v --fail --retry 5 --retry-delay 10 --retry-connrefused "$test_url" || {
echo "=== Error Details ==="
echo "Failed to reach $test_url for $service_name"
echo "Container status:"
docker ps -a | grep $service_name || true
echo "Latest logs:"
docker logs --tail 50 ${service_name} 2>&1 || true
echo "Network status:"
netstat -tulpn | grep $port || true
exit 1
}
echo "=== Test completed for $service_name ==="
done < $GITHUB_WORKSPACE/deploy_dirs.txt
- name: Check service health
run: |
while IFS= read -r dir; do
service_name=$(basename "$dir" | sed 's/-stack//')
echo "Checking health for $service_name..."
# Get port from config
port=$(bun run -b --bun ./tooling/scripts/get-port.ts ${service_name})
# Skip if no port found
if [ -z "$port" ]; then
echo "No port configured for $service_name, skipping..."
continue
fi
# Wait for port to be available
timeout 60 bash -c "until nc -z localhost $port; do sleep 2; done" || {
echo "Service $service_name not ready on port $port"
docker logs ${service_name} || true
exit 1
}
done < $GITHUB_WORKSPACE/deploy_dirs.txt
- name: Cleanup
if: always()
run: |
if [ -f "$GITHUB_WORKSPACE/deploy_dirs.txt" ]; then
while IFS= read -r dir; do
cd "$dir"
docker compose down
cd $GITHUB_WORKSPACE
done < $GITHUB_WORKSPACE/deploy_dirs.txt
fi