From 48507277a39f588d20d227605ff2cfb94eed2d6f Mon Sep 17 00:00:00 2001
From: Tasos Katsoulas <12612986+tkatsoulas@users.noreply.github.com>
Date: Thu, 29 Feb 2024 14:15:34 +0200
Subject: [PATCH] Cache key wasn't taking account changes in the version of
 bundled software (#16985)

To optimize the CI we are trying to cache build artifacts such as all the software we build and statically bundle for static binaries (for each arch) In a nutshell the artifacts of these https://github.com/netdata/netdata/tree/master/packaging/makeself/jobs source files. With this https://github.com/netdata/netdata/blob/master/.github/scripts/get-static-cache-key.sh script we generate the keys for these cached artifacts taking into account the (source files of the jobs, version of the software, static packages bundled in the base images). The effort #16303 to make a centralized file for all the versions expanded the problem of not considering the exact versions.

Signed-off-by: Tasos Katsoulas <tasos@netdata.cloud>
---
 .github/scripts/get-static-cache-key.sh                         | 1 +
 .../makeself/{bundled-packages => bundled-packages.version}     | 0
 packaging/makeself/jobs/20-openssl.install.sh                   | 2 +-
 packaging/makeself/jobs/50-bash-5.1.16.install.sh               | 2 +-
 packaging/makeself/jobs/50-curl.install.sh                      | 2 +-
 packaging/makeself/jobs/50-ioping-1.3.install.sh                | 2 +-
 packaging/makeself/jobs/50-libnetfilter_acct-1.0.3.install.sh   | 2 +-
 7 files changed, 6 insertions(+), 5 deletions(-)
 rename packaging/makeself/{bundled-packages => bundled-packages.version} (100%)

diff --git a/.github/scripts/get-static-cache-key.sh b/.github/scripts/get-static-cache-key.sh
index 5093b33279..e45ae30bd7 100755
--- a/.github/scripts/get-static-cache-key.sh
+++ b/.github/scripts/get-static-cache-key.sh
@@ -8,6 +8,7 @@ docker pull --platform "${platform}" netdata/static-builder:${builder_rev}
 
 # shellcheck disable=SC2046
 cat $(find packaging/makeself/jobs -type f ! -regex '.*\(netdata\|-makeself\).*') > /tmp/static-cache-key-data
+cat packaging/makeself/bundled-packages.version >> /tmp/static-cache-key-data
 
 docker run -it --rm --platform "${platform}" netdata/static-builder:${builder_rev} sh -c 'apk list -I 2>/dev/null' >> /tmp/static-cache-key-data
 
diff --git a/packaging/makeself/bundled-packages b/packaging/makeself/bundled-packages.version
similarity index 100%
rename from packaging/makeself/bundled-packages
rename to packaging/makeself/bundled-packages.version
diff --git a/packaging/makeself/jobs/20-openssl.install.sh b/packaging/makeself/jobs/20-openssl.install.sh
index 1158a63300..a07f9c9471 100755
--- a/packaging/makeself/jobs/20-openssl.install.sh
+++ b/packaging/makeself/jobs/20-openssl.install.sh
@@ -4,7 +4,7 @@
 # shellcheck source=packaging/makeself/functions.sh
 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
 # Source of truth for all the packages we bundle in static builds
-. "$(dirname "${0}")/../bundled-packages"
+. "$(dirname "${0}")/../bundled-packages.version"
 # shellcheck disable=SC2015
 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building OpenSSL" || true
 
diff --git a/packaging/makeself/jobs/50-bash-5.1.16.install.sh b/packaging/makeself/jobs/50-bash-5.1.16.install.sh
index 7a302f2ee3..cc74d0fc89 100755
--- a/packaging/makeself/jobs/50-bash-5.1.16.install.sh
+++ b/packaging/makeself/jobs/50-bash-5.1.16.install.sh
@@ -4,7 +4,7 @@
 # shellcheck source=packaging/makeself/functions.sh
 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
 # Source of truth for all the packages we bundle in static builds
-. "$(dirname "${0}")/../bundled-packages"
+. "$(dirname "${0}")/../bundled-packages.version"
 
 # shellcheck disable=SC2015
 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::building bash" || true
diff --git a/packaging/makeself/jobs/50-curl.install.sh b/packaging/makeself/jobs/50-curl.install.sh
index 824b305624..54f55480fa 100755
--- a/packaging/makeself/jobs/50-curl.install.sh
+++ b/packaging/makeself/jobs/50-curl.install.sh
@@ -4,7 +4,7 @@
 # shellcheck source=packaging/makeself/functions.sh
 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
 # Source of truth for all the packages we bundle in static builds
-. "$(dirname "${0}")/../bundled-packages"
+. "$(dirname "${0}")/../bundled-packages.version"
 
 # shellcheck disable=SC2015
 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building cURL" || true
diff --git a/packaging/makeself/jobs/50-ioping-1.3.install.sh b/packaging/makeself/jobs/50-ioping-1.3.install.sh
index 6bd538e356..de6cb3241c 100755
--- a/packaging/makeself/jobs/50-ioping-1.3.install.sh
+++ b/packaging/makeself/jobs/50-ioping-1.3.install.sh
@@ -4,7 +4,7 @@
 # shellcheck source=packaging/makeself/functions.sh
 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
 # Source of truth for all the packages we bundle in static builds
-. "$(dirname "${0}")/../bundled-packages" || exit 1
+. "$(dirname "${0}")/../bundled-packages.version" || exit 1
 
 # shellcheck disable=SC2015
 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building ioping" || true
diff --git a/packaging/makeself/jobs/50-libnetfilter_acct-1.0.3.install.sh b/packaging/makeself/jobs/50-libnetfilter_acct-1.0.3.install.sh
index 8297521785..efde6976fd 100755
--- a/packaging/makeself/jobs/50-libnetfilter_acct-1.0.3.install.sh
+++ b/packaging/makeself/jobs/50-libnetfilter_acct-1.0.3.install.sh
@@ -7,7 +7,7 @@
 # shellcheck source=packaging/makeself/functions.sh
 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
 # Source of truth for all the packages we bundle in static builds
-. "$(dirname "${0}")/../bundled-packages" || exit 1
+. "$(dirname "${0}")/../bundled-packages.version" || exit 1
 
 # shellcheck disable=SC2015
 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::building libnetfilter_acct" || true