3232
3333 # Set environment variables for this session
3434 export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
35- export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
35+ export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
3636 export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"
3737
3838 # Add to nix.conf for daemon
@@ -58,3 +58,138 @@ jobs:
5858 ls -la $(nix path-info .#default)/bin/ || echo "$out/bin not found"
5959 echo "Testing compiled binary with direct path..."
6060 $(nix path-info .#default)/bin/godon_cli --help
61+
62+ - name : Start Prism mock container
63+ run : |
64+ # Download the OpenAPI spec with retry
65+ echo "Downloading OpenAPI spec..."
66+ curl -L --retry 3 --retry-delay 5 -o openapi.yml \
67+ https://raw.githubusercontent.com/godon-dev/godon-images/main/images/godon-api/openapi.yml
68+
69+ # Verify the spec was downloaded
70+ if [ ! -f openapi.yml ]; then
71+ echo "Failed to download OpenAPI spec"
72+ exit 1
73+ fi
74+ echo "OpenAPI spec downloaded successfully"
75+ echo "=== Spec file size ==="
76+ wc -l openapi.yml
77+ echo "=== First 20 lines of spec ==="
78+ head -20 openapi.yml
79+ echo "=== Paths section ==="
80+ grep -A 20 "^paths:" openapi.yml || echo "No paths section found"
81+ echo "=== All path definitions ==="
82+ grep -E "^\s*/" openapi.yml || echo "No path definitions found"
83+
84+ # Start Prism container in background
85+ docker run -d --name prism -p 4010:4010 \
86+ -v $(pwd)/openapi.yml:/tmp/openapi.yml \
87+ stoplight/prism:4 \
88+ mock --host 0.0.0.0 /tmp/openapi.yml
89+
90+ # Check if container started
91+ echo "Checking container status..."
92+ docker ps | grep prism || echo "Container not found in docker ps"
93+ echo "=== Container logs ==="
94+ docker logs prism || echo "No logs available"
95+ echo "=== Container inspection ==="
96+ docker inspect prism | grep -A 10 -B 10 "State" || echo "Could not inspect container"
97+ echo "=== Network ports ==="
98+ docker port prism || echo "Could not get port mappings"
99+
100+ # Wait for Prism to start
101+ echo "Waiting for Prism to start..."
102+ sleep 15
103+
104+ # Test basic connectivity
105+ echo "Testing basic connectivity to localhost:4010..."
106+ curl -v http://localhost:4010 || echo "Basic connection failed"
107+
108+ # Verify Prism is running with retry
109+ for i in {1..5}; do
110+ echo "=== Attempt $i: Testing Prism health ==="
111+ if curl -v http://localhost:4010/health 2>&1 | head -10; then
112+ echo "✅ Prism container started successfully on port 4010"
113+ break
114+ else
115+ echo "❌ Attempt $i: Prism not ready yet, waiting..."
116+ echo "Container still running?"
117+ docker ps | grep prism || echo "Container stopped"
118+ echo "Recent logs:"
119+ docker logs --tail 5 prism
120+ sleep 5
121+ fi
122+ done
123+
124+ # Test available endpoints
125+ echo "=== Testing available Prism endpoints ==="
126+ echo "Testing root path:"
127+ curl -v http://localhost:4010/ 2>&1 | head -10 || echo "Root path failed"
128+
129+ echo "Testing /v0 path:"
130+ curl -v http://localhost:4010/v0 2>&1 | head -10 || echo "/v0 path failed"
131+
132+ echo "Testing /v0/breeders:"
133+ curl -v http://localhost:4010/v0/breeders 2>&1 | head -10 || echo "/v0/breeders failed"
134+
135+ echo "Testing OpenAPI spec:"
136+ curl -v http://localhost:4010/openapi.json 2>&1 | head -5 || echo "OpenAPI spec failed"
137+
138+ echo "=== Testing exact URLs that CLI will use ==="
139+ echo "Testing /breeders (what CLI should call):"
140+ curl -v http://localhost:4010/breeders 2>&1 | head -10 || echo "/breeders failed"
141+
142+ echo "Testing POST /breeders:"
143+ curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' \
144+ http://localhost:4010/breeders 2>&1 | head -10 || echo "POST /breeders failed"
145+
146+ - name : Integration tests against Prism mock
147+ run : |
148+ # Get the binary path
149+ BINARY_PATH=$(nix path-info .#default)/bin/godon_cli
150+
151+ echo "Running integration tests against Prism mock..."
152+
153+ # Test breeder list
154+ echo "Testing: breeder list"
155+ $BINARY_PATH --hostname=localhost --port=4010 breeder list
156+
157+ # Create test YAML files using echo
158+ echo 'name: "Test Breeder"' > test_breeder.yml
159+ echo 'description: "Integration test breeder"' >> test_breeder.yml
160+ echo 'config:' >> test_breeder.yml
161+ echo ' setting1: "value1"' >> test_breeder.yml
162+ echo ' setting2: 42' >> test_breeder.yml
163+
164+ echo "Testing: breeder create"
165+ $BINARY_PATH --hostname=localhost --port=4010 breeder create --file=test_breeder.yml
166+
167+ # Test breeder show with a mock UUID
168+ echo "Testing: breeder show"
169+ $BINARY_PATH --hostname=localhost --port=4010 breeder show --id=123e4567-e89b-12d3-a456-426614174000
170+
171+ # Create update test file
172+ echo 'name: "Updated Test Breeder"' > test_breeder_update.yml
173+ echo 'description: "Updated integration test breeder"' >> test_breeder_update.yml
174+ echo 'config:' >> test_breeder_update.yml
175+ echo ' setting1: "updated_value1"' >> test_breeder_update.yml
176+ echo ' setting2: 100' >> test_breeder_update.yml
177+ echo ' new_setting: "new_value"' >> test_breeder_update.yml
178+
179+ echo "Testing: breeder update"
180+ $BINARY_PATH --hostname=localhost --port=4010 breeder update --file=test_breeder_update.yml
181+
182+ # Test breeder purge
183+ echo "Testing: breeder purge"
184+ $BINARY_PATH --hostname=localhost --port=4010 breeder purge --id=123e4567-e89b-12d3-a456-426614174000
185+
186+ # Test help commands
187+ echo "Testing: help commands"
188+ $BINARY_PATH --help
189+ $BINARY_PATH breeder --help || true # May fail but tests argument parsing
190+
191+ - name : Cleanup Prism container
192+ if : always()
193+ run : |
194+ docker stop prism || true
195+ docker rm prism || true
0 commit comments