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 }}
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