Fixed port checking #13
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 Containerized | |
| on: [push, pull_request] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| - name: Install cloud-provider-kind | |
| run: | | |
| go install sigs.k8s.io/cloud-provider-kind@latest | |
| echo "${HOME}/go/bin" >> $GITHUB_PATH | |
| - name: Create k8s Kind Cluster | |
| uses: helm/kind-action@v1 | |
| with: | |
| config: kind-config.yaml | |
| - name: Apply manifests | |
| run: | | |
| kubectl apply -f deployment.yaml | |
| kubectl apply -f service.yaml | |
| cloud-provider-kind & | |
| - name: Wait for server to be ready | |
| run: | | |
| sleep 30 | |
| kubectl get svc -owide | |
| #- name: Start cloud-provider-kind | |
| # run: | | |
| # cloud-provider-kind > cloud_provider_output.log 2>&1 & | |
| # echo "Started cloud-provider-kind" | |
| # sleep 40 | |
| - name: Find port mapping for service | |
| run: | | |
| echo "Checking Docker containers for port mappings..." | |
| docker ps | |
| HOST_PORT=$(docker ps --format '{{.Ports}}' | grep -o '[0-9]\+->5000/tcp' | cut -d':' -f2 | cut -d'-' -f1 || echo "") | |
| echo "SERVICE_URL=http://localhost:$HOST_PORT" >> $GITHUB_ENV | |
| - name: Send GET request and check response | |
| run: | | |
| response=$(curl -s ${{ 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 |