Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Cache Clojure classpath and prefill caches
Browse files Browse the repository at this point in the history
For repos that are built with the [Clojure CLI tools][clojure-cli]
(i.e., repos marked with a `deps.edn` file), we cache and restore the
`.cpcache` directory. Clojure uses this directory to avoid unnecessarily
re-calculating the JVM classpath. For most projects this additional
cache will not lead to a large improvement in build times.

We also download dependencies to the `.m2` cache before handing off to
the build script. Technically, this is unnecessary since, presumably,
the build script uses the Clojure CLI tools which have a side-effect of
populating `.m2`. Therefore, the benefit of this change is simply to
separate the two steps, isolating any errors that occure while fetching
dependencies.

[clojure-cli]: https://clojure.org/reference/deps_and_cli
  • Loading branch information
mainej committed Jun 4, 2021
1 parent 87dd246 commit 4af837c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ RUN mkdir /opt/boot-clj && cd /opt/boot-clj && \
chmod +x boot && \
ln -s /opt/boot-clj/boot /usr/local/bin/boot

# TODO: When upgrading to >= 1.10.1.672, also update approach for populating .m2 with clojure deps:
# In run-build-functions.sh replace `clojure -Spath -Sforce >/dev/null` with more modern `clojure -P`
RUN curl -sL https://download.clojure.org/install/linux-install-1.10.1.492.sh | bash

USER buildbot
Expand Down
10 changes: 10 additions & 0 deletions run-build-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,15 @@ install_dependencies() {
if [ -f deps.edn ]
then
restore_home_cache ".m2" "maven dependencies"
restore_cwd_cache ".cpcache" "clojure classpath"
echo "Installing Clojure dependencies"
if clojure -Spath -Sforce >/dev/null
then
echo "Clojure dependencies installed"
else
echo "Error during Clojure install"
exit 1
fi
fi

# Hugo
Expand Down Expand Up @@ -708,6 +717,7 @@ cache_artifacts() {

cache_cwd_directory ".venv" "python virtualenv"
cache_cwd_directory ".build" "swift build"
cache_cwd_directory ".cpcache" "clojure classpath"
cache_cwd_directory ".netlify/plugins" "build plugins"

if [ -f Cargo.toml ] || [ -f Cargo.lock ]
Expand Down

0 comments on commit 4af837c

Please sign in to comment.