GitHub Actions on Android project

Introduction

I’m a big CI enthusiast who tries to keep abreast of changes and evolution of different CI services. This post describes how I configured GitHub Actions on Android project and first impressions about this service.

I’m coming from Android development background. CI’s I analyze/use are also with main focus on the Android platform. A few years back I’ve created a ci-matters repository on GitHub. It is a showcase of Android project’s tasks automation (build, test, distribute) on different CI services. And the time has come for GitHub Actions.

GitHub Actions

GitHub Actions were announced in October 2018 as a public beta feature available to a limited amount of people.
Notice from https://developer.github.com/actions

Note: GitHub Actions are currently available as a limited public beta, which means you should avoid using it for high-value workflows and content during this beta period. Creating workflows that use GitHub Actions is limited to private repositories and push events in public repositories during the limited public beta. Features and requirements may change at any time during this period. You can request to join the limited public beta on the GitHub Actions page. If you’re participating in the beta, please contact support if you have any questions.

GitHub Actions is an online CI service from GitHub that makes use of Docker container images to automate various tasks. I’m not going to describe here all the little details about what GitHub Actions are and how to create very first Action. Actions documentation is very intuitive and should not take more than 30-60 minutes to get familiar with and start using.

I just wanted to try GitHub Actions on the Android project and see how ready is this service for such projects.

GitHub Actions on Android project

I’ve configured GitHub Actions on ci-matters project (see GITHUB_ACTIONS.md) and automated following tasks:

  • build project
  • run unit tests and generate a code coverage report
  • run code quality checks
  • run UI tests on Android emulator
  • distribute application to fabric.io
  • publish code coverage report to coveralls.io

Final Actions workflow looks like this:

workflow "Build, Test and Distribute" {
  on = "push"
  resolves = "Publish Code Coverage"
}

action "Build" {
  uses = "vgaidarji/android-github-actions/build@v1.0.0"
  secrets = ["FABRIC_API_KEY", "FABRIC_API_SECRET"]
  args = "./gradlew assembleDebug -PpreDexEnable=false"
}

action "Check" {
  needs = ["Build"]
  uses = "vgaidarji/android-github-actions/build@v1.0.0"
  secrets = ["FABRIC_API_KEY", "FABRIC_API_SECRET"]
  args = "./gradlew testDebug jacocoTestReport checkstyle pmd jdepend lintDebug buildDashboard -PpreDexEnable=false"
}

action "Run UI Tests" {
  needs = ["Build"]
  secrets = ["FABRIC_API_KEY", "FABRIC_API_SECRET"]
  uses = "vgaidarji/android-github-actions/emulator@v1.0.0"
}

action "Distribute" {
  needs = ["Check", "Run UI Tests"]
  uses = "vgaidarji/android-github-actions/build@v1.0.0"
  secrets = ["FABRIC_API_KEY", "FABRIC_API_SECRET"]
  args = "./gradlew crashlyticsUploadDistributionDebug -PpreDexEnable=false"
}

action "Publish Code Coverage" {
  needs = ["Distribute"]
  uses = "vgaidarji/android-github-actions/build@v1.0.0"
  secrets = ["COVERALLS_REPO_TOKEN"]
  args = "./gradlew coveralls -PpreDexEnable=false"
}

Core components of this workflow are “build action”, “emulator action”, “environment variables”.

Android build action
GitHub Action for building and running Gradle tasks (see vgaidarji/android-github-actions/build).

Android emulator action
GitHub Action for running UI tests (see vgaidarji/android-github-actions/emulator).

Secret environment variables
Secret environment variables, which are required by Gradle tasks executed when action runs (see help article from GitHub).

Actions dependencies
Action dependencies are defined using special keyword needs and form following execution graph:

            Build
     Check          Run UI Tests
          Distribute
     Publish Code Coverage    

And successul build looks like this: GitHub Actions successful build

First impression

  • gentle learning curve if you’re familiar with Docker
  • code + CI in one place (GitHub)
  • free (forever?)
  • ability to create environment variables
  • visual workflow with UI editor
  • containers caching reduces build times
  • ability to host actions inside the project on GitHub and automate custom steps
  • evolving list of actions (awesome-actions & GitHub)

  • debugging is hard. No way to debug locally, just commit -> push -> wait
  • no access to logs when build is running
  • no visual reports, pure logs

I enjoyed the experience of GitHub Actions and looking forward to automating more actions on non-Android projects.


Resources

comments powered by Disqus