Skip to content

Add .cpcache to cached paths to prevent re-downloading dependencies #122

@miguno

Description

@miguno

TL;DR: I suggest to also include .cpcache to the actions@cache path in the README, as it prevents certain dependencies from being re-downloaded again and again.


I initially followed the setup example in the README, using:

      - name: Cache clojure dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.m2/repository
            ~/.gitlibs
            ~/.deps.clj
          key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }}
          restore-keys: cljdeps-

However, I noticed that some steps (such as running tests) would keep re-downloading dependencies for each run:

# From GitHub Action logs

# Lint step
Run clojure -M:lint/splint
== Linting sources with splint (https://github.com/NoahTheDuke/splint) ==
Downloading: io/github/noahtheduke/splint/1.20.0/splint-1.20.0.pom from clojars
Downloading: org/clojure/data.json/2.5.0/data.json-2.5.0.pom from central
Downloading: rewrite-clj/rewrite-clj/1.1.48/rewrite-clj-1.1.48.pom from clojars
Downloading: camel-snake-kebab/camel-snake-kebab/0.4.3/camel-snake-kebab-0.4.3.pom from clojars
Downloading: org/flatland/ordered/1.15.12/ordered-1.15.12.pom from clojars

...snip...

# Test step
Run clojure -M:test
== Running tests with kaocha (https://github.com/lambdaisland/kaocha) ==
Downloading: org/slf4j/slf4j-nop/2.0.17/slf4j-nop-2.0.17.pom from central
Downloading: org/slf4j/slf4j-parent/2.0.17/slf4j-parent-2.0.17.pom from central
Downloading: lambdaisland/kaocha/1.91.1392/kaocha-1.91.1392.pom from clojars
Downloading: org/slf4j/slf4j-bom/2.0.17/slf4j-bom-2.0.17.pom from central
Downloading: expound/expound/0.9.0/expound-0.9.0.pom from clojars

Running with -Sverbose helped me find the culprit:

Run clojure -Sverbose -M:test
  clojure -Sverbose -M:test
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/24.0.1-9/x64
    JAVA_HOME_24_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/24.0.1-9/x64
    CLOJURE_INSTALL_DIR: /tmp/usr/local/opt/ClojureTools
version      = 1.12.0.1530
install_dir  = /tmp/usr/local/opt/ClojureTools/lib/clojure
config_dir   = /home/runner/.config/clojure
config_paths = /tmp/usr/local/opt/ClojureTools/lib/clojure/deps.edn /home/runner/.config/clojure/deps.edn deps.edn
cache_dir    = .cpcache     # <=========== HERE
cp_file      = .cpcache/1712088764.cp

Refreshing classpath
[(...............................)]
5 tests, 31 assertions, 0 failures.

Adding .cpcache to the actions/cache path fixes the problem:

      - name: Cache clojure dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.m2/repository
            ~/.gitlibs
            ~/.deps.clj
            .cpcache
          key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }}
          restore-keys: cljdeps-

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions