Add bottle file size to GHP manifest annotations

This will reduce the number of requests necessary to ascertain the size
of formulas' bottle archives for analysis purposes.

Currently, getting the size of each bottle requires 1 request for the
formula.json and followed by N requests per formula-version, which
for most formulae is 7— more than 47k requests!

After this change, size retrieval can ascertain all bottle sizes for a
formula-version in a single request, at the cost of one additional
request per formula-version if that formula-version has not been
rebuilt since this change was introduced.

To start, size retrieval will incur an additional P requests where
P is the number of packages. Over the next few weeks and months,
the retrieval will go a lot faster as all new and updated packages will
require only one request.
This commit is contained in:
Colin Dean 2023-04-16 21:32:47 +00:00
parent ac0663ae5d
commit 2787eead89

View File

@ -356,11 +356,14 @@ class GitHubPackages
documentation = "https://formulae.brew.sh/formula/#{formula_name}" if formula_core_tap
local_file_size = File.size(local_file)
descriptor_annotations_hash = {
"org.opencontainers.image.ref.name" => tag,
"sh.brew.bottle.cpu.variant" => cpu_variant,
"sh.brew.bottle.digest" => tar_gz_sha256,
"sh.brew.bottle.glibc.version" => glibc_version,
"sh.brew.bottle.size" => local_file_size,
"sh.brew.tab" => tab.to_json,
}.reject { |_, v| v.blank? }