|
6 | 6 |
|
7 | 7 | # usage: [DEBUG=1] ./hack/calculate-cache.sh
|
8 | 8 | # DEBUG=1 will save the collected information in .calculate-cache-collected-info-{before,after}.yaml
|
| 9 | +# |
| 10 | +# This script does: |
| 11 | +# 1. extracts `runs_on` and `template` from workflow file (.github/workflows/test.yml) |
| 12 | +# 2. check each template for image and nerdctl |
| 13 | +# 3. detect size of image and nerdctl (responses from remote are cached for faster iteration) |
| 14 | +# 4. print content size, actual cache size (if available), by cache key |
| 15 | +# |
| 16 | +# The major differences for reducing cache usage are as follows: |
| 17 | +# - it is now cached `~/.cache/lima/download/by-url-sha256/$sha256` instead of caching `~/.cache/lima/download` |
| 18 | +# - the cache keys are now based on the image digest and nerdctl digest instead of the template file's hash |
| 19 | +# - enables the use of cache regardless of the operating system used to execute CI. |
| 20 | +# |
| 21 | +# The script requires the following commands: |
| 22 | +# - gh: GitHub CLI. |
| 23 | +# Using to get the cache information |
| 24 | +# - jq: Command-line JSON processor |
| 25 | +# Parse the workflow file and print runs-on and template. |
| 26 | +# Parse output from gh cache list |
| 27 | +# Calculate the expected content size, actual cached size, and cache-keys used. |
| 28 | +# - limactl: lima CLI. |
| 29 | +# Using to validate the template file for getting nerdctl location and digest. |
| 30 | +# - sha256sum: Print or check SHA256 (256-bit) checksums |
| 31 | +# - xxd: make a hexdump or do the reverse. |
| 32 | +# Using to simulate the 'hashFile()' function in the workflow. |
| 33 | +# - yq: Command-line YAML processor. |
| 34 | +# Parse the template file for image and nerdctl location, digest, and size. |
| 35 | +# Parse the cache response file for the cache. |
| 36 | +# Convert the collected information to JSON. |
9 | 37 |
|
10 | 38 | set -u -o pipefail
|
11 | 39 |
|
|
0 commit comments