From 78ebda141b9e9aba821a58bd0b94f7251d51bdd7 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Mon, 29 Jul 2024 22:22:51 +0200 Subject: [PATCH] Invalidate CircleCI deps cache if the plugin list changes Useful if you are developing or updating plugins --- .circleci/template.yml | 2 +- tools/circle-generate-config.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index 1b5703220df..ddb22a91f0d 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -6,7 +6,7 @@ references: - &ENTRYPOINT ["/bin/sh", "-c", "eval ${INSTALL_DEPS_CMD:-echo} && echo __INJECT_FILES__ | eval ${BASE32DEC:-base32 --decode} | bash"] # Caches created via the save_cache step are stored for up to 15 days - &CERT_KEY certs-cache-{{ checksum "certs_cache_key" }}-v3 - - &DEPS_CACHE_KEY deps-cache-{{ checksum "rebar.lock" }}-{{ checksum "big_tests/rebar.lock" }}-{{ checksum "otp_version" }}-v5 + - &DEPS_CACHE_KEY deps-cache-{{ checksum "rebar.lock" }}-{{ checksum "big_tests/rebar.lock" }}-__REBAR_PLUGINS_HASH__-{{ checksum "otp_version" }}-v5 - &BUILD_CACHE_KEY build-cache-{{ .Branch }}-{{ .Revision }}-{{ checksum "otp_version" }}-v6 # list of references to be used inside executors block diff --git a/tools/circle-generate-config.sh b/tools/circle-generate-config.sh index d27a726056b..6b1c3d4a8f3 100755 --- a/tools/circle-generate-config.sh +++ b/tools/circle-generate-config.sh @@ -35,6 +35,9 @@ CACERT=$(cat32 tools/ssl/ca/cacert.pem) CERTS_CACHE_KEY=$(cat certs_cache_key) +# Matches plugins list in the rebar.config +REBAR_PLUGINS_HASH=$(cat rebar.config | sed -n '/^{plugins/,/]}./p' | sha1sum | awk '{print $1}') + sed -e "s/__MYSQL_CNF__/${MYSQL_CNF}/" \ -e "s/__MYSQL_SQL__/${MYSQL_SQL}/" \ -e "s/__MYSQL_SETUP__/${MYSQL_SETUP}/" \ @@ -69,5 +72,6 @@ sed -e "s/__MYSQL_CNF__/${MYSQL_CNF}/" \ -e "s/__PYTHON2_BASE32_DEC__/${PYTHON2_BASE32_DEC}/" \ -e "s/__PYTHON3_BASE32_DEC__/${PYTHON3_BASE32_DEC}/" \ -e "s/__CERTS_CACHE_KEY__/${CERTS_CACHE_KEY}/" \ + -e "s/__REBAR_PLUGINS_HASH__/${REBAR_PLUGINS_HASH}/" \ .circleci/template.yml \ > "$OUT_FILE"