1
+ name : Validate Homebridge Docker Container
2
+ run-name : Validate Homebridge Docker Container - ${{ github.event.inputs.release_tag }} Release
3
+
4
+ on :
5
+ workflow_call :
6
+ inputs :
7
+ release_tag :
8
+ description : ' Release tag to validate (alpha, beta, or latest)'
9
+ required : true
10
+ type : string
11
+ default : latest
12
+
13
+ workflow_dispatch :
14
+ inputs :
15
+ release_tag :
16
+ description : ' Release tag to validate (alpha, beta, or latest)'
17
+ required : true
18
+ type : choice
19
+ options :
20
+ - alpha
21
+ - beta
22
+ - latest
23
+ default : latest
24
+
25
+ concurrency :
26
+ group : validate-docker-container
27
+ cancel-in-progress : false
28
+
29
+ jobs :
30
+ validate-container :
31
+ runs-on : ubuntu-latest
32
+ timeout-minutes : 15
33
+
34
+ steps :
35
+ - name : Checkout
36
+ uses : actions/checkout@v4
37
+
38
+ - name : Set container image based on release tag
39
+ id : set-image
40
+ run : |
41
+ echo "CONTAINER_IMAGE=ghcr.io/homebridge/homebridge:${{ inputs.release_tag }}" >> $GITHUB_OUTPUT
42
+ echo "EXPECTED_TAG=${{ inputs.release_tag }}" >> $GITHUB_OUTPUT
43
+
44
+ - name : Start Homebridge container
45
+ working-directory : ./test
46
+ run : |
47
+ echo "Starting Homebridge container with image: ${{ steps.set-image.outputs.CONTAINER_IMAGE }}"
48
+ export HOMEBRIDGE_IMAGE=${{ steps.set-image.outputs.CONTAINER_IMAGE }}
49
+ docker compose up -d
50
+
51
+ echo "Waiting for container to initialize..."
52
+ sleep 15
53
+
54
+ # Check if container is still running
55
+ if ! docker compose ps | grep -q "Up"; then
56
+ echo "❌ Container failed to start or exited unexpectedly"
57
+ docker compose logs
58
+ exit 1
59
+ fi
60
+
61
+ echo "✅ Container is running"
62
+
63
+ - name : Validate Homebridge UI accessibility
64
+ working-directory : ./test
65
+ run : |
66
+ echo "Testing Homebridge UI accessibility..."
67
+
68
+ # Test UI accessibility with retries
69
+ max_attempts=5
70
+ attempt=1
71
+
72
+ while [ $attempt -le $max_attempts ]; do
73
+ echo "Attempt $attempt/$max_attempts: Checking UI accessibility..."
74
+
75
+ if curl -f --connect-timeout 10 --max-time 30 -s -o /dev/null -w "%{http_code}" http://localhost:8581 | grep -q "200"; then
76
+ echo "✅ Homebridge UI is accessible (HTTP 200)"
77
+ break
78
+ elif [ $attempt -eq $max_attempts ]; then
79
+ echo "❌ Homebridge UI is not accessible after $max_attempts attempts"
80
+
81
+ # Show detailed debugging information
82
+ echo "Container status:"
83
+ docker compose ps
84
+ echo "Container logs:"
85
+ docker compose logs --tail 20
86
+ echo "Port check:"
87
+ netstat -tlnp | grep :8581 || echo "Port 8581 not listening"
88
+
89
+ exit 1
90
+ else
91
+ echo "UI not ready yet, waiting 10 seconds..."
92
+ sleep 10
93
+ attempt=$((attempt + 1))
94
+ fi
95
+ done
96
+
97
+ - name : Validate Homebridge service startup
98
+ working-directory : ./test
99
+ run : |
100
+ echo "Validating Homebridge service startup..."
101
+
102
+ # Check for Homebridge version in logs
103
+ if docker compose logs | grep -q "Homebridge v"; then
104
+ version=$(docker compose logs | grep "Homebridge v" | tail -1 | sed -n 's/.*Homebridge v\([0-9.]*\).*/\1/p')
105
+ echo "✅ Homebridge service started successfully (version: $version)"
106
+ else
107
+ echo "❌ Homebridge version not found in logs"
108
+ docker compose logs
109
+ exit 1
110
+ fi
111
+
112
+ # Check for pairing code (indicates successful setup)
113
+ if docker compose logs | grep -q "Enter this code"; then
114
+ echo "✅ Homebridge setup completed with pairing code"
115
+ else
116
+ echo "⚠️ Pairing code not found - this may be normal for some configurations"
117
+ fi
118
+
119
+ # Check for any error messages
120
+ if docker compose logs | grep -i error | grep -v "no such file or directory"; then
121
+ echo "⚠️ Some errors found in logs (may be non-critical):"
122
+ docker compose logs | grep -i error | grep -v "no such file or directory" | head -5
123
+ fi
124
+
125
+ - name : Test container health check
126
+ working-directory : ./test
127
+ run : |
128
+ echo "Testing container health check..."
129
+
130
+ # Wait a bit more for health check to stabilize
131
+ sleep 5
132
+
133
+ # Check container health status
134
+ health_status=$(docker compose ps --format "table {{.Service}}\t{{.Status}}" | grep homebridge | awk '{print $2}')
135
+
136
+ if echo "$health_status" | grep -q "Up"; then
137
+ echo "✅ Container health check passed"
138
+ else
139
+ echo "❌ Container health check failed. Status: $health_status"
140
+ docker compose ps
141
+ exit 1
142
+ fi
143
+
144
+ - name : Validate hb-serivice status
145
+ working-directory : ./test
146
+ run : |
147
+ echo "Validating hb-service status inside container..."
148
+ docker compose exec homebridge sudo hb-service status || echo "⚠️ hb-service status failed"
149
+
150
+ echo "Running hb-service view inside the container..."
151
+ docker compose exec homebridge sudo hb-service view || echo "⚠️ hb-service view failed"
152
+
153
+ - name : Validate version manifest
154
+ run : |
155
+ echo "Checking Docker manifest for ${{ inputs.release_tag }} release..."
156
+
157
+ # Pull version manifest from container
158
+ if docker run --rm ${{ steps.set-image.outputs.CONTAINER_IMAGE }} cat /opt/homebridge/Docker.manifest > manifest_output.txt 2>/dev/null; then
159
+ echo "✅ Successfully retrieved Docker manifest"
160
+ echo "Manifest preview:"
161
+ head -10 manifest_output.txt
162
+
163
+ # Check for expected components in manifest
164
+ if grep -q "Ubuntu" manifest_output.txt && grep -q "Homebridge" manifest_output.txt; then
165
+ echo "✅ Manifest contains expected components"
166
+ else
167
+ echo "⚠️ Manifest may be incomplete"
168
+ cat manifest_output.txt
169
+ fi
170
+ else
171
+ echo "⚠️ Could not retrieve Docker manifest (non-critical)"
172
+ fi
173
+
174
+ - name : Cleanup
175
+ if : always()
176
+ working-directory : ./test
177
+ run : |
178
+ echo "Cleaning up test environment..."
179
+ docker compose down
180
+ echo "✅ Cleanup completed"
181
+
182
+ - name : Validation summary
183
+ if : success()
184
+ run : |
185
+ echo "🎉 Container validation completed successfully!"
186
+ echo "Release tag: ${{ inputs.release_tag }}"
187
+ echo "Container image: ${{ steps.set-image.outputs.CONTAINER_IMAGE }}"
188
+ echo "All validation checks passed:"
189
+ echo " ✅ Container started successfully"
190
+ echo " ✅ Homebridge UI accessible on port 8581"
191
+ echo " ✅ Homebridge service running"
192
+ echo " ✅ Container health check passed"
193
+ echo "::notice::Validation completed successfully for tag ${{ inputs.release_tag }}"
194
+
195
+ - name : Validation failure summary
196
+ if : failure()
197
+ run : |
198
+ echo "❌ Container validation failed!"
199
+ echo "Release tag: ${{ inputs.release_tag }}"
200
+ echo "Container image: ${{ steps.set-image.outputs.CONTAINER_IMAGE }}"
201
+ echo "Please review the logs above for details on the failure."
202
+ echo "::error::Validation failed for tag ${{ inputs.release_tag }}"
0 commit comments