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

Commit 7bcb781

Browse files
committed
Cache Clojure classpath and prefill caches
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
1 parent e52a065 commit 7bcb781

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ RUN mkdir /opt/boot-clj && cd /opt/boot-clj && \
350350
chmod +x boot && \
351351
ln -s /opt/boot-clj/boot /usr/local/bin/boot
352352

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

355357
USER buildbot

run-build-functions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,15 @@ install_dependencies() {
585585
if [ -f deps.edn ]
586586
then
587587
restore_home_cache ".m2" "maven dependencies"
588+
restore_cwd_cache ".cpcache" "clojure classpath"
589+
echo "Installing Clojure dependencies"
590+
if clojure -Spath -Sforce >/dev/null
591+
then
592+
echo "Clojure dependencies installed"
593+
else
594+
echo "Error during Clojure install"
595+
exit 1
596+
fi
588597
fi
589598

590599
# Hugo
@@ -706,6 +715,7 @@ cache_artifacts() {
706715

707716
cache_cwd_directory ".venv" "python virtualenv"
708717
cache_cwd_directory ".build" "swift build"
718+
cache_cwd_directory ".cpcache" "clojure classpath"
709719
cache_cwd_directory ".netlify/plugins" "build plugins"
710720
cache_cwd_directory ".netlify/rust-functions-cache" "Rust functions"
711721

0 commit comments

Comments
 (0)