Skip to content

Commit

Permalink
Merge pull request #4346 from esl/invalidate-circleci-cache-with-plugins
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NelsonVides authored Jul 30, 2024
2 parents 8f6c421 + 78ebda1 commit 9fb5603
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .circleci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tools/circle-generate-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}/" \
Expand Down Expand Up @@ -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"

0 comments on commit 9fb5603

Please sign in to comment.