fix: remove kubectl installation, assume available in runner
CI / CI (pull_request) Failing after 3m6s

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:<sha>
  3. Push: <sha> 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
This commit is contained in:
Admin Bot
2026-09-13 13:44:15 +09:00
parent e0622449cc
commit a700ac065b
+10 -16
View File
@@ -70,11 +70,9 @@ jobs:
KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }} KUBECONFIG_B64: ${{ secrets.KUBECONFIG_B64 }}
continue-on-error: true continue-on-error: true
- name: Install kubectl - name: Verify kubectl availability
run: | run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" kubectl version --client || (echo "ERROR: kubectl not available" && exit 1)
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
- name: Deploy test pod from new image - name: Deploy test pod from new image
run: | 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 kubectl wait --for=condition=ready pod -l run=api-gateway-test-${{ steps.sha.outputs.short_sha }} -n api --timeout=60s
continue-on-error: true continue-on-error: true
- name: Run integration tests against test pod - name: Run integration tests inside test pod
run: | run: |
echo "Running integration tests against test pod..." echo "Running integration tests inside test pod..."
# Port-forward to test pod echo "Test pod: api-gateway-test-${{ steps.sha.outputs.short_sha }}"
kubectl port-forward -n api pod/api-gateway-test-${{ steps.sha.outputs.short_sha }} 8080:8080 & sleep 5
PF_PID=$!
sleep 3
# Run tests # Run tests from inside the pod
TEST_RESULT=0 # Pod has network access to all services via network policy labels
go test -v -tags=integration -timeout=5m ./internal/integration/... || TEST_RESULT=$? kubectl exec -n api pod/api-gateway-test-${{ steps.sha.outputs.short_sha }} -- \
go test -v -tags=integration -timeout=5m ./internal/integration/...
kill $PF_PID || true
exit $TEST_RESULT
env: env:
GATEWAY_URL: http://localhost:8080 GATEWAY_URL: http://localhost:8080
continue-on-error: false continue-on-error: false