read

You can setup your own CI server with real devices on gitlab with these scripts and setups. I found this issues that are common between any CI server:

  • Copy env/secret variables to local project before each run.
  • Run commands on every device connected.
  • Run tests with test coverage and see it inside gitlab-ci.
  • Install app dependencies before each run if needed.
  • You need to setup (How to) your gitlab runner executor to shell to make it run processes “natively” instead of start a new Docker instance for every test.

1. Gitlab will run everything you put in .gitlab-ci.yml, check this sample:

  • I use spoon to run UI tests, update the gradle task in case you use another thing.
  • All scripts in scripts/ will be explained in 3. .

2. Android project setup:

  • Setup code coverage, tests and spoon:

  • Setup jacoco tasks to generate code coverage files:

  • Setup tests to print each test result (to see in the job results which ones failed)

3. Usefull scripts:

  • Install your project dependencies on the machine by terminal:

  • Run the same command on every connected device (avoid INSTALL_FAILED_UPDATE_INCOMPATIBLE)

  • Copy every env/secret variable into gradle.propertes file inside the project (gmaps key or something like that)

NOTE: you can use System.getenv("VAR_NAME") in your gradle files if you dont need a local .properties file for your project. (thanks to reddit/Atraac)

Gitlab-ci Advantages:

  • “Free” testing farm (your own devices, maybe uncle/grandmother/mom old devices).
  • “Free” Parallel Job Executions based on your machine (you can setup your gitlab-ci runner to allow this).
  • “Secure” handling of signing keys (it depends to you).
  • “Secure” handling of services config keys (like google console config jsons).
  • Fastest test/build/everything jobs since gradle daemon can run in your machine (on CircleCi/Travis/Etc you need to disable it since they start a new virtual machine for every test).

Links

Now enjoy a happy android dev :)

Blog Logo

Daniel Gomez Rico


Published

Image

MakinGIANTS

The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview