Files
Driver/.circleci/config.yml
2023-06-27 10:47:12 +01:00

134 lines
4.9 KiB
YAML

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
# For a detailed guide to building and testing on Android, read the docs:
# https://circleci.com/docs/2.0/language-android/ for more details.
version: 2.1
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
# See: https://circleci.com/docs/2.0/orb-intro/
orbs:
android: circleci/android@2.3.0
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
build-and-test:
# Parameters used for determining
parameters:
flavour:
type: string
default: "Driver"
# These next lines define the Android machine image executor.
# See: https://circleci.com/docs/2.0/executor-types/
executor:
name: android/android-machine
tag: 2023.05.1
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
# Checkout the code and its submodule as the first step.
- checkout
# config git user
- run:
name: Setup subtree for test data
command: |
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
# Setup files for build.
- run:
name: Setup variables for build
command: |
echo "$GOOGLE_SERVICES_KEY" > "app/google-services.json"
- run:
name: Grant execute permission for gradlew
command: |
chmod +x gradlew
# The next step will run the unit tests
- android/run-tests:
test-command: ./gradlew test<< parameters.flavour >>DebugUnitTest --continue
# Install Firebase tools needed for firebase emulator
- run:
name: Install firebase tools
command: |
curl -sL firebase.tools | bash
# 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
pull-data: true
pull-data-path: storage/emulated/0/Android/data/h_mal.appttude.com.driver.admin/files/screengrab/en-US/images/screenshots
test-command: ./gradlew connected<< parameters.flavour >>DebugAndroidTest
system-image: system-images;android-25;google_apis;x86
max-tries: 1
# store test reports
- store_artifacts:
path: app/build/reports/androidTests/connected
destination: reports
# Then publish the artifacts of the Firebase emulator logs!
- run:
name: save firebase emulator logs
command: |
mkdir -p tmp/firebase_logs
cp *.log tmp/firebase_logs
- store_artifacts:
path: tmp/firebase_logs
destination: logs
# Then publish the results of the Instrumentation tests!
- store_test_results:
path: app/build/outputs/androidTest-results/connected
# Assemble
assemble-and-release:
# Parameters used for determining
parameters:
flavour:
type: string
default: "Driver"
executor:
name: android/android-machine
tag: 2023.05.1
steps:
- 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:
version: 2
build-release-driver:
jobs:
- build-and-test:
flavour: "Driver"
- assemble-and-release:
flavour: "Driver"
filters:
branches:
only:
- main_driver
requires:
- build-and-test
build-release-admin:
jobs:
- build-and-test:
flavour: "Admin"
- assemble-and-release:
flavour: "Admin"
filters:
branches:
only: main_admin
requires:
- build-and-test