From a700ac065bce896ddecae12bb152edaa9cd677e6 Mon Sep 17 00:00:00 2001 From: Admin Bot Date: Sun, 13 Sep 2026 13:44:15 +0900 Subject: [PATCH] fix: remove kubectl installation, assume available in runner OPTIMIZATIONS: - Remove curl-based kubectl installation (inefficient) - Assume kubectl is available in Gitea runner environment - Replace port-forward with kubectl exec for test execution - Tests now run directly inside test pod (not from runner) - Simpler, faster, more reliable CI Flow: 1. go vet + go test (unit tests) 2. Build image: api-gateway: 3. Push: tag only 4. Deploy test pod with proper labels 5. kubectl exec into pod to run tests 6. Tests run inside pod, can reach services via network policy 7. Promote to latest only if tests pass 8. Cleanup test pod --- .gitea/workflows/ci.yaml | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index aa152fc..f5e9e1d 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -70,11 +70,9 @@ jobs: KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }} continue-on-error: true - - name: Install kubectl + - name: Verify kubectl availability run: | - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" - chmod +x kubectl - sudo mv kubectl /usr/local/bin/ + kubectl version --client || (echo "ERROR: kubectl not available" && exit 1) - name: Deploy test pod from new image run: | @@ -91,20 +89,16 @@ jobs: kubectl wait --for=condition=ready pod -l run=api-gateway-test-${{ steps.sha.outputs.short_sha }} -n api --timeout=60s continue-on-error: true - - name: Run integration tests against test pod + - name: Run integration tests inside test pod run: | - echo "Running integration tests against test pod..." - # Port-forward to test pod - kubectl port-forward -n api pod/api-gateway-test-${{ steps.sha.outputs.short_sha }} 8080:8080 & - PF_PID=$! - sleep 3 + echo "Running integration tests inside test pod..." + echo "Test pod: api-gateway-test-${{ steps.sha.outputs.short_sha }}" + sleep 5 - # Run tests - TEST_RESULT=0 - go test -v -tags=integration -timeout=5m ./internal/integration/... || TEST_RESULT=$? - - kill $PF_PID || true - exit $TEST_RESULT + # Run tests from inside the pod + # Pod has network access to all services via network policy labels + kubectl exec -n api pod/api-gateway-test-${{ steps.sha.outputs.short_sha }} -- \ + go test -v -tags=integration -timeout=5m ./internal/integration/... env: GATEWAY_URL: http://localhost:8080 continue-on-error: false