Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom key for cache #182

Merged
merged 1 commit into from
Oct 2, 2023
Merged

feat: custom key for cache #182

merged 1 commit into from
Oct 2, 2023

Conversation

wtto00
Copy link
Contributor

@wtto00 wtto00 commented Oct 2, 2023

When the user does not disable the use of cache (cache-disabled:true), the user can customize the cache key.

For example: https://github.com/wtto00/karma-android-launcher/actions/runs/6380253195/workflow

Here I am running 14 tasks simultaneously, and each task will execute the following shell commands:

# Install emulator tool
sdkmanager --install emulator
# The android-31 in each task is different, ranging from android-21 to android-34
sdkmanager --install "system-images;android-31;default;x86_64"
# Create emulator
avdmanager -s create avd -n android_emulator_name -k "system-images;android-31;default;x86_64"
# Start emulator
emulator -avd android_emulator_name -no-window -noaudio

However, all the cache keys for these tasks are the same, so the cache for the 'system-images' I installed is not saved, or only one of them is cached. They will overwrite each other.

In addition, each task will create an emulator, which is a time-consuming task to create and launch the emulator from scratch. If it can be cached, it will be much faster.

If it is possible to customize the cache key, all the data for different tasks can be cached, and the next execution will be much faster. It won't need to download and create the emulator from scratch every time.

@wtto00 wtto00 requested a review from amyu as a code owner October 2, 2023 15:01
"description": "setup-android for self hosted runner",
"main": "dist/setup/index.js",
"scripts": {
"postinstall": "patch-package",
"build": "tsc",
"format": "prettier --write '**/*.ts'",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding quotes, cannot be executed on Windows.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍 👍 👍 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is formatted by prettier

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks reformat!

Copy link
Owner

@amyu amyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!!!!!!!
Perfect code!

@@ -116,3 +116,35 @@ jobs:

- run: |
sdkmanager --install "system-images;android-31;default;x86_64"

test_custom_cache_key:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks reformat!


# default: `${sdkVersion}-${buildToolsVersion}-${ndkVersion}-${cmakeVersion}-v3.1`
# Custom key for cache. It is invalid when `cache-disabled: true`
cache-key: 'custom-cache-key'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

cache-key:
required: false
description: 'cache key'
default: ''
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

"description": "setup-android for self hosted runner",
"main": "dist/setup/index.js",
"scripts": {
"postinstall": "patch-package",
"build": "tsc",
"format": "prettier --write '**/*.ts'",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍 👍 👍 👍

@@ -1,13 +1,13 @@
{
"name": "setup-android",
"version": "2",
"version": "3",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍 👍 👍 👍 👍 👍

@amyu
Copy link
Owner

amyu commented Oct 2, 2023

I will release soon and include v3.
Thanks @wtto00

@amyu amyu merged commit 2fdb21d into amyu:main Oct 2, 2023
@amyu
Copy link
Owner

amyu commented Oct 2, 2023

@wtto00
I released v3.2 that include this change!
https://github.com/amyu/setup-android/releases/tag/v3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants