just about Testing Github Actions workflows for Android regionally with Docker | by Lukasz Kalnik | Dec, 2022 will cowl the most recent and most present counsel happening for the world. learn slowly thus you comprehend with out issue and appropriately. will progress your information proficiently and reliably
When enhancing your Github Actions workflows, it might be good to have the flexibility to check them regionally so you might have a fast suggestions loop if one thing breaks. In any other case, you must watch for 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 would not run when it is wanted most. .
That is doable utilizing Docker and a neighborhood motion runner known as act.
The next information is designed particularly for testing Android app workflows on a Mac, but it surely must be simple sufficient to adapt to different platforms.
- Obtain and set up Docker Desktop
- Set up act:
brew set up act
Act runs its workflows by default from the .github/workflows
listing. Meaning you could run act from the basis listing of your undertaking.
Nonetheless, act would not know something about your project-specific Github setting variables, undertaking secrets and techniques, or the Android SDK you are utilizing to construct your undertaking. So first you must put together your undertaking.
Configure the Android SDK
Because the Act Docker picture doesn’t include an Android SDK pre-installed, you may work round this by quickly including the setup-android motion to your workflow. .yml
proceedings.
Simply add the 2 traces to your workflow (be sure you do not commit them as your Github Actions runners in all probability have already got the Android SDK pre-installed):
- identify: Setup Android SDK
makes use of: android-actions/[email protected]
Set ANDROID_HOME
Sadly, the setup-android motion doesn’t set the ANDROID_HOME
setting variable routinely.
To do it your self, you may create a .env
file within the root folder of your undertaking that can include your setting variables.
The file ought to include the next line:
ANDROID_HOME=/root/.android/sdk
Keep in mind so as to add the .env
file to your .gitignore
since it is just wanted regionally.
Configure undertaking secrets and techniques
Github Actions workflows typically require the GITHUB_TOKEN
and different secrets and techniques associated to the undertaking (for instance, PACKAGES_READ_TOKEN
totally different API keys your software makes use of, and so on.).
You’ll be able to configure all of the secrets and techniques of your undertaking inside a .secrets and techniques
file within the root folder of your undertaking.
IMPORTANT: You’ll want to add the .secrets and techniques
file to .gitignore
since your secrets and techniques ought to by no means be pushed and posted to Github!
to generate aGITHUB_TOKEN
both PACKAGES_READ_TOKEN
You might want to go to your Github Developer Settings, generate a brand new private entry token, copy it, and be sure you’ve approved the token to entry the related group your repository lives in (if needed).
Then contained in the .secrets and techniques
file you may add your secrets and techniques like this:
GITHUB_TOKEN=your_generated_token
PACKAGES_READ_TOKEN=your_generated_token
NOTE: in the event you outline in your undertaking any string variable, which then turns into your construct.gradle.kts
information in BuildConfig
fields, you have to enclose them in quotes inside escapes "
after which once more in outer quotes "
I like this:
SOME_API_KEY=""your_api_key""
That is as a result of approach BuildConfig
area era works for strings.
To run the actions, first open the terminal and alter the present listing to the basis listing of your undertaking.
If you don’t specify in any other case, act will dispatch the push
occasion to set off your workflows. You can too ship different occasions; see extra choices.
Operating utilizing the artifact server
in case you are utilizing actions/upload-artifact
both actions/download-artifact
in your workflow, you could create a neighborhood 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
It will run the workflows in your undertaking and ship all of the artifacts to the desired listing, the place you may examine them later.
Operating with out an artifact server
Simply go to your undertaking and run
act
That is it! Completely satisfied to check your workflows!
I want the article roughly Testing Github Actions workflows for Android regionally with Docker | by Lukasz Kalnik | Dec, 2022 provides notion to you and is helpful for toting as much as your information
Testing Github Actions workflows for Android locally with Docker | by Lukasz Kalnik | Dec, 2022