-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (138 loc) · 6.17 KB
/
ci.yml
File metadata and controls
166 lines (138 loc) · 6.17 KB
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
158
159
160
161
162
163
164
165
166
name: Build and Test Godon CLI
on:
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-25.11
extra_nix_config: |
sandbox = false
sandbox-paths = /etc/ssl/certs/ca-bundle.crt
experimental-features = nix-command flakes
- name: Configure Nix daemon SSL certificates
run: |
# Find and symlink SSL certificates for Nix daemon
sudo mkdir -p /etc/ssl/certs
CERT_BUNDLE=$(find /nix/store -name "ca-bundle.crt" | head -1)
echo "Found certificate bundle: $CERT_BUNDLE"
sudo ln -sf "$CERT_BUNDLE" /etc/ssl/certs/ca-bundle.crt
sudo ln -sf "$CERT_BUNDLE" /etc/ssl/certs/ca-certificates.crt
# Set environment variables for this session
export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"
# Add to nix.conf for daemon
echo "ssl-cert-file = /etc/ssl/certs/ca-bundle.crt" | sudo tee -a /etc/nix/nix.conf
echo "SSL certificates configured for Nix daemon"
- name: Build with Nix
run: |
export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"
nix --experimental-features "nix-command flakes" build --verbose
- name: Test binary
run: |
echo "Checking build output..."
echo "Result path:"
nix path-info .#default
echo "Contents of result directory:"
ls -la $(nix path-info .#default)/ || echo "result directory contents"
echo "Checking $out/bin directory:"
ls -la $(nix path-info .#default)/bin/ || echo "$out/bin not found"
echo "Testing compiled binary with direct path..."
$(nix path-info .#default)/bin/godon_cli --help
- name: Start Prism mock container
run: |
# Download the OpenAPI spec with retry
echo "Downloading OpenAPI spec..."
curl -L --retry 3 --retry-delay 5 -o openapi.yml \
https://raw.githubusercontent.com/godon-dev/godon-images/main/images/godon-api/openapi.yml
# Verify the spec was downloaded
if [ ! -f openapi.yml ]; then
echo "Failed to download OpenAPI spec"
exit 1
fi
echo "OpenAPI spec downloaded successfully"
head -5 openapi.yml
# Start Prism container in background
docker run -d --name prism -p 4010:4010 \
-v $(pwd)/openapi.yml:/tmp/openapi.yml \
stoplight/prism:4 \
mock --host 0.0.0.0 /tmp/openapi.yml
# Check if container started
echo "Checking container status..."
docker ps | grep prism || echo "Container not found in docker ps"
echo "=== Container logs ==="
docker logs prism || echo "No logs available"
echo "=== Container inspection ==="
docker inspect prism | grep -A 10 -B 10 "State" || echo "Could not inspect container"
echo "=== Network ports ==="
docker port prism || echo "Could not get port mappings"
# Wait for Prism to start
echo "Waiting for Prism to start..."
sleep 15
# Test basic connectivity
echo "Testing basic connectivity to localhost:4010..."
curl -v http://localhost:4010 || echo "Basic connection failed"
# Verify Prism is running with retry
for i in {1..5}; do
echo "=== Attempt $i: Testing Prism health ==="
if curl -v http://localhost:4010/health 2>&1 | head -10; then
echo "✅ Prism container started successfully on port 4010"
break
else
echo "❌ Attempt $i: Prism not ready yet, waiting..."
echo "Container still running?"
docker ps | grep prism || echo "Container stopped"
echo "Recent logs:"
docker logs --tail 5 prism
sleep 5
fi
done
- name: Integration tests against Prism mock
run: |
# Get the binary path
BINARY_PATH=$(nix path-info .#default)/bin/godon_cli
echo "Running integration tests against Prism mock..."
# Test breeder list
echo "Testing: breeder list"
$BINARY_PATH --hostname=localhost --port=4010 breeder list
# Create test YAML files using echo
echo 'name: "Test Breeder"' > test_breeder.yml
echo 'description: "Integration test breeder"' >> test_breeder.yml
echo 'config:' >> test_breeder.yml
echo ' setting1: "value1"' >> test_breeder.yml
echo ' setting2: 42' >> test_breeder.yml
echo "Testing: breeder create"
$BINARY_PATH --hostname=localhost --port=4010 breeder create --file=test_breeder.yml
# Test breeder show with a mock UUID
echo "Testing: breeder show"
$BINARY_PATH --hostname=localhost --port=4010 breeder show --uuid=123e4567-e89b-12d3-a456-426614174000
# Create update test file
echo 'name: "Updated Test Breeder"' > test_breeder_update.yml
echo 'description: "Updated integration test breeder"' >> test_breeder_update.yml
echo 'config:' >> test_breeder_update.yml
echo ' setting1: "updated_value1"' >> test_breeder_update.yml
echo ' setting2: 100' >> test_breeder_update.yml
echo ' new_setting: "new_value"' >> test_breeder_update.yml
echo "Testing: breeder update"
$BINARY_PATH --hostname=localhost --port=4010 breeder update --file=test_breeder_update.yml
# Test breeder purge
echo "Testing: breeder purge"
$BINARY_PATH --hostname=localhost --port=4010 breeder purge --uuid=123e4567-e89b-12d3-a456-426614174000
# Test help commands
echo "Testing: help commands"
$BINARY_PATH --help
$BINARY_PATH breeder --help || true # May fail but tests argument parsing
- name: Cleanup Prism container
if: always()
run: |
docker stop prism || true
docker rm prism || true