My Workflow
As most Android Developers know, an Android Project may have many
different modules.
If you change one single module and submit a Pull Request, most CI workflows will try to build/test all the existing modules, which might take a lot of time, when in reality you only need to build the module you changed.
This GitHub Action aims to solve that problem. When you submit a Pull Request, it will only build the module you changed,or no module at all if you left them untouched (in case of documentation or configuration changes).
Real Project Showcase
Take a look at this project I forked: quickstart-android. It contains many different modules (admob, analytics, database, etc).
I made a change to the database module and sent a Pull Request:
refactor(database): make a demo change for the Github Actions Hackathon #11
I'm hoping that this PR will only build the database
module, since that's the only change I made.
GitHub Actions built the database
module only and finished in 4m 40s, as seen in the log.
Building the whole project generally takes around 17min, as seen in this log.
Submission Category:
Phone Friendly
Yaml File or Link to Code
rosariopfernandes / modular-android-action
GitHub Actions to selectively build PRs on multi-module Android Projects
Github Actions for Modular Android Projects
As most Android Developers know, an Android Project may have many different modules.
If you change one single module and submit a Pull Request, most CI workflows will try to build/test all the existing modules, which might take a lot of time, when in reality you only need to build the module you changed.
This GitHub Action aims to solve that problem. When you submit a Pull Request, it will only build the module you changed or no module at all if you left them untouched (in case of documentation or configuration changes).
Usage
Add it to your workflow YAML like this:
- name: Build with Modular Action
uses: rosariopfernandes/modular-android-action@v0.2.0
with
for-each-module: 'assembleDebug'
for-all-modules: 'check'
As you can see, it takes 2 arguments:
-
for-each-module
- gradle task to run for each module. -
for-all-modules
- gradle…
Additional Resources / Info
- Inspired by the blog post "Selectively running Android modularized unit tests on your CI server" by Joe Birch.
- I've previously written a blog post describing how I adapted Joe's code for GitHub Actions.
- The Projects bellow are already using this workflow:
Top comments (0)