File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 3
3
# implementation in https://github.com/lima-vm/lima/pull/2508
4
4
#
5
5
# Answer to the question in https://github.com/lima-vm/lima/pull/2508#discussion_r1699798651
6
+
7
+ # usage: [DEBUG=1] ./hack/calculate-cache.sh
8
+ # DEBUG=1 will save the collected information in .calculate-cache-collected-info-{before,after}.yaml
9
+
6
10
set -u -o pipefail
7
11
8
12
required_commands=(gh jq limactl sha256sum xxd yq)
@@ -175,13 +179,17 @@ for cache_method in before after; do
175
179
" ${key} " " ${template} " " ${location} " " ${digest} " " ${size} "
176
180
done
177
181
)
178
- cat <<< " ${output_yaml}" > " .calculate-cache-collected-info-${cache_method} .yaml"
179
- output_json=$( yq -o=j . <<< " ${output_yaml}" | tee " .calculate-cache-collected-info-${cache_method} .json" )
182
+ output_json=$( yq -o=j . <<< " ${output_yaml}" )
180
183
181
184
# print size key
182
185
jq --argjson actual_size " ${actual_cache_sizes} " -r ' unique_by(.key)|sort_by(.key)|.[]|[.size, $actual_size[.key] // 0, .key]|@tsv' <<< " ${output_json}" | size_to_mib
183
186
# total
184
187
echo " ------------"
185
188
jq ' [unique_by(.key)|.[]|.size]|add' <<< " ${output_json}" | size_to_mib
189
+ # save the collected information as yaml if DEBUG is set
190
+ if [[ -n " ${DEBUG: +1} " ]]; then
191
+ cat <<< " ${output_yaml}" > " .calculate-cache-collected-info-${cache_method} .yaml"
192
+ echo " Saved the collected information in .calculate-cache-collected-info-${cache_method} .yaml"
193
+ fi
186
194
echo " "
187
195
done
You can’t perform that action at this time.
0 commit comments