-
Notifications
You must be signed in to change notification settings - Fork 628
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
test.yml: use image cache with parameters created from template #2508
Merged
AkihiroSuda
merged 4 commits into
lima-vm:master
from
norio-nomura:ci-use-digest-of-image-in-template-as-key-for-cache
Aug 30, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cd30aaa
test.yml: use image cache with parameters created from template
norio-nomura 99c1247
setup_cache_for_template: Improve caching mechanism for images and `n…
norio-nomura f8acc9d
calculate-cache.sh: calculate cache size usage for new caching method…
norio-nomura 5058106
setup_cache_for_template: add `kernel` and `initrd` cache support
norio-nomura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: 'setup cache for template' | ||
description: 'setup cache for template' | ||
inputs: | ||
arch: | ||
description: arch to setup cache for | ||
required: false | ||
template: | ||
description: template yaml file | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "detect platform for download directory" | ||
id: detect-platform | ||
run: | | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
download_dir=~/Library/Caches/lima/download | ||
else | ||
download_dir=~/.cache/lima/download | ||
fi | ||
echo "download-dir=$download_dir" >> "$GITHUB_OUTPUT" | ||
shell: bash | ||
- name: "create cache parameters from template" | ||
if: always() | ||
id: cache-params-from-template | ||
run: | | ||
set -eux | ||
source hack/cache-common-inc.sh | ||
print_cache_informations_from_template "${{ inputs.template }}" "${{ inputs.arch }}" >> "$GITHUB_OUTPUT" | ||
shell: bash | ||
|
||
- name: "Cache ${{ steps.cache-params-from-template.outputs.image-path }}" | ||
if: ${{ steps.cache-params-from-template.outputs.image-key != '' }} | ||
# avoid using `~` in path that will be expanded to platform specific home directory | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.cache-params-from-template.outputs.image-path }} | ||
key: ${{ steps.cache-params-from-template.outputs.image-key }} | ||
enableCrossOsArchive: true | ||
|
||
- name: "Cache ${{ steps.cache-params-from-template.outputs.kernel-path }}" | ||
if: ${{ steps.cache-params-from-template.outputs.kernel-key != '' }} | ||
# avoid using `~` in path that will be expanded to platform specific home directory | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.cache-params-from-template.outputs.kernel-path }} | ||
key: ${{ steps.cache-params-from-template.outputs.kernel-key }} | ||
enableCrossOsArchive: true | ||
|
||
- name: "Cache ${{ steps.cache-params-from-template.outputs.initrd-path }}" | ||
if: ${{ steps.cache-params-from-template.outputs.initrd-key != '' }} | ||
# avoid using `~` in path that will be expanded to platform specific home directory | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.cache-params-from-template.outputs.initrd-path }} | ||
key: ${{ steps.cache-params-from-template.outputs.initrd-key }} | ||
enableCrossOsArchive: true | ||
|
||
- name: "Cache ${{ steps.cache-params-from-template.outputs.containerd-key }}" | ||
if: ${{ steps.cache-params-from-template.outputs.containerd-key != '' }} | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.cache-params-from-template.outputs.containerd-path }} | ||
key: ${{ steps.cache-params-from-template.outputs.containerd-key }} | ||
enableCrossOsArchive: true | ||
|
||
- name: "Create symbolic link named ${{ steps.detect-platform.outputs.download-dir }} pointing to .download" | ||
run: | | ||
set -eux | ||
[ -d .download ] || mkdir -p .download | ||
path_to_cache=${{ steps.detect-platform.outputs.download-dir }} | ||
mkdir -p "$(dirname "$path_to_cache")" | ||
ln -sfn "$PWD/.download" "$path_to_cache" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your dedicated work. Is it possible to measure how much we are saving by implementing caching in this GitHub Action workflow?
We need to understand the benefits we will receive if we merge this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer the question, I created a script to calculate the cache size usage and committed it at 9bb92f3.
Running the script produces the following output:
It appears that the cache is stored in a compressed format, so the actual cache size is somewhat smaller than the size of the downloaded content. However, I believe the results are generally accurate and this should answer the question.
During the process of creating this response, several improvements were made to utilize the cache more efficiently. Thank you for the question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased on master(6c2bfaa).
Following is output of
hack/calculate-cache.sh
Judging from this output, I believe the cache size calculations prior to this PR are generally accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Latest output of
calculate-cach.sh
: