Skip to content

Commit

Permalink
[TEST]
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Nov 28, 2024
1 parent ad2b476 commit 58a7c1a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/wait_for_docker_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

CONTAINER_ID=$(docker ps -q -f "name=simple-server")
echo "--- inspect --"
docker inspect "$CONTAINER_ID"
echo "--- process --"
docker exec -it "$CONTAINER_ID" bash
echo "-- logs --"
docker logs "$CONTAINER_ID"

url="http://$DOCKER_IP:8420"
timeout_in_seconds=900 # 15 minutes in seconds

start_time=$(date +%s)

while true; do
response_code=$(curl -s -o /dev/null -w "%{http_code}" "$url")

if [ "$response_code" -eq 200 ]; then
echo "Success! Received 200 OK response."
break
else
echo "Failed, got $response_code as response code. Retrying..."
sleep 5

current_time=$(date +%s)
elapsed_time=$((current_time - start_time))

if [ "$elapsed_time" -ge "$timeout_in_seconds" ]; then
echo "Timeout reached. Exiting."
exit 1
fi
fi
done
11 changes: 9 additions & 2 deletions .github/workflows/ci_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,14 @@ jobs:
echo "Docker container IP address is: $IP_ADDRESS"
echo "DOCKER_IP=$IP_ADDRESS" >> $GITHUB_ENV
- name: Replace IP address in network security config
run: sed -i 's/localhost/$DOCKER_IP/g' app/src/main/res/xml/network_config.xml
run: |
sed -i "s/localhost/$DOCKER_IP/g" app/src/main/res/xml/network_config.xml
cat app/src/main/res/xml/network_config.xml
- name: Wait for Docker server to be available
run: .github/scripts/wait_for_docker_server.sh

- name: Cache AVD
uses: actions/cache@v4
Expand Down Expand Up @@ -186,7 +192,7 @@ jobs:
- name: Build QA Test Artifacts
id: build-instrumented-tests
run: |
./gradlew --build-cache --no-daemon -PmanifestEndpoint=http://$DOCKER_IP:8420/api/ assembleQaDebug assembleQaDebugAndroidTest
./gradlew --build-cache --no-daemon -PmanifestEndpoint=http://$DOCKER_IP/api/ assembleQaDebug assembleQaDebugAndroidTest
- name: QA Android Tests
id: run-instrumented-tests
Expand All @@ -199,6 +205,7 @@ jobs:
disable-animations: true
disk-size: 8G
script: |
echo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' simple-server
adb root
mkdir -p app/build/outputs/test-artifacts
adb install app/build/outputs/apk/qa/debug/app-qa-debug.apk
Expand Down

0 comments on commit 58a7c1a

Please sign in to comment.