Android test reporting with Github Actions

The tutorial shows how to retrieve Android Lint and Unit Tests output files results from GitHub actions. When we run Gradle tasks locally the results files reports get store locally in our machine, and when we run Gradle tasks on GitHub Actions (they run on remote machines). To retrieve the test results reports we need to add the Action Upload-artifact. With this action we upload the output build files to GitHub Artifacts.

Example android.yml file:

jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Unit tests
run: bash ./gradlew test --stacktrace
- name: Unit tests results
uses: actions/upload-artifact@v1
with:
name: unit-tests-results
path: app/build/reports/tests/testDebugUnitTest/index.html


lint:
name: Lint Check
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Lint debug flavor
run: bash ./gradlew lintDebug --stacktrace
- name: Lint results
uses: actions/upload-artifact@v1
with:
name: app
path: app/build/reports/lint-results-debug.html

Here is the main logic:

- name: Unit tests results (name)
uses: actions/upload-artifact@v1 (Action upload-artifact)
with:
name: unit-tests-results (Artifacts zip file name)
path: app/build/reports/tests/testDebugUnitTest/index.html (file path to upload)

After the GitHub Action runs you will get the Artifacts results on the top right:

Top right corner shows results artifacts

You need to download the zip file and inside you will find the html results report. It would be nice if we could see the html reports without downloading the zip file.

Code example:

Thanks for spending your time reading it and let me know if I’m wrong somewhere or if there’s something that could do differently or better. I’m open to your feedback 🙌🏻 -Andres

Questions for GitHub team

Do the zip files get deleted at some point?

Limited data storage.

How much is to run GitHub Actions that store data?

software engineer, read, swim, travel. apps: https://goo.gl/rDuuQw https://goo.gl/15GvfE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store