From 09bccb3fd5ec0aa9372639dd8c2dc405aa2423eb Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 27 Apr 2022 11:43:37 +0200 Subject: [PATCH 1/3] Add CI_CERT_KEY_VERSION environment variable --- tools/make-certs-cache-key.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/make-certs-cache-key.sh b/tools/make-certs-cache-key.sh index 3a3f195e6c..f4bc2533f6 100755 --- a/tools/make-certs-cache-key.sh +++ b/tools/make-certs-cache-key.sh @@ -5,4 +5,13 @@ week=$(date "+%V") year=$(date "+%Y") makefile_sum=$(sha1sum tools/ssl/Makefile | cut -d " " -f1) -echo "${year}-week${num}-${makefile_sum}-1" +# Change it once incompatible changes are made in tools/ssl/ directory +CERT_KEY_VERSION=1 + +# CI_CERT_KEY_VERSION could be set in +# https://app.circleci.com/settings/project/github/esl/MongooseIM/environment-variables +# It takes integer values 1, 2, 3... +# Change it to invalidate cache without making code changes +# There is no way to see the current value in the Circle CI settings though. +# To get the current value, run a CI job and check the output of the "Prepare cache key" task. +echo "${year}-week${num}-${makefile_sum}-${CERT_KEY_VERSION}-${CI_CERT_KEY_VERSION}" From 3116e7328f04198b3fd40947e78604392723544b Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 27 Apr 2022 11:57:00 +0200 Subject: [PATCH 2/3] Avoid caching invalid certificate data --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8987fdb66a..19c4522848 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,6 +41,9 @@ commands: - run: name: Print cert hashes for debugging command: find tools/ssl -type f -exec md5sum {} \; | sort + - run: + name: Continue if certificate data is valid + command: test -f tools/ssl/mongooseim/key.pem - save_cache: name: Cache built certs key: *CERT_KEY From 7417601bf85f4a9fd8bd8cfe58d3ad0e0cc4a231 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Wed, 27 Apr 2022 12:02:24 +0200 Subject: [PATCH 3/3] Print cache key --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 19c4522848..e9c9adbf43 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,7 @@ commands: steps: - run: name: Prepare cache key - command: tools/make-certs-cache-key.sh > certs_cache_key + command: tools/make-certs-cache-key.sh > certs_cache_key && cat certs_cache_key - restore_cache: name: Restore certificates key: *CERT_KEY @@ -42,7 +42,7 @@ commands: name: Print cert hashes for debugging command: find tools/ssl -type f -exec md5sum {} \; | sort - run: - name: Continue if certificate data is valid + name: Continue if certificate exists command: test -f tools/ssl/mongooseim/key.pem - save_cache: name: Cache built certs