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 29, 2024
1 parent 45baab8 commit 9334d70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 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
16 changes: 13 additions & 3 deletions .github/workflows/ci_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ 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
cat src/main/res/xml/network_config.xml
- name: Cache AVD
uses: actions/cache@v4
id: avd-cache
Expand Down Expand Up @@ -176,10 +188,8 @@ jobs:

- name: Build QA Test Artifacts
id: build-instrumented-tests
env:
SIMPLE_SERVER_HOST: http://localhost: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
2 changes: 1 addition & 1 deletion 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-->
<!-- 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 9334d70

Please sign in to comment.