Skip to content

Commit

Permalink
Use Docker container IP address and port as manifest endpoint for run…
Browse files Browse the repository at this point in the history
…ning integration tests in CI
  • Loading branch information
msasikanth committed Nov 28, 2024
1 parent abda404 commit ad2b476
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/docker/simple-server.compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
- "6379"

server:
container_name: simple-server
image: simpledotorg/server:latest
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rake db:setup; bundle exec rails s -p 3000 -b '0.0.0.0'"
expose:
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/ci_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ jobs:
run: |
docker compose -f ".github/docker/simple-server.compose.yml" up -d
- name: Get Docker server IP address
run: |
IP_ADDRESS=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' simple-server)
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

- name: Cache AVD
uses: actions/cache@v4
id: avd-cache
Expand Down Expand Up @@ -176,10 +185,8 @@ jobs:

- name: Build QA Test Artifacts
id: build-instrumented-tests
env:
SIMPLE_SERVER_HOST: http://10.0.2.2:8420
run: |
./gradlew --build-cache --no-daemon -PmanifestEndpoint=$SIMPLE_SERVER_HOST/api/ assembleQaDebug assembleQaDebugAndroidTest
./gradlew --build-cache --no-daemon -PmanifestEndpoint=http://$DOCKER_IP:8420/api/ assembleQaDebug assembleQaDebugAndroidTest
- name: QA Android Tests
id: run-instrumented-tests
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/network_config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<!--We use this local host and port for our integration tests in CI-->
<domain includeSubdomains="true">10.0.2.2</domain>
<!-- We replace the localhost with Docker container IP address during CI -->
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>

0 comments on commit ad2b476

Please sign in to comment.