1+
12name : Integration Tests
23
34on :
6061 ${{ runner.os }}-cargo-
6162
6263 - name : Install SQLx CLI
63- run : cargo install sqlx-cli --no-default-features --features postgres
64+ run : |
65+ if ! command -v sqlx &> /dev/null; then
66+ cargo install sqlx-cli --no-default-features --features postgres
67+ else
68+ echo "SQLx CLI already installed"
69+ fi
6470
6571 - name : Set up Python
6672 uses : actions/setup-python@v4
7379 pip install --upgrade pip
7480 pip install -r tests/requirements.txt
7581
82+ # ===== KUBERNETES SETUP SECTION =====
83+ - name : Install kubectl
84+ run : |
85+ echo "Installing kubectl..."
86+ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
87+ curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
88+ echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
89+ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
90+ kubectl version --client
91+ rm -f kubectl kubectl.sha256
92+
93+ - name : Install Minikube
94+ run : |
95+ echo "Installing Minikube..."
96+ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
97+ sudo install minikube-linux-amd64 /usr/local/bin/minikube
98+ rm -f minikube-linux-amd64
99+ minikube version
100+
101+ - name : Start Minikube
102+ run : |
103+ echo "Starting Minikube with Docker driver..."
104+ # Start minikube with specific configuration for CI
105+ minikube start \
106+ --driver=docker \
107+ --kubernetes-version=v1.28.3 \
108+ --memory=4096 \
109+ --cpus=2 \
110+ --disk-size=20g \
111+ --wait=all \
112+ --wait-timeout=5m
113+
114+ # Wait for cluster to be ready
115+ echo "Waiting for Minikube cluster to be ready..."
116+ minikube status
117+ kubectl cluster-info
118+ kubectl get nodes
119+
120+ - name : Configure Kubernetes environment
121+ run : |
122+ echo "Configuring Kubernetes environment..."
123+ # Set kubeconfig
124+ export KUBECONFIG=$HOME/.kube/config
125+ echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
126+
127+ # Create test namespace
128+ kubectl create namespace test || true
129+ kubectl config set-context --current --namespace=test
130+
131+ # Show cluster info
132+ echo "Kubernetes cluster info:"
133+ kubectl version
134+ kubectl get namespaces
135+ kubectl get pods --all-namespaces
136+ # ===== END KUBERNETES SETUP =====
137+
76138 - name : Build Rust application
77139 run : |
78140 # Use offline mode for SQLx to avoid database dependency during compilation
@@ -97,11 +159,21 @@ jobs:
97159 # Override specific variables for GitHub Actions environment
98160 echo "DATABASE_URL=postgresql://postgres:password@localhost:5432/container_engine_test" >> $GITHUB_ENV
99161 echo "REDIS_URL=redis://localhost:6379" >> $GITHUB_ENV
162+
163+ # Add Kubernetes-specific environment variables
164+ echo "KUBERNETES_ENABLED=true" >> $GITHUB_ENV
165+ echo "KUBERNETES_NAMESPACE=test" >> $GITHUB_ENV
166+ echo "KUBERNETES_IN_CLUSTER=false" >> $GITHUB_ENV
100167
101168 - name : Run database migrations
102169 run : |
103170 sqlx migrate run --database-url postgresql://postgres:password@localhost:5432/container_engine_test
104171
172+ - name : Prepare SQLx offline data
173+ run : |
174+ export DATABASE_URL=postgresql://postgres:password@localhost:5432/container_engine_test
175+ cargo sqlx prepare
176+
105177 - name : Start Container Engine server in background
106178 run : |
107179 # Use offline mode for SQLx and start server
@@ -112,10 +184,31 @@ jobs:
112184 # Wait for server to be ready (using port 3001 for integration tests)
113185 timeout 60 bash -c 'until curl -f http://localhost:3001/health; do sleep 2; done'
114186
115- - name : Run integration tests
187+ - name : Verify Kubernetes connectivity
116188 run : |
117- python -m pytest tests/integrate/ -v --tb=short --durations=10
118- timeout-minutes : 15
189+ echo "Verifying Container Engine can connect to Kubernetes..."
190+ # This would be where you verify your app can talk to K8s
191+ kubectl auth can-i get pods --namespace=test
192+
193+ # - name: Run integration tests
194+ # run: |
195+ # python -m pytest tests/integrate/ -v --tb=short --durations=10
196+ # timeout-minutes: 15
197+
198+ - name : Show logs on failure
199+ if : failure()
200+ run : |
201+ echo "=== Server logs ==="
202+ if [ -f server.pid ]; then
203+ ps aux | grep $(cat server.pid) || echo "Server process not found"
204+ fi
205+
206+ echo "=== Minikube logs ==="
207+ minikube logs --lines=50
208+
209+ echo "=== Kubernetes pod logs ==="
210+ kubectl get pods --all-namespaces
211+ kubectl describe pods --all-namespaces
119212
120213 - name : Stop server
121214 if : always()
@@ -125,23 +218,29 @@ jobs:
125218 rm server.pid
126219 fi
127220
128- - name : Upload test results
129- if : always()
130- uses : actions/upload-artifact@v4
131- with :
132- name : test-results
133- path : |
134- pytest-report.html
135- .pytest_cache/
136- retention-days : 7
137-
138- - name : Test Summary
221+ - name : Stop Minikube
139222 if : always()
140223 run : |
141- echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
142- echo "Integration tests completed for Container Engine API" >> $GITHUB_STEP_SUMMARY
143- if [ ${{ job.status }} == 'success' ]; then
144- echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
145- else
146- echo "❌ Some tests failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
147- fi
224+ minikube stop || true
225+ minikube delete || true
226+
227+ # - name: Upload test results
228+ # if: always()
229+ # uses: actions/upload-artifact@v4
230+ # with:
231+ # name: test-results
232+ # path: |
233+ # pytest-report.html
234+ # .pytest_cache/
235+ # retention-days: 7
236+
237+ # - name: Test Summary
238+ # if: always()
239+ # run: |
240+ # echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
241+ # echo "Integration tests completed for Container Engine API" >> $GITHUB_STEP_SUMMARY
242+ # if [ ${{ job.status }} == 'success' ]; then
243+ # echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
244+ # else
245+ # echo "❌ Some tests failed. Check the logs above." >> $GITHUB_STEP_SUMMARY
246+ # fi
0 commit comments