-
Notifications
You must be signed in to change notification settings - Fork 611
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
test.yml: use image cache with parameters created from template #2508
Conversation
d839954
to
ec43bfb
Compare
Some templates download not only images but also Looking at the current cache status, it appears that some caches contain empty directories due to trial and error during the work process. I believe this can be resolved either by deleting the caches or by having the caches recreated when the PR is merged.
|
ec43bfb
to
8a09f1c
Compare
8a09f1c
to
2e32b6f
Compare
Updated to create image caches on a per-directory basis under |
a1050c7
to
47e601f
Compare
It seems the image.location used in hack/test-templates/test-misc.yaml returns 404. - location: "https://cloud-images.ubuntu.com/releases/22.04/release-20220902/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
digest: "sha256:c777670007cc5f132417b9e0bc01367ccfc2a989951ffa225bb1952917c3aa81"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20220902/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"
digest: "sha256:9620f479bd5a6cbf1e805654d41b27f4fc56ef20f916c8331558241734de81ae" https://github.com/lima-vm/lima/actions/runs/10086752926/job/27889808281?pr=2508#step:10:11 |
I created #2513 to checking remote image existence on ci. |
Updated PR description: #2508 (comment) |
47e601f
to
072f9d6
Compare
072f9d6
to
41923ae
Compare
fixed commit message( |
@@ -0,0 +1,88 @@ | |||
name: 'setup cache for template' |
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:
$ hack/calculate-cache.sh
==> expected content size, actual cached size, and cache-keys used in caching method prior implementation in https://github.com/lima-vm/lima/pull/2508
content-size actual-size cache-key
784.84 MiB <<missing>> Linux-1c3b2791d52735d916dc44767c745c2319eb7cae74af71bbf45ddb268f42fc1d
605.53 MiB <<missing>> Linux-231c66957fc2cdb18ea10e63f60770049026e29051ecd6598fc390b60d6a4fa6
74.00 MiB <<missing>> Linux-69a547b760dbf1650007ed541408474237bc611704077214adcac292de556444
554.60 MiB <<missing>> Linux-710b470b49a6cc49e1ef9cb911e6e749311dc44bb6a9c29493ffe97a21c9abd5
474.86 MiB <<missing>> Linux-7782f8b4ff8cd378377eb79f8d61c9559b94bbd0c11d19eb380ee7bda19af04e
723.24 MiB <<missing>> Linux-a1122da40e693040c8f499d00dd9b8634eb070648e543de6436e24ef8f149067
453.00 MiB <<missing>> Linux-ad6e29b3057a13dfd0cac759735d0aac4bb6c9c6aad480f957be363685efb646
784.84 MiB 774.10 MiB Linux-de83bce0608d787e3c68c7a31c5fab2b6d054320fd7bf633a031845e2ee03414
72.00 MiB <<missing>> Linux-f88f0b3b678ff6432386a42bdd27661133c84a36ad29f393da407c871b0143eb
679.46 MiB 669.58 MiB Linux-fb77ce057fac31cb2e2ec5d8c8e9fc6e385a662090373e35a557a3aff7e1d7e4
878.96 MiB <<missing>> macOS-10ad71d670ff0c9a346871f49f665972f8f8f201c47b4dd573e54ae1053ebb63
605.53 MiB <<missing>> macOS-231c66957fc2cdb18ea10e63f60770049026e29051ecd6598fc390b60d6a4fa6
784.84 MiB <<missing>> macOS-8f37f663956af5f743f0f99ab973729b6a02f200ebfac7a3a036eff296550732
679.46 MiB <<missing>> macOS-b3b32541a86504a4206a16a3a8cb27098edb89176bd51f6dd81d2130ef6160ad
679.46 MiB <<missing>> macOS-f174bdf75da4cd402b862784fcafca4fff2e690cab986351201496447ed96bb9
------------
8834.64 MiB
==> expected content size, actual cached size, and cache-keys used in caching method after implementation in https://github.com/lima-vm/lima/pull/2508
content-size actual-size cache-key
226.46 MiB 226.43 MiB containerd:nerdctl-full-1.7.6-linux-amd64.tar.gz-sha256:2c841e097fcfb5a1760bd354b3778cb695b44cd01f9f271c17507dc4a0b25606
496.77 MiB <<missing>> image:Arch-Linux-x86_64-cloudimg.qcow2-url-sha256:f84cefea6f889e36ddc5a7ffc1368a9aa95fd24b4589e1f79aab7ab85325d065
379.06 MiB 377.28 MiB image:Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2-sha256:ac58f3c35b73272d5986fa6d3bc44fd246b45df4c334e99a07b3bbd00684adee
72.00 MiB 65.34 MiB image:alpine-lima-std-3.19.0-x86_64.iso-sha512:568852df405e6b9858e678171a9894c058f483df0b0570c22cf33fc75f349ba6cc5bb3d50188180d8c31faaf53400fe884ca3e5f949961b03b2bf53e65de88d7
74.00 MiB 67.05 MiB image:alpine-lima-std-3.20.0-x86_64.iso-sha512:df013ba0666460c9e303e996e46e061e613ce546124a9de60060041874c702444ac7a90e67f1aed4756b85cc89d40c5ea4375dea62c98b9536ceb44f18874b67
328.14 MiB 320.45 MiB image:debian-12-genericcloud-amd64-20240429-1732.qcow2-sha512:6cc752d71b390c7fea64b0b598225914a7f4adacd4a33fa366187fac01094648628e0681a109ae9320b9a79aba2832f33395fa13154dad636465b7d9cdbed599
248.40 MiB 245.08 MiB image:openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2-url-sha256:713f6146e29554b9092f147652323bc0625a501abccc82dff249e139df8fade3
652.50 MiB 644.52 MiB image:ubuntu-22.04-server-cloudimg-amd64.img-sha256:345fbbb6ec827ca02ec1a1ced90f7d40d3fd345811ba97c5772ac40e951458e1
453.00 MiB 443.15 MiB image:ubuntu-24.04-server-cloudimg-amd64.img-sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3
558.38 MiB 547.64 MiB image:ubuntu-24.04-server-cloudimg-amd64.img-url-sha256:3b6b67faf5fd451e96832cbcaf6f5e04704d2ff7c47e749663508fc2a636130f
------------
3488.72 MiB
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
$ hack/calculate-cache.sh
==> expected content size, actual cached size, and cache-keys used in caching method prior implementation in https://github.com/lima-vm/lima/pull/2508
content-size actual-size cache-key
784.84 MiB 774.11 MiB Linux-1c3b2791d52735d916dc44767c745c2319eb7cae74af71bbf45ddb268f42fc1d
605.53 MiB 603.70 MiB Linux-231c66957fc2cdb18ea10e63f60770049026e29051ecd6598fc390b60d6a4fa6
558.38 MiB 547.67 MiB Linux-3b906d46fa532e3bc348c35fc8e7ede6c69f0b27032046ee2cbb56d4022d1146
74.00 MiB <<missing>> Linux-69a547b760dbf1650007ed541408474237bc611704077214adcac292de556444
474.86 MiB 471.56 MiB Linux-7782f8b4ff8cd378377eb79f8d61c9559b94bbd0c11d19eb380ee7bda19af04e
784.84 MiB 775.04 MiB Linux-8812aedfe81b4456d421645928b493b1f2f88aff04b7f3171207492fd44cd189
723.24 MiB <<missing>> Linux-a1122da40e693040c8f499d00dd9b8634eb070648e543de6436e24ef8f149067
784.84 MiB 774.10 MiB Linux-de83bce0608d787e3c68c7a31c5fab2b6d054320fd7bf633a031845e2ee03414
552.05 MiB 543.28 MiB Linux-eb88a19dfcf2fb98278e7c7e941c143737c6d7cd8950a88f58e04b4ee7cef1bc
72.00 MiB 65.31 MiB Linux-f88f0b3b678ff6432386a42bdd27661133c84a36ad29f393da407c871b0143eb
878.96 MiB <<missing>> macOS-10ad71d670ff0c9a346871f49f665972f8f8f201c47b4dd573e54ae1053ebb63
605.53 MiB 603.68 MiB macOS-231c66957fc2cdb18ea10e63f60770049026e29051ecd6598fc390b60d6a4fa6
784.84 MiB 775.51 MiB macOS-49aa50a4872ded07ebf657c0eaf9e44ecc0c174d033a97c537ecd270f35b462f
784.84 MiB 774.11 MiB macOS-8f37f663956af5f743f0f99ab973729b6a02f200ebfac7a3a036eff296550732
784.84 MiB 775.51 MiB macOS-ef5509b5d4495c8c3590442ee912ad1c9a33f872dc4a29421c524fc1e2103b59
------------
9253.59 MiB
==> expected content size, actual cached size, and cache-keys used in caching method after implementation in https://github.com/lima-vm/lima/pull/2508
content-size actual-size cache-key
226.46 MiB 226.43 MiB containerd:nerdctl-full-1.7.6-linux-amd64.tar.gz-sha256:2c841e097fcfb5a1760bd354b3778cb695b44cd01f9f271c17507dc4a0b25606
496.77 MiB <<missing>> image:Arch-Linux-x86_64-cloudimg.qcow2-url-sha256:f84cefea6f889e36ddc5a7ffc1368a9aa95fd24b4589e1f79aab7ab85325d065
379.06 MiB 377.28 MiB image:Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2-sha256:ac58f3c35b73272d5986fa6d3bc44fd246b45df4c334e99a07b3bbd00684adee
72.00 MiB 65.34 MiB image:alpine-lima-std-3.19.0-x86_64.iso-sha512:568852df405e6b9858e678171a9894c058f483df0b0570c22cf33fc75f349ba6cc5bb3d50188180d8c31faaf53400fe884ca3e5f949961b03b2bf53e65de88d7
74.00 MiB 67.05 MiB image:alpine-lima-std-3.20.0-x86_64.iso-sha512:df013ba0666460c9e303e996e46e061e613ce546124a9de60060041874c702444ac7a90e67f1aed4756b85cc89d40c5ea4375dea62c98b9536ceb44f18874b67
325.58 MiB 317.74 MiB image:debian-12-genericcloud-amd64-20240717-1811.qcow2-sha512:0f0075d53749dba4c9825e606899360626bb20ac6bab3dbdeff40041b051d203eb1a56e68d377c9fac0187faa0aea77fd543ef4a883fff2304eac252cce01b44
248.40 MiB 245.08 MiB image:openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2-url-sha256:713f6146e29554b9092f147652323bc0625a501abccc82dff249e139df8fade3
652.50 MiB 644.52 MiB image:ubuntu-22.04-server-cloudimg-amd64.img-sha256:345fbbb6ec827ca02ec1a1ced90f7d40d3fd345811ba97c5772ac40e951458e1
558.38 MiB 547.64 MiB image:ubuntu-24.04-server-cloudimg-amd64.img-sha256:d2377667ea95222330ca2287817403c85178dad397e9fed768a9b4aec79d2a7f
558.38 MiB 547.64 MiB image:ubuntu-24.04-server-cloudimg-amd64.img-url-sha256:3b6b67faf5fd451e96832cbcaf6f5e04704d2ff7c47e749663508fc2a636130f
------------
3591.53 MiB
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
:
$ hack/calculate-cache.sh
=> compare expected content size, actual cached size, and cache-keys used before and after the change in https://github.com/lima-vm/lima/pull/2508
==> before
content-size actual-size cache-key
785.15 MiB 773.20 MiB Linux-1c3b2791d52735d916dc44767c745c2319eb7cae74af71bbf45ddb268f42fc1d
605.53 MiB 603.71 MiB Linux-231c66957fc2cdb18ea10e63f60770049026e29051ecd6598fc390b60d6a4fa6
558.38 MiB 547.64 MiB Linux-3b906d46fa532e3bc348c35fc8e7ede6c69f0b27032046ee2cbb56d4022d1146
74.00 MiB 67.05 MiB Linux-69a547b760dbf1650007ed541408474237bc611704077214adcac292de556444
474.49 MiB 471.25 MiB Linux-7782f8b4ff8cd378377eb79f8d61c9559b94bbd0c11d19eb380ee7bda19af04e
784.84 MiB 775.08 MiB Linux-8812aedfe81b4456d421645928b493b1f2f88aff04b7f3171207492fd44cd189
723.24 MiB 719.76 MiB Linux-caa7d8af214d55ad8902e82d5918e61573f3d6795d2b5ad9a35305e26fa0e6a9
785.15 MiB 773.14 MiB Linux-de83bce0608d787e3c68c7a31c5fab2b6d054320fd7bf633a031845e2ee03414
552.05 MiB 544.19 MiB Linux-eb88a19dfcf2fb98278e7c7e941c143737c6d7cd8950a88f58e04b4ee7cef1bc
72.00 MiB 65.32 MiB Linux-f88f0b3b678ff6432386a42bdd27661133c84a36ad29f393da407c871b0143eb
878.96 MiB <<missing>> macOS-10ad71d670ff0c9a346871f49f665972f8f8f201c47b4dd573e54ae1053ebb63
605.53 MiB 603.70 MiB macOS-231c66957fc2cdb18ea10e63f60770049026e29051ecd6598fc390b60d6a4fa6
784.84 MiB 775.51 MiB macOS-49aa50a4872ded07ebf657c0eaf9e44ecc0c174d033a97c537ecd270f35b462f
785.15 MiB 773.20 MiB macOS-8f37f663956af5f743f0f99ab973729b6a02f200ebfac7a3a036eff296550732
784.84 MiB 775.51 MiB macOS-ef5509b5d4495c8c3590442ee912ad1c9a33f872dc4a29421c524fc1e2103b59
------------
9254.15 MiB
==> after
content-size actual-size cache-key
226.46 MiB 226.43 MiB containerd:nerdctl-full-1.7.6-linux-amd64.tar.gz-sha256:2c841e097fcfb5a1760bd354b3778cb695b44cd01f9f271c17507dc4a0b25606
496.77 MiB 493.33 MiB image:Arch-Linux-x86_64-cloudimg-20240801.250900.qcow2-sha256:f0e92eb32c15f4352d27662fdee90e8acc51902f50ded1843ee622e48e999eea
379.06 MiB 377.28 MiB image:Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2-sha256:ac58f3c35b73272d5986fa6d3bc44fd246b45df4c334e99a07b3bbd00684adee
72.00 MiB 65.32 MiB image:alpine-lima-std-3.19.0-x86_64.iso-sha512:568852df405e6b9858e678171a9894c058f483df0b0570c22cf33fc75f349ba6cc5bb3d50188180d8c31faaf53400fe884ca3e5f949961b03b2bf53e65de88d7
74.00 MiB 67.06 MiB image:alpine-lima-std-3.20.0-x86_64.iso-sha512:df013ba0666460c9e303e996e46e061e613ce546124a9de60060041874c702444ac7a90e67f1aed4756b85cc89d40c5ea4375dea62c98b9536ceb44f18874b67
325.58 MiB 317.73 MiB image:debian-12-genericcloud-amd64-20240717-1811.qcow2-sha512:0f0075d53749dba4c9825e606899360626bb20ac6bab3dbdeff40041b051d203eb1a56e68d377c9fac0187faa0aea77fd543ef4a883fff2304eac252cce01b44
248.02 MiB 244.80 MiB image:openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2-url-sha256:713f6146e29554b9092f147652323bc0625a501abccc82dff249e139df8fade3
652.50 MiB 644.52 MiB image:ubuntu-22.04-server-cloudimg-amd64.img-sha256:345fbbb6ec827ca02ec1a1ced90f7d40d3fd345811ba97c5772ac40e951458e1
558.38 MiB 547.61 MiB image:ubuntu-24.04-server-cloudimg-amd64.img-sha256:d2377667ea95222330ca2287817403c85178dad397e9fed768a9b4aec79d2a7f
558.69 MiB 546.71 MiB image:ubuntu-24.04-server-cloudimg-amd64.img-url-sha256:3b6b67faf5fd451e96832cbcaf6f5e04704d2ff7c47e749663508fc2a636130f
------------
3591.47 MiB
a3d0d7e
to
a09d928
Compare
3e79f33
to
0c0c914
Compare
… versus previous method This was created in response to the question at lima-vm#2508 (comment). Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: `shfmt -s` Signed-off-by: Norio Nomura <[email protected]>
3df02fc
to
c82e6ce
Compare
FYI, the details of the cache currently used in this repository's CI can be seen here: https://github.com/lima-vm/lima/actions/caches. The cache settings are not efficient, so we quickly exceed the limit and caches expire. This PR will minimize the cache for files downloaded during |
hack/calculate-cache.sh
Outdated
@@ -0,0 +1,207 @@ | |||
#!/usr/bin/env bash | |||
# This script calculates the expected content size, actual cached size, and cache-keys used in caching method prior and after |
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.
Can you add the usage of the script?
What is the input and the output?
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.
Added some descriptions to calculate-cache.sh
.
… versus previous method This was created in response to the question at lima-vm#2508 (comment). Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: `shfmt -s` Signed-off-by: Norio Nomura <[email protected]>
c82e6ce
to
bcfd453
Compare
Following |
No, it is just out of sync with the latest version |
Use `actions/cache@v4` with following params: path: ".download/by-url-sha256/$(echo $location | sha256sum | cut -d' ' -f1)" key: "image-$digest" enableCrossOsArchive: true To make the image cache cross-platform, the cache directory is specified using a relative path from the working directory, and the platform-specific cache directories are accessed via symbolic links. This should reduce the cache size used by the CI. Signed-off-by: Norio Nomura <[email protected]> setup_cache_for_template: support url in template parameter Signed-off-by: Norio Nomura <[email protected]>
…erdctl` archives - Change cache key to `url-sha256:$sha256` for caching images without a digest - Include image basename in the cache key - Use `limactl validate --fill` to retrieve nerdctl archive info and set cache if needed - `test.yml`: Change cache configuration to run after `make install` Signed-off-by: Norio Nomura <[email protected]> test.yml: Remove `normalize_template_path` since `hashFile` is no longer used. Signed-off-by: Norio Nomura <[email protected]>
… versus previous method This was created in response to the question at lima-vm#2508 (comment). Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: `shfmt -s` Signed-off-by: Norio Nomura <[email protected]>
12893ad
to
dc7681d
Compare
… versus previous method This was created in response to the question at lima-vm#2508 (comment). Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: `shfmt -s` Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: extract `runs_on` and `template` from workflow file Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add DEBUG=1 to save collected information as yaml Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add descriptions and output examples to functions Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: use `--jq` instead of `| jq` Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add some descriptions Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: resolve shfmt issue Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: mention response cache file Signed-off-by: Norio Nomura <[email protected]>
5b9f0bb
to
f44b3f9
Compare
… versus previous method This was created in response to the question at lima-vm#2508 (comment). Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: `shfmt -s` Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: extract `runs_on` and `template` from workflow file Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add DEBUG=1 to save collected information as yaml Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add descriptions and output examples to functions Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: use `--jq` instead of `| jq` Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add some descriptions Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: resolve shfmt issue Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: mention response cache file Signed-off-by: Norio Nomura <[email protected]> calculate-cache.sh: add `select(.steps)|` Signed-off-by: Norio Nomura <[email protected]>
refactor some common codes from `setup_cache_for_template` and `calculate-cache.sh` into `cache-common-inc.sh` Signed-off-by: Norio Nomura <[email protected]>
f44b3f9
to
5058106
Compare
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.
Thanks
Thanks! 🙏🏻 |
This should reduce the cache size used by the CI.
This change adds
./.github/actions/setup_cache_for_template
to set up the cache using templates in tests, and utilizes it intest.yml
.For example, when using
templates/default.yaml
:templates/default.yaml
:The corresponding
arch
'slocation
anddigest
are read from theimages
section and used to set up the cache as follows:path
, it avoids using~
which expands to different absolute paths on different platforms..download
is a symbolic link to~/Library/Caches/lima/download
on macOS and~/.cache/lima/download
on Linux, making it usable on both platforms.key
usesimage-
+digest
, ensuring the cache is not reused if thedigest
changes while thelocation
remains the same (though such a scenario is rare). If the digest is absent, it falls back to${{ runner.os }}-${{ hashFiles(inputs.template) }}
.enableCrossOsArchive
allows sharing the cache between macOS and Linux.Additionally,
./.github/actions/setup_cache_for_template
can accept a URL for thetemplate
, allowing cache setup for remote templates in upgrade tests:Since many templates use the same images, this approach reduces cache usage more effectively than using the template file as the hash key.
Thanks,