Skip to content

Commit ad2b476

Browse files
committed
Use Docker container IP address and port as manifest endpoint for running integration tests in CI
1 parent abda404 commit ad2b476

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.github/docker/simple-server.compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ services:
1515
- "6379"
1616

1717
server:
18+
container_name: simple-server
1819
image: simpledotorg/server:latest
1920
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'"
2021
expose:

.github/workflows/ci_checks.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ jobs:
143143
run: |
144144
docker compose -f ".github/docker/simple-server.compose.yml" up -d
145145
146+
- name: Get Docker server IP address
147+
run: |
148+
IP_ADDRESS=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' simple-server)
149+
echo "Docker container IP address is: $IP_ADDRESS"
150+
echo "DOCKER_IP=$IP_ADDRESS" >> $GITHUB_ENV
151+
152+
- name: Replace IP address in network security config
153+
run: sed -i 's/localhost/$DOCKER_IP/g' app/src/main/res/xml/network_config.xml
154+
146155
- name: Cache AVD
147156
uses: actions/cache@v4
148157
id: avd-cache
@@ -176,10 +185,8 @@ jobs:
176185

177186
- name: Build QA Test Artifacts
178187
id: build-instrumented-tests
179-
env:
180-
SIMPLE_SERVER_HOST: http://10.0.2.2:8420
181188
run: |
182-
./gradlew --build-cache --no-daemon -PmanifestEndpoint=$SIMPLE_SERVER_HOST/api/ assembleQaDebug assembleQaDebugAndroidTest
189+
./gradlew --build-cache --no-daemon -PmanifestEndpoint=http://$DOCKER_IP:8420/api/ assembleQaDebug assembleQaDebugAndroidTest
183190
184191
- name: QA Android Tests
185192
id: run-instrumented-tests
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<network-security-config>
33
<domain-config cleartextTrafficPermitted="true">
4-
<!--We use this local host and port for our integration tests in CI-->
5-
<domain includeSubdomains="true">10.0.2.2</domain>
4+
<!-- We replace the localhost with Docker container IP address during CI -->
5+
<domain includeSubdomains="true">localhost</domain>
66
</domain-config>
77
</network-security-config>

0 commit comments

Comments
 (0)