Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improve clojure deps download & caching #16

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ jobs:
with:
path: |
~/.m2/repository
~/.deps.clj
~/.gitlibs
key: $${ runner.os }}-cljdeps-release-${{ hashFiles('deps.edn') }}
restore-keys: $${ runner.os }}-cljdeps-release-
key: $${ runner.os }}-cljdeps-${{ hashFiles('deps.edn','bb.edn') }}
restore-keys: $${ runner.os }}-cljdeps-

- name: Setup Java
uses: actions/setup-java@v4
Expand All @@ -53,7 +54,7 @@ jobs:
clojure -Sdescribe

- name: Download Clojure Dependencies
run: clojure -P -M:jar:deploy
run: bb download-deps

- name: Release Prep (step 1 of 4)
run: bb ci-release prep
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
with:
path: |
~/.m2/repository
~/.deps.clj
~/.gitlibs
key: $${ runner.os }}-cljdeps-${{ hashFiles('deps.edn') }}
key: $${ runner.os }}-cljdeps-${{ hashFiles('deps.edn','bb.edn') }}
restore-keys: $${ runner.os }}-cljdeps-

- name: Setup Java
Expand Down Expand Up @@ -82,7 +83,7 @@ jobs:
clojure -Sdescribe

- name: Download Clojure Dependencies
run: clojure -P
run: bb download-deps

- name: Run CI Tests
run: bb ci-test
2 changes: 2 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
(status/line :detail "\nTASK %s done." name)))

;; commands
download-deps {:doc "bring down Clojure deps"
:task (clojure "-T:build download-deps")}

lint {:doc "[--rebuild] lint source code with clj-kondo"
:task lint/-main}
Expand Down
26 changes: 21 additions & 5 deletions build.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(ns build
(:require [clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))
[clojure.tools.build.api :as b]))

(def lib 'com.github.lread/test-doc-blocks)
(def version (let [version-template (-> "version.edn" slurp edn/read-string)
Expand Down Expand Up @@ -66,11 +65,28 @@
(defn deploy
"Deploy built jar to clojars"
[_]
(dd/deploy {:installer :remote
:artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))
((requiring-resolve 'deps-deploy.deps-deploy/deploy)
{:installer :remote
:artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))

(defn project-lib
"Returns project groupid/artifactid"
[_]
(println lib))

(defn download-deps
"Download all deps for all aliases"
[_]
(let [aliases (->> "deps.edn"
slurp
edn/read-string
:aliases
keys
sort)]
;; one at a time because aliases with :replace-deps will... well... you know.
(println "Bring down default deps")
(b/create-basis {})
(doseq [a (sort aliases)]
(println "Bring down deps for alias" a)
(b/create-basis {:aliases [a]}))))
7 changes: 5 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@
;;
;; Deployment
;;
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.1"}
slipset/deps-deploy {:mvn/version "0.2.2"}}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.1"}}
:ns-default build}

;; keep deploy deps separate from build deps to avoid download-deps issues
;; caused by, I think, conflicting maven deps
:deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.2"}}}

;; Maintenance
:outdated {:extra-deps {org.clojure/clojure {:mvn/version "1.11.3"}
com.github.liquidz/antq {:mvn/version "2.8.1201"}
Expand Down