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

Commit 7423f4b

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 dd94d3c commit 7423f4b

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
@@ -349,6 +349,8 @@ RUN mkdir /opt/boot-clj && cd /opt/boot-clj && \
349349
chmod +x boot && \
350350
ln -s /opt/boot-clj/boot /usr/local/bin/boot
351351

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

354356
USER buildbot

run-build-functions.sh

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

587596
# Hugo
@@ -702,6 +711,7 @@ cache_artifacts() {
702711

703712
cache_cwd_directory ".venv" "python virtualenv"
704713
cache_cwd_directory ".build" "swift build"
714+
cache_cwd_directory ".cpcache" "clojure classpath"
705715
cache_cwd_directory ".netlify/plugins" "build plugins"
706716

707717
if [ -f Cargo.toml ] || [ -f Cargo.lock ]

0 commit comments

Comments
 (0)