Skip to content

feat: custom key for cache - #182

Merged
amyu merged 1 commit into
amyu:mainfrom
wtto00:cache-key
Oct 2, 2023
Merged

amyu merged 1 commit into
amyu:mainfrom
wtto00:cache-key

Conversation

@wtto00

@wtto00 wtto00 commented Oct 2, 2023

Copy link
Copy Markdown
Contributor

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
Comment thread package.json
"scripts": {
"postinstall": "patch-package",
"build": "tsc",
"format": "prettier --write '**/*.ts'",

Copy link
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍 👍 👍 👍 👍 👍

Copy link
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks reformat!

@amyu amyu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

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

test_custom_cache_key:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍 👍

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks reformat!

Comment thread README.md

# 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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread action.yml
cache-key:
required: false
description: 'cache key'
default: ''

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍 👍

Comment thread package.json
"scripts": {
"postinstall": "patch-package",
"build": "tsc",
"format": "prettier --write '**/*.ts'",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍 👍 👍 👍 👍 👍

Comment thread package.json
{
"name": "setup-android",
"version": "2",
"version": "3",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍 👍 👍 👍 👍 👍 👍 👍

@amyu

amyu commented Oct 2, 2023

Copy link
Copy Markdown
Owner

I will release soon and include v3.
Thanks @wtto00

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

amyu commented Oct 2, 2023

Copy link
Copy Markdown
Owner

@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