From 1ccb754186796a941e07ce77c388a711f556b078 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 20:23:06 +0100 Subject: [PATCH 01/20] Update config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 348774f1..714a2d9d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: @@ -71,4 +71,4 @@ workflows: - build - test: requires: - - build \ No newline at end of file + - build From bb5ba6ce9ee227750eab95289065ac88e5154d5f Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:37:44 +0100 Subject: [PATCH 02/20] Update config.yml --- .circleci/config.yml | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 714a2d9d..a29bbe8f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,12 +2,12 @@ version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: - name: android/android-machine - resource-class: large + name: android/default tag: 2024.01.1 steps: @@ -15,23 +15,14 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - - - android/create-avd: - avd-name: avd - install: true - system-image: system-images;android-29;default;x86 - - android/start-emulator: - avd-name: avd - no-window: true - restore-gradle-cache-prefix: v2 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest - - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - - android/save-gradle-cache: - cache-prefix: v1 + - android/setup-emulator: + api-level: 29 + emulator-type: full + - android/wait-for-emulator: + timeout-sec: 180 + - run: + name: Install APKs and Run Tests + command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results @@ -42,18 +33,15 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/restore-gradle-cache: - cache-prefix: v1 - run: name: Download Dependencies command: ./gradlew androidDependencies - - android/save-gradle-cache: - cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug From 882ac4c25d56a3e6e49d281f1c620f16c7927df8 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:42:35 +0100 Subject: [PATCH 03/20] Update config.yml --- .circleci/config.yml | 54 ++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a29bbe8f..e20dd29d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,25 +1,27 @@ version: 2.1 -orbs: - android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common - executor: - name: android/default - tag: 2024.01.1 - + docker: + - image: circleci/android:2020.10 steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/setup-emulator: - api-level: 29 - emulator-type: full - - android/wait-for-emulator: - timeout-sec: 180 + - run: + name: Download and Install SDK Packages + command: sdkmanager "system-images;android-29;google_apis;x86" "platform-tools" "platforms;android-29" "emulator" --sdk_root=/usr/local/android-sdk + - run: + name: Create and Start Emulator + command: | + echo "no" | avdmanager --verbose create avd --force --name test --package "system-images;android-29;google_apis;x86" --abi google_apis/x86 + emulator -avd test -no-window -no-audio -no-snapshot -gpu swiftshader_indirect & + circle-android wait-for-boot + - run: + name: Wait for Emulator to Start + command: adb wait-for-device - run: name: Install APKs and Run Tests command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest @@ -30,33 +32,7 @@ jobs: name: Store Test Reports path: services_app/build/reports - build: - docker: - - image: cimg/android:2024.01 - - steps: - - checkout - - run: - name: Chmod Permissions - command: sudo chmod +x gradlew - - run: - name: Download Dependencies - command: ./gradlew androidDependencies - - run: - name: Build Services - command: ./gradlew assembleSnapshotDebug - - store_artifacts: - name: Store Build Artifacts - path: services_app/build/outputs/apk - - persist_to_workspace: - root: . - paths: - - services_app/build/outputs/apk - workflows: build-test-workflow: jobs: - - build - - test: - requires: - - build + - test From bd8faad5bf2acce655f98ebec8545824411e5bbe Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:44:14 +0100 Subject: [PATCH 04/20] Update config.yml --- .circleci/config.yml | 73 +++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e20dd29d..95e8df3c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,30 +1,38 @@ + version: 2.1 +orbs: + android: circleci/android@2.4.0 jobs: test: description: Runs unit tests and instrumented tests on the Android Common - docker: - - image: circleci/android:2020.10 + executor: + name: android/android-machine + resource-class: large + tag: 2024.01.1 + steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - run: - name: Download and Install SDK Packages - command: sdkmanager "system-images;android-29;google_apis;x86" "platform-tools" "platforms;android-29" "emulator" --sdk_root=/usr/local/android-sdk - - run: - name: Create and Start Emulator - command: | - echo "no" | avdmanager --verbose create avd --force --name test --package "system-images;android-29;google_apis;x86" --abi google_apis/x86 - emulator -avd test -no-window -no-audio -no-snapshot -gpu swiftshader_indirect & - circle-android wait-for-boot - - run: - name: Wait for Emulator to Start - command: adb wait-for-device - - run: - name: Install APKs and Run Tests - command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + + - android/create-avd: + avd-name: avd + install: true + system-image: system-images;android-29;default;x86 + - android/start-emulator: + avd-name: avd + no-window: true + restore-gradle-cache-prefix: v2 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + - android/save-gradle-cache: + cache-prefix: v1 - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results @@ -32,7 +40,36 @@ jobs: name: Store Test Reports path: services_app/build/reports + build: + docker: + - image: cimg/android:2024.01 + steps: + - checkout + - run: + name: Chmod Permissions + command: sudo chmod +x gradlew + - android/restore-gradle-cache: + cache-prefix: v1 + - run: + name: Download Dependencies + command: ./gradlew androidDependencies + - android/save-gradle-cache: + cache-prefix: v1 + - run: + name: Build Services + command: ./gradlew assembleSnapshotDebug + - store_artifacts: + name: Store Build Artifacts + path: services_app/build/outputs/apk + - persist_to_workspace: + root: . + paths: + - services_app/build/outputs/apk + workflows: build-test-workflow: jobs: - - test + - build + - test: + requires: + - build From 3f5bed479e96f0b835df3cc35dfb9d28af7ade07 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:45:20 +0100 Subject: [PATCH 05/20] Update config.yml --- .circleci/config.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f94a866c..51762538 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,3 @@ - version: 2.1 orbs: @@ -16,6 +15,8 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + environment: + TERM: dumb - android/create-avd: avd-name: avd @@ -27,11 +28,17 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + environment: + TERM: dumb - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest + environment: + TERM: dumb - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + environment: + TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -49,16 +56,22 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + environment: + TERM: dumb - android/restore-gradle-cache: cache-prefix: v1 - run: name: Download Dependencies command: ./gradlew androidDependencies + environment: + TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug + environment: + TERM: dumb - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From 18376679aebadcd99c759e458ea2fc3230261dc1 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:50:59 +0100 Subject: [PATCH 06/20] Update config.yml --- .circleci/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 51762538..30de6259 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,9 +15,6 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - environment: - TERM: dumb - - android/create-avd: avd-name: avd install: true @@ -28,8 +25,6 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - environment: - TERM: dumb - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest @@ -57,7 +52,6 @@ jobs: name: Chmod Permissions command: sudo chmod +x gradlew environment: - TERM: dumb - android/restore-gradle-cache: cache-prefix: v1 - run: From cac1a57e636c7ec7c31b77bad3c0b53e258d88cc Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:53:25 +0100 Subject: [PATCH 07/20] Update config.yml --- .circleci/config.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30de6259..741a3bbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,12 +28,8 @@ jobs: - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - environment: - TERM: dumb - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - environment: - TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -57,15 +53,11 @@ jobs: - run: name: Download Dependencies command: ./gradlew androidDependencies - environment: - TERM: dumb - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug - environment: - TERM: dumb - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From 87104d5f8a1d8be8ed16e6a2d17c5cd7d90a6b1b Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:58:34 +0100 Subject: [PATCH 08/20] Update config.yml --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 741a3bbc..4ff1b081 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,6 +30,7 @@ jobs: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + no_output_timeout: 1h - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: From b3e33e39db971ccf524a9e9f82f6e87ec11e090a Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:59:33 +0100 Subject: [PATCH 09/20] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ff1b081..e628cbcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ jobs: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - no_output_timeout: 1h + no-output-timeout: 1h - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: From 6898371699d447782e23660f24855220b0fa155b Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:22:41 +0100 Subject: [PATCH 10/20] Update config.yml --- .circleci/config.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e628cbcf..20063323 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,6 +2,7 @@ version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -25,12 +26,25 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - run: + name: Wait for Emulator + command: | + # Wait for the emulator to fully boot up + adb wait-for-device + sleep 30 + adb shell input keyevent 82 + - run: + name: Restart ADB Server + command: | + adb kill-server + adb start-server + adb devices - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - no-output-timeout: 1h + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + no-output-timeout: 30min - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -39,6 +53,9 @@ jobs: - store_artifacts: name: Store Test Reports path: services_app/build/reports + - run: + name: Collect ADB Logs + command: adb logcat -d > $CIRCLE_ARTIFACTS/adb_log.txt build: docker: From 37db507f0a8fe314bcdfb86868d1e0f02eef36ae Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:29:08 +0100 Subject: [PATCH 11/20] Update config.yml --- .circleci/config.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 20063323..9edb89bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,15 +40,16 @@ jobs: adb start-server adb devices - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest - - android/run-tests: + - run: + name: Run Unit Tests + command: ./gradlew testSnapshotDebugUnitTest --info + - run: + name: Run Instrumented Tests command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - no-output-timeout: 30min + no-output-timeout: 30m - android/save-gradle-cache: cache-prefix: v1 - - store_artifacts: - name: Store Test Results + - store_test_results: path: services_app/build/outputs/androidTest-results - store_artifacts: name: Store Test Reports @@ -56,6 +57,9 @@ jobs: - run: name: Collect ADB Logs command: adb logcat -d > $CIRCLE_ARTIFACTS/adb_log.txt + - store_artifacts: + name: Store ADB Logs + path: $CIRCLE_ARTIFACTS/adb_log.txt build: docker: @@ -65,7 +69,6 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - environment: - android/restore-gradle-cache: cache-prefix: v1 - run: From 8bbd1d75f8219bd14372cf28e04acb762869f42b Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:13:31 +0100 Subject: [PATCH 12/20] Update config.yml --- .circleci/config.yml | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9edb89bd..68e0747f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ + version: 2.1 orbs: android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -16,6 +16,7 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/create-avd: avd-name: avd install: true @@ -26,40 +27,20 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - - run: - name: Wait for Emulator - command: | - # Wait for the emulator to fully boot up - adb wait-for-device - sleep 30 - adb shell input keyevent 82 - - run: - name: Restart ADB Server - command: | - adb kill-server - adb start-server - adb devices - android/disable-animations - - run: - name: Run Unit Tests - command: ./gradlew testSnapshotDebugUnitTest --info - - run: - name: Run Instrumented Tests - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest --info + - android/run-tests: + test-command:./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info no-output-timeout: 30m - android/save-gradle-cache: cache-prefix: v1 - - store_test_results: + - store_artifacts: + name: Store Test Results path: services_app/build/outputs/androidTest-results - store_artifacts: name: Store Test Reports path: services_app/build/reports - - run: - name: Collect ADB Logs - command: adb logcat -d > $CIRCLE_ARTIFACTS/adb_log.txt - - store_artifacts: - name: Store ADB Logs - path: $CIRCLE_ARTIFACTS/adb_log.txt build: docker: From 27345a300c967e950bd75391a58957c31affa71d Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:36:52 +0100 Subject: [PATCH 13/20] Update config.yml --- .circleci/config.yml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 68e0747f..f5828c14 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: @@ -16,7 +16,6 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/create-avd: avd-name: avd install: true @@ -28,10 +27,12 @@ jobs: memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest --info - - android/run-tests: - test-command:./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - run: + name: Run Unit Tests + command: ./gradlew testSnapshotDebugUnitTest --info + - run: + name: Run Instrumented Tests + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info no-output-timeout: 30m - android/save-gradle-cache: cache-prefix: v1 @@ -41,6 +42,12 @@ jobs: - store_artifacts: name: Store Test Reports path: services_app/build/reports + - run: + name: Collect ADB Logs + command: adb logcat -d > adb_log.txt + - store_artifacts: + name: Store ADB Logs + path: adb_log.txt build: docker: @@ -54,12 +61,12 @@ jobs: cache-prefix: v1 - run: name: Download Dependencies - command: ./gradlew androidDependencies + command: ./gradlew androidDependencies --info - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services - command: ./gradlew assembleSnapshotDebug + command: ./gradlew assembleSnapshotDebug --info - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From dc66510f71baf137ff8c2f89c802ac702f35ee81 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:46:04 +0100 Subject: [PATCH 14/20] Update config.yml --- .circleci/config.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f5828c14..196a112a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -17,15 +17,19 @@ jobs: name: Chmod Permissions command: sudo chmod +x gradlew - android/create-avd: - avd-name: avd - install: true - system-image: system-images;android-29;default;x86 + avd-name: Pixel_7_Pro + device: pixel_7_pro + system-image: system-images;android-33;google_apis_playstore;x86_64 + tag: google_apis_playstore + abi: x86_64 + sdcard-path: sdcard.img + force: true - android/start-emulator: - avd-name: avd + avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 - memory: 4096 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + memory: 4096 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - run: name: Run Unit Tests @@ -33,7 +37,7 @@ jobs: - run: name: Run Instrumented Tests command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - no-output-timeout: 30m + timeout: 30m - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: From abb7c961301ed8324443d54ad411b835f9b6e2d9 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:50:49 +0100 Subject: [PATCH 15/20] Update config.yml --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 196a112a..251b8ee5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,6 +23,7 @@ jobs: tag: google_apis_playstore abi: x86_64 sdcard-path: sdcard.img + install: true force: true - android/start-emulator: avd-name: Pixel_7_Pro From 1d84806b8c83f48e1c58e4acdb2a37e813defecf Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:52:05 +0100 Subject: [PATCH 16/20] Update config.yml --- .circleci/config.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 251b8ee5..e997f352 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,13 +18,8 @@ jobs: command: sudo chmod +x gradlew - android/create-avd: avd-name: Pixel_7_Pro - device: pixel_7_pro system-image: system-images;android-33;google_apis_playstore;x86_64 - tag: google_apis_playstore - abi: x86_64 - sdcard-path: sdcard.img install: true - force: true - android/start-emulator: avd-name: Pixel_7_Pro no-window: true From e434b0ab5262a94fdc71a4bfdab851af02a6bb37 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:55:41 +0100 Subject: [PATCH 17/20] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e997f352..de4ebe6a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: From 576569c15ce8cc50a6bac305223a407798ef205f Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Wed, 5 Jun 2024 07:55:13 +0100 Subject: [PATCH 18/20] Update config.yml --- .circleci/config.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index de4ebe6a..16cff964 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ + version: 2.1 orbs: android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -16,9 +16,10 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/create-avd: avd-name: Pixel_7_Pro - system-image: system-images;android-33;google_apis_playstore;x86_64 + system-image: system-images;android-29;google_apis_playstore;x86_64 install: true - android/start-emulator: avd-name: Pixel_7_Pro @@ -27,13 +28,10 @@ jobs: memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - - run: - name: Run Unit Tests - command: ./gradlew testSnapshotDebugUnitTest --info - - run: - name: Run Instrumented Tests - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - timeout: 30m + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - android/save-gradle-cache: cache-prefix: v1 - store_artifacts: @@ -42,12 +40,6 @@ jobs: - store_artifacts: name: Store Test Reports path: services_app/build/reports - - run: - name: Collect ADB Logs - command: adb logcat -d > adb_log.txt - - store_artifacts: - name: Store ADB Logs - path: adb_log.txt build: docker: @@ -61,12 +53,12 @@ jobs: cache-prefix: v1 - run: name: Download Dependencies - command: ./gradlew androidDependencies --info + command: ./gradlew androidDependencies - android/save-gradle-cache: cache-prefix: v1 - run: name: Build Services - command: ./gradlew assembleSnapshotDebug --info + command: ./gradlew assembleSnapshotDebug - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk From e6261d84605cf2d3437c6cf3d1c90eee5d56e5a1 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:30:30 +0100 Subject: [PATCH 19/20] Update config.yml --- .circleci/config.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 16cff964..feab5628 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -13,30 +13,50 @@ jobs: steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew - android/create-avd: avd-name: Pixel_7_Pro - system-image: system-images;android-29;google_apis_playstore;x86_64 + system-image: system-images;android-30;google_apis_playstore;x86_64 install: true + + - run: + name: Start ADB server + command: adb start-server + - android/start-emulator: avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + + - run: + name: Wait for Emulator to be Ready + command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' # Ensures the emulator is fully booted + + - run: + name: Restart ADB server + command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues + - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - android/save-gradle-cache: cache-prefix: v1 + - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results + - store_artifacts: name: Store Test Reports path: services_app/build/reports @@ -44,24 +64,32 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/restore-gradle-cache: cache-prefix: v1 + - run: name: Download Dependencies command: ./gradlew androidDependencies + - android/save-gradle-cache: cache-prefix: v1 + - run: name: Build Services command: ./gradlew assembleSnapshotDebug + - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk + - persist_to_workspace: root: . paths: From 5caf9ff735c323ddf9b7d940be2b212be71ace5b Mon Sep 17 00:00:00 2001 From: stryker101 Date: Mon, 2 Sep 2024 19:24:56 +0100 Subject: [PATCH 20/20] File system test --- .../utilities/ODKFileUtilsTest.java | 106 +++++++++++++++++ .../services/utilities/FileSystemHelper.java | 107 ++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 services_app/src/androidTest/java/org/opendatakit/utilities/ODKFileUtilsTest.java create mode 100644 services_app/src/main/java/org/opendatakit/services/utilities/FileSystemHelper.java diff --git a/services_app/src/androidTest/java/org/opendatakit/utilities/ODKFileUtilsTest.java b/services_app/src/androidTest/java/org/opendatakit/utilities/ODKFileUtilsTest.java new file mode 100644 index 00000000..6f5f476e --- /dev/null +++ b/services_app/src/androidTest/java/org/opendatakit/utilities/ODKFileUtilsTest.java @@ -0,0 +1,106 @@ +package org.opendatakit.utilities; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.os.Environment; +import android.provider.MediaStore; + +import androidx.test.core.app.ApplicationProvider; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.rule.GrantPermissionRule; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.opendatakit.services.utilities.FileSystemHelper; + +@RunWith(AndroidJUnit4.class) +public class ODKFileUtilsTest { + + private static final String ODK_FOLDER_NAME = "opendatakit"; + private FileSystemHelper fileSystemHelper; + private Context context; + + @Rule + public GrantPermissionRule permissionRule = GrantPermissionRule.grant(android.Manifest.permission.WRITE_EXTERNAL_STORAGE); + + @Before + public void setUp() { + context = ApplicationProvider.getApplicationContext(); + fileSystemHelper = new FileSystemHelper(context); + } + + @Test + public void testCreateDirectory() { + String folderName = "testFolder"; + String relativePath = Environment.DIRECTORY_DOCUMENTS + "/" + ODK_FOLDER_NAME + "/" + folderName; + + Uri directoryUri = fileSystemHelper.getFolderUri(relativePath); + if (directoryUri == null) { + directoryUri = fileSystemHelper.createDirectory(relativePath); + } + assertNotNull("Directory URI should not be null after creation", directoryUri); + + Uri externalUri = MediaStore.Files.getContentUri("external"); + String[] projection = {MediaStore.Files.FileColumns.RELATIVE_PATH}; + String selection = MediaStore.Files.FileColumns.RELATIVE_PATH + "=?"; + String[] selectionArgs = {relativePath + "/"}; + try (Cursor cursor = context.getContentResolver().query(externalUri, projection, selection, selectionArgs, null)) { + boolean directoryExists = cursor != null && cursor.getCount() > 0; + assertTrue("Directory should exist after creation", directoryExists); + } + } + + @Test + public void testGetOdkFolderUri() { + Uri resultUri = fileSystemHelper.getOdkFolder(); + assertNotNull(resultUri); + String[] projection = {MediaStore.MediaColumns.RELATIVE_PATH}; + String selection = MediaStore.MediaColumns.RELATIVE_PATH + "=?"; + String[] selectionArgs = {Environment.DIRECTORY_DOCUMENTS + "/" + ODK_FOLDER_NAME + "/"}; + + Cursor cursor = context.getContentResolver().query( + MediaStore.Files.getContentUri("external"), + projection, + selection, + selectionArgs, + null + ); + assertNotNull(cursor); + assertTrue(cursor.getCount() > 0); + cursor.close(); + } + + + @Test + public void testAssertDirectoryStructure() { + String appName = ODK_FOLDER_NAME; + + try { + fileSystemHelper.assertDirectoryStructure(appName); + } catch (Exception e) { + fail("Exception thrown while asserting directory structure: " + e.getMessage()); + } + + String[] folderNames = {"config", "data", "output", "system", "permanent"}; + for (String folderName : folderNames) { + String relativePath = Environment.DIRECTORY_DOCUMENTS + "/" + appName + "/" + folderName; + + Uri folderUri = fileSystemHelper.getFolderUri(relativePath); + assertNotNull("Folder " + folderName + " does not exist", folderUri); + +// Uri nomediaUri = fileSystemHelper.getFileUri(relativePath, ".nomedia"); +// assertNotNull(".nomedia file does not exist in folder " + folderName, nomediaUri); + } + } + + +} + + diff --git a/services_app/src/main/java/org/opendatakit/services/utilities/FileSystemHelper.java b/services_app/src/main/java/org/opendatakit/services/utilities/FileSystemHelper.java new file mode 100644 index 00000000..dd7a9f15 --- /dev/null +++ b/services_app/src/main/java/org/opendatakit/services/utilities/FileSystemHelper.java @@ -0,0 +1,107 @@ +package org.opendatakit.services.utilities; + +import android.content.ContentUris; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.os.Environment; +import android.provider.DocumentsContract; +import android.provider.MediaStore; + +public class FileSystemHelper { + private static final String ODK_FOLDER_NAME = "opendatakit"; + private final Context context; + + public FileSystemHelper(Context context) { + this.context = context; + } + + public Uri getOdkFolder() { + ContentValues values = new ContentValues(); + values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS + "/" + ODK_FOLDER_NAME); + Uri folderUri = context.getContentResolver().insert(MediaStore.Files.getContentUri("external"), values); + return folderUri; + } + + public void assertDirectoryStructure(String appName) { + String[] folderNames = {"config", "data", "output", "system", "permanent"}; + + // Create each directory and check for existence + for (String folderName : folderNames) { + String relativePath = Environment.DIRECTORY_DOCUMENTS + "/" + appName + "/" + folderName; + if (getFolderUri(relativePath) == null) { + createDirectory(relativePath); + } + + // Ensure .nomedia file is created inside each folder + String nomediaFilePath = relativePath; + if (getFileUri(nomediaFilePath, ".nomedia") == null) { + createNomediaFile(nomediaFilePath); + } + } + } + + // Helper method to create a .nomedia file inside a specific directory + private void createNomediaFile(String relativePath) { + ContentValues values = new ContentValues(); + values.put(MediaStore.MediaColumns.DISPLAY_NAME, ".nomedia"); + values.put(MediaStore.MediaColumns.RELATIVE_PATH, relativePath + "/"); + values.put(MediaStore.MediaColumns.MIME_TYPE, "application/octet-stream"); // MIME type for generic binary data + + context.getContentResolver().insert(MediaStore.Files.getContentUri("external"), values); + } + + // Helper method to create a directory using MediaStore + public Uri createDirectory(String relativePath) { + ContentValues values = new ContentValues(); + values.put(MediaStore.MediaColumns.DISPLAY_NAME, relativePath.substring(relativePath.lastIndexOf("/") + 1)); // Directory name + values.put(MediaStore.MediaColumns.RELATIVE_PATH, relativePath); + values.put(MediaStore.MediaColumns.MIME_TYPE, DocumentsContract.Document.MIME_TYPE_DIR); // MIME type for a directory + + return context.getContentResolver().insert(MediaStore.Files.getContentUri("external"), values); + } + + // Helper method to get the folder Uri using MediaStore + public Uri getFolderUri(String relativePath) { + String[] projection = {MediaStore.MediaColumns._ID}; + String selection = MediaStore.MediaColumns.RELATIVE_PATH + "=?"; + String[] selectionArgs = {relativePath + "/"}; + + try (Cursor cursor = context.getContentResolver().query( + MediaStore.Files.getContentUri("external"), + projection, + selection, + selectionArgs, + null + )) { + if (cursor != null && cursor.moveToFirst()) { + long id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns._ID)); + return ContentUris.withAppendedId(MediaStore.Files.getContentUri("external"), id); + } + } + return null; + } + + // Helper method to get the file Uri using MediaStore + public Uri getFileUri(String relativePath, String fileName) { + String[] projection = {MediaStore.MediaColumns._ID}; + String selection = MediaStore.MediaColumns.RELATIVE_PATH + "=? AND " + MediaStore.MediaColumns.DISPLAY_NAME + "=?"; + String[] selectionArgs = {relativePath + "/", fileName}; + + try (Cursor cursor = context.getContentResolver().query( + MediaStore.Files.getContentUri("external"), + projection, + selection, + selectionArgs, + null + )) { + if (cursor != null && cursor.moveToFirst()) { + long id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns._ID)); + return ContentUris.withAppendedId(MediaStore.Files.getContentUri("external"), id); + } + } + return null; + } + +}