diff --git a/.circleci/config.yml b/.circleci/config.yml index ff77153..d5a6ae2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,34 +20,29 @@ commands: git config --global user.email "$GIT_EMAIL" git config --global user.name "$GIT_EMAIL" git subtree add --prefix=driver_app_data https://github.com/hmalik144/driver_app_data main - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - run: - name: Chmod permissions - command: sudo chmod +x ./gradlew + - android/restore-gradle-cache - run: name: Download Dependencies - command: ./gradlew androidDependencies - - save_cache: - paths: - - ~/.gradle - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - + command: | + sudo chmod +x ./gradlew + ./gradlew androidDependencies # Setup files for build. - run: name: Setup variables for build command: | echo "$GOOGLE_SERVICES_KEY" > "app/google-services.json" run_tests: - description: run tests for flavour specified + description: run non-instrumentation tests for flavour specified parameters: flavour: type: string default: "Driver" steps: # The next step will run the unit tests - - android/run-tests: - test-command: ./gradlew test<< parameters.flavour >>DebugUnitTest --continue + - run: + name: Run non-instrumentation unit tests + command: | + ./gradlew test<< parameters.flavour >>DebugUnitTest --continue - store_artifacts: path: app/build/reports destination: reports @@ -69,39 +64,35 @@ commands: name: Install firebase tools command: | curl -sL firebase.tools | bash - # Save cache for firebase tools - - save_cache: - paths: - - .firebase/emulator - - ~/.cache/firebase/emulators/ - key: emulator-cache-v1-{{ epoch }} - # Then start firebase emulator in the background - - run: - name: Start firebase emulator - command: | - firebase emulators:start --import=driver_app_data/export_directory - background: true # Then start the emulator and run the Instrumentation tests! - android/start-emulator-and-run-tests: post-emulator-launch-assemble-command: ./gradlew assemble<< parameters.flavour >>DebugAndroidTest test-command: ./gradlew connected<< parameters.flavour >>DebugAndroidTest system-image: system-images;android-25;google_apis;x86 - max-tries: 1 - kill-emulators: false - - run: - name: Pull screenshots from device - command: | - mkdir ~/screenshots - adb pull /storage/emulated/0/Android/data/h_mal.appttude.com.driver.admin/files/screengrab/en-US/images/screenshots ~/screenshots - when: on_fail + pull-data: true + pull-data-path: /storage/emulated/0/Android/data/ + pull-data-target: ~/app-data + pre-emulator-wait-steps: + # Start firebase emulator in the background while waiting to start testing + - run: + name: Start firebase emulator and while avd starts + command: | + firebase emulators:start --import=driver_app_data/export_directory + background: true + post-run-tests-steps: + # Save cache for firebase tools + - save_cache: + paths: + - ~/.cache/firebase/emulators/ + key: emulator-cache-v1-{{ epoch }} # store test reports - store_artifacts: path: app/build/reports/androidTests/connected destination: reports # store screenshots for failed ui tests - store_artifacts: - path: ~/screenshots - destination: screenshots + path: ~/app-data + destination: data # Then publish the artifacts of the Firebase emulator logs! - run: name: save firebase emulator logs @@ -138,29 +129,6 @@ jobs: flavour: << parameters.flavour >> - run_ui_tests: flavour: << parameters.flavour >> - # Assemble - assemble-and-release: - # Parameters used for determining - parameters: - flavour: - type: string - default: "Driver" - executor: - name: android/android-machine - tag: 2023.05.1 - steps: - - setup_repo - - run: - name: Setup variables for release - command: | - echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > "android/app/release_keystore.jks" - echo "$GOOGLE_PLAY_KEY" > "android/playstore.json" - # And finally run the release build - - run: - name: Assemble and Upload to PlayStore - command: | - pwd - bundle exec fastlane deploy<< parameters.flavour >> # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: @@ -169,22 +137,29 @@ workflows: jobs: - build-and-test: flavour: "Driver" - - assemble-and-release: - flavour: "Driver" + - android/deploy-to-play-store: filters: branches: only: - main_driver requires: - build-and-test + executor: + name: android/android-machine + tag: 2023.05.1 + lane-name: deployDriver build-release-admin: jobs: - build-and-test: flavour: "Admin" - - assemble-and-release: - flavour: "Admin" + - android/deploy-to-play-store: filters: branches: - only: main_admin + only: + - main_driver requires: - - build-and-test \ No newline at end of file + - build-and-test + executor: + name: android/android-machine + tag: 2023.05.1 + lane-name: deployAdmin \ No newline at end of file diff --git a/.gitignore b/.gitignore index ddc23c1..ab59a65 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,8 @@ local /.circleci/run_local.bash # Gem/fastlane /Gemfile.lock -/playstore.json +/google-play-key.json +/app/google-services.json /fastlane/report.xml # Firebase emulator database-debug.log diff --git a/app/build.gradle b/app/build.gradle index 96aa532..7a793a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,6 @@ plugins { def relStorePassword = System.getenv("RELEASE_STORE_PASSWORD") def relKeyPassword = System.getenv("RELEASE_KEY_PASSWORD") def relKeyAlias = System.getenv("RELEASE_KEY_ALIAS") -def relStoreFile = System.getenv("RELEASE_KEYSTORE") android { compileSdkVersion 31 @@ -41,7 +40,7 @@ android { storePassword relStorePassword keyPassword relKeyPassword keyAlias relKeyAlias - storeFile file(relStoreFile) + storeFile file('./keystore') } } diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 16b123d..a1ade16 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -33,12 +33,12 @@ platform :android do desc "Deploy a new version of Driver to the Google Play" lane :deployDriver do gradle(task: "clean bundle", flavor: "driver", build_type: "Release") - upload_to_play_store(aab: "app/build/outputs/bundle/driverRelease/app-driver-release.aab", json_key: "playstore.json", package_name: "h_mal.appttude.com.driver") + upload_to_play_store(aab: "app/build/outputs/bundle/driverRelease/app-driver-release.aab", json_key: "google-play-key.json", package_name: "h_mal.appttude.com.driver") end desc "Deploy a new version of Admin to the Google Play" lane :deployAdmin do gradle(task: "clean bundle", flavor: "admin", build_type: "Release") - upload_to_play_store(aab: "app/build/outputs/bundle/adminRelease/app-admin-release.aab", json_key: "playstore.json", package_name: "h_mal.appttude.com.driver.admin") + upload_to_play_store(aab: "app/build/outputs/bundle/adminRelease/app-admin-release.aab", json_key: "google-play-key.json", package_name: "h_mal.appttude.com.driver.admin") end end diff --git a/gradle.properties b/gradle.properties index 7bbba6a..e781d7a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,7 @@ org.gradle.jvmargs=-Xmx1536m android.useAndroidX=true android.enableJetifier=true kotlin.code.style=official +org.gradle.caching=true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/gradlew b/gradlew old mode 100644 new mode 100755