|
|
|
@@ -187,16 +187,16 @@ jobs:
|
|
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
echo "🚀 Testing ${{ needs.create-release.outputs.version }} deployment locally..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create a dedicated network so we can resolve by container name
|
|
|
|
|
docker network create ci_net || true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pull the built image
|
|
|
|
|
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.create-release.outputs.version }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Stop & remove any existing container
|
|
|
|
|
docker rm -f ping-river-monitor-test 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Start the container on the user-defined network
|
|
|
|
|
docker run -d \
|
|
|
|
|
--name ping-river-monitor-test \
|
|
|
|
@@ -205,24 +205,24 @@ jobs:
|
|
|
|
|
-e LOG_LEVEL=INFO \
|
|
|
|
|
-e DB_TYPE=sqlite \
|
|
|
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.create-release.outputs.version }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "✅ Container started for testing"
|
|
|
|
|
|
|
|
|
|
- name: Health check after deployment
|
|
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
echo "⏳ Waiting for application to start..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pull a curl-only image for probing (keeps your app image slim)
|
|
|
|
|
docker pull curlimages/curl:8.10.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Helper: curl via a sibling container on the SAME Docker network
|
|
|
|
|
probe() {
|
|
|
|
|
local url="$1"
|
|
|
|
|
docker run --rm --network ci_net curlimages/curl:8.10.1 \
|
|
|
|
|
-sS --max-time 5 --connect-timeout 3 -w "HTTP_CODE:%{http_code}" "$url" || true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Wait for /health (up to ~3m 45s)
|
|
|
|
|
for i in {1..15}; do
|
|
|
|
|
echo "🔍 Attempt $i/15: checking http://ping-river-monitor-test:8000/health"
|
|
|
|
@@ -246,7 +246,7 @@ jobs:
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "🧪 Testing API endpoints…"
|
|
|
|
|
endpoints=("health" "docs" "stations" "metrics")
|
|
|
|
|
for ep in "${endpoints[@]}"; do
|
|
|
|
@@ -262,19 +262,8 @@ jobs:
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo "✅ All health checks passed!"
|
|
|
|
|
|
|
|
|
|
- name: (Fallback) Probe via host-published port
|
|
|
|
|
if: always()
|
|
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
# In case you also want to verify the host-published port from inside the job container:
|
|
|
|
|
HOST_GATEWAY="$(ip route | awk '/default/ {print $3}')"
|
|
|
|
|
echo "🔎 Host gateway is $HOST_GATEWAY — probing http://$HOST_GATEWAY:8080/health"
|
|
|
|
|
docker run --rm curlimages/curl:8.10.1 \
|
|
|
|
|
-sS --max-time 5 --connect-timeout 3 -w "HTTP_CODE:%{http_code}\n" \
|
|
|
|
|
"http://$HOST_GATEWAY:8080/health" || true
|
|
|
|
|
echo "✅ All health checks passed!"
|
|
|
|
|
|
|
|
|
|
- name: Container logs and cleanup
|
|
|
|
|
if: always()
|
|
|
|
|