Skip to content

Commit 9fb5603

Browse files
authored
Merge pull request #4346 from esl/invalidate-circleci-cache-with-plugins
Invalidate CircleCI deps cache if the plugin list changes This PR addresses MIM-2265. It is hard to handle updates of plugins, circleci would always use the cached old version. And rebar.lock is not tracking plugins. Proposed changes include: Hashing of {plugins, ...}. block. Useful if you are developing or updating plugins Invalidate CircleCI deps cache if the plugin list changes We use base circle ci image for initial template generation, which has no Erlang. So we use sed to match plugins block and we hash it.
2 parents 8f6c421 + 78ebda1 commit 9fb5603

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.circleci/template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ references:
66
- &ENTRYPOINT ["/bin/sh", "-c", "eval ${INSTALL_DEPS_CMD:-echo} && echo __INJECT_FILES__ | eval ${BASE32DEC:-base32 --decode} | bash"]
77
# Caches created via the save_cache step are stored for up to 15 days
88
- &CERT_KEY certs-cache-{{ checksum "certs_cache_key" }}-v3
9-
- &DEPS_CACHE_KEY deps-cache-{{ checksum "rebar.lock" }}-{{ checksum "big_tests/rebar.lock" }}-{{ checksum "otp_version" }}-v5
9+
- &DEPS_CACHE_KEY deps-cache-{{ checksum "rebar.lock" }}-{{ checksum "big_tests/rebar.lock" }}-__REBAR_PLUGINS_HASH__-{{ checksum "otp_version" }}-v5
1010
- &BUILD_CACHE_KEY build-cache-{{ .Branch }}-{{ .Revision }}-{{ checksum "otp_version" }}-v6
1111

1212
# list of references to be used inside executors block

tools/circle-generate-config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ CACERT=$(cat32 tools/ssl/ca/cacert.pem)
3535

3636
CERTS_CACHE_KEY=$(cat certs_cache_key)
3737

38+
# Matches plugins list in the rebar.config
39+
REBAR_PLUGINS_HASH=$(cat rebar.config | sed -n '/^{plugins/,/]}./p' | sha1sum | awk '{print $1}')
40+
3841
sed -e "s/__MYSQL_CNF__/${MYSQL_CNF}/" \
3942
-e "s/__MYSQL_SQL__/${MYSQL_SQL}/" \
4043
-e "s/__MYSQL_SETUP__/${MYSQL_SETUP}/" \
@@ -69,5 +72,6 @@ sed -e "s/__MYSQL_CNF__/${MYSQL_CNF}/" \
6972
-e "s/__PYTHON2_BASE32_DEC__/${PYTHON2_BASE32_DEC}/" \
7073
-e "s/__PYTHON3_BASE32_DEC__/${PYTHON3_BASE32_DEC}/" \
7174
-e "s/__CERTS_CACHE_KEY__/${CERTS_CACHE_KEY}/" \
75+
-e "s/__REBAR_PLUGINS_HASH__/${REBAR_PLUGINS_HASH}/" \
7276
.circleci/template.yml \
7377
> "$OUT_FILE"

0 commit comments

Comments
 (0)