Append tests #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: End-to-End Test Final | |
| on: [push, pull_request] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: waltermity/demohttpserver:latest | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| - name: Create k8s Kind Cluster | |
| uses: waltermity/kind-action@cloudprovider | |
| with: | |
| config: kind-config.yaml | |
| cloud_provider: true | |
| - name: Apply manifests | |
| run: | | |
| kubectl apply -f deployment.yaml | |
| kubectl apply -f service.yaml | |
| - name: Wait for LoadBalancer to get external IP | |
| run: | | |
| echo "Waiting for external IP (timeout: 120s)..." | |
| timeout 120s bash -c 'until kubectl get service demo-http-server-service -o jsonpath="{.status.loadBalancer.ingress[0].ip}" | grep -v "null"; do sleep 2; done' || true | |
| EXTERNAL_IP=$(kubectl get service demo-http-server-service -o jsonpath="{.status.loadBalancer.ingress[0].ip}") | |
| if [ -z "$EXTERNAL_IP" ]; then | |
| echo "Failed to get external IP, test will likely fail" | |
| else | |
| echo "Service has external IP: $EXTERNAL_IP" | |
| echo "SERVICE_URL=http://${EXTERNAL_IP}:5000" >> $GITHUB_ENV | |
| fi | |
| - name: Send GET request and check response | |
| run: | | |
| response=$(curl -v ${{ env.SERVICE_URL }}) | |
| echo "Response: $response" | |
| if [ "$response" == "Hello there!" ]; then | |
| echo "✅ The value received is correct" | |
| else | |
| echo "❌ Received value is incorrect" | |
| exit 1 | |
| fi |