roughly Testing Github Actions workflows for Android domestically with Docker | by Lukasz Kalnik | Dec, 2022 will lid the newest and most present advice practically the world. admission slowly consequently you comprehend with out issue and appropriately. will accrual your data adroitly and reliably

When modifying your Github Actions workflows, it might be good to have the power to check them domestically so you might have a fast suggestions loop if one thing breaks. In any other case, it’s a must to look forward to Github Actions to execute the motion (which within the case of dash builds or Play Retailer launch builds might not occur for weeks) solely to later understand that the modified workflow has an error. and it does not run when it is wanted most. .

That is potential utilizing Docker and an area motion runner referred to as act.

The next information is designed particularly for testing Android app workflows on a Mac, however it ought to be straightforward sufficient to adapt to different platforms.

  1. Obtain and set up Docker Desktop
  2. Set up act:
brew set up act

Act runs its workflows by default from the .github/workflows listing. Which means you have to run act from the foundation listing of your challenge.

Nonetheless, act does not know something about your project-specific Github atmosphere variables, challenge secrets and techniques, or the Android SDK you are utilizing to construct your challenge. So first it’s a must to put together your challenge.

Configure the Android SDK

Because the Act Docker picture doesn’t include an Android SDK pre-installed, you possibly can work round this by briefly including the setup-android motion to your workflow. .yml proceedings.

Simply add the 2 traces to your workflow (be sure to do not commit them as your Github Actions runners in all probability have already got the Android SDK pre-installed):

- title: Setup Android SDK
makes use of: android-actions/[email protected]

Set ANDROID_HOME

Sadly, the setup-android motion doesn’t set the ANDROID_HOME atmosphere variable robotically.

To do it your self, you possibly can create a .env file within the root folder of your challenge that may comprise your atmosphere variables.

The file ought to comprise the next line:

ANDROID_HOME=/root/.android/sdk

Bear in mind so as to add the .env file to your .gitignoresince it is just wanted domestically.

Configure challenge secrets and techniques

Github Actions workflows typically require the GITHUB_TOKEN and different secrets and techniques associated to the challenge (for instance, PACKAGES_READ_TOKENcompletely different API keys your utility makes use of, and so forth.).

You’ll be able to configure all of the secrets and techniques of your challenge inside a .secrets and techniques file within the root folder of your challenge.

IMPORTANT: Make sure to add the .secrets and techniques file to .gitignoresince your secrets and techniques ought to by no means be pushed and posted to Github!

to generate aGITHUB_TOKEN both PACKAGES_READ_TOKEN It is advisable go to your Github Developer Settings, generate a brand new private entry token, copy it, and be sure to’ve licensed the token to entry the related group your repository lives in (if crucial).

Then contained in the .secrets and techniques file you possibly can add your secrets and techniques like this:

GITHUB_TOKEN=your_generated_token
PACKAGES_READ_TOKEN=your_generated_token

NOTE: in case you outline in your challenge any string variable, which then turns into your construct.gradle.kts recordsdata in BuildConfig fields, you need to enclose them in quotes internal escapes " after which once more in outer quotes " like this:

SOME_API_KEY=""your_api_key""

That is as a result of approach BuildConfig discipline era works for strings.

To run the actions, first open the terminal and alter the present listing to the foundation listing of your challenge.

If you don’t specify in any other case, act will dispatch the push occasion to set off your workflows. It’s also possible to ship different occasions; see extra choices.

Operating utilizing the artifact server

if you’re utilizing actions/upload-artifact both actions/download-artifact in your workflow, you have to create an area listing in your laptop, which can be used for a mock artifact server:

mkdir /tmp/artifacts

after which go this listing to behave utilizing the parameter --artifact-server-path :

act --artifact-server-path /tmp/artifacts

This can run the workflows in your challenge and ship all of the artifacts to the required listing, the place you possibly can examine them later.

Operating with out an artifact server

Simply go to your challenge and run

act

That’s all! Comfortable to check your workflows!

I want the article nearly Testing Github Actions workflows for Android domestically with Docker | by Lukasz Kalnik | Dec, 2022 provides perspicacity to you and is helpful for depend to your data

Testing Github Actions workflows for Android locally with Docker | by Lukasz Kalnik | Dec, 2022

By admin

x