react-native-circleci-orb icon indicating copy to clipboard operation
react-native-circleci-orb copied to clipboard

Improve Build Android APK step

Open compojoom opened this issue 4 years ago • 1 comments

Currently the Build Android APK step looks like this:

  - run:
      name: Build Android APK
      command: "cd <<parameters.project_path>> && chmod +x gradlew && ./gradlew --build-cache --max-workers 2 --continue assemble<<parameters.build_type>> assembleAndroidTest -DtestBuildType=<<parameters.build_type>> --stacktrace"

In our project we have 3 flavors(develop, staging, production) and 2 build types (debug and release). if I assemble the app with

gradlew assembleRelease assembleAndroidTest -DtestBuildType=release

gradlew will build all 3 flavors in release type. and it will also build all 3 flavors for androidTest in release type. This takes around 10mins on my machine and a little longer on circleci.

To speed this up we are generally only building specific build variants DevelopDebug, DevelopRelease etc. To build a detox build we would do:

./gradlew assembleDevelopRelease assembleDevelopReleaseAndroidTest -DtestBuildType=release

this way we only generate developRlease androidTest/developRelease - this is 3 times faster as we generate 3 times less apks that we don't need.

Because of that I would like to propose different job parameters: assemble_build_type, assemble_detox_build_type and test_build_type.

This way one could call rn/android_build like this:

      - rn/android_build:
          assemble_build_type: assembleRelease | assembleDevelopRelease | assembleDebug etc
          assemble_detox_build_type: assembleDevelopReleaseAndroidTest | assembleAndroidTest etc
          test_build_type: release etc

It is a breaking change, but it would also allow for greater flexibility of the build step.

compojoom avatar Jan 14 '20 10:01 compojoom

@compojoom Our project also has variants made of flavorBuild (4 flavors and 2 builds so 8 variants). To make this work, I copied over a lot of this orb's code only to change the ./gradlew assemble... shell command to accept our desired variant. Bit of a nuisance, but it seems to be working fine.

m2mathew avatar Sep 11 '20 19:09 m2mathew