From 6a3b28cc382bf33022d3c4d404da2a5c9e271eea Mon Sep 17 00:00:00 2001 From: Radford Smith <11401+rads@users.noreply.github.com> Date: Sun, 15 Jan 2023 17:12:44 -0800 Subject: [PATCH] Bump `io.github.rads/deps-info` to `v0.0.10` New features: - Support inference for private Git repos (resolves #48) - Support all possible "lib to url" cases (resolves #3) --- .github/workflows/ci.yml | 6 +++++ bbin | 11 ++------- deps.edn | 2 +- src/babashka/bbin/scripts.clj | 9 +------ test/babashka/bbin/scripts_test.clj | 38 +++++++++++++++++------------ 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c06dd2..139c915 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,9 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Install clojure tools uses: DeLaGuardo/setup-clojure@9.4 with: @@ -16,6 +19,9 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v3 + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Install clojure tools uses: DeLaGuardo/setup-clojure@9.4 with: diff --git a/bbin b/bbin index d605805..33a475c 100755 --- a/bbin +++ b/bbin @@ -12,7 +12,7 @@ fipp/fipp {:mvn/version "0.6.26"}, com.taoensso/timbre {:mvn/version "5.2.1"}, selmer/selmer {:mvn/version "1.12.53"}, - io.github.rads/deps-info {:git/tag "v0.0.9", :git/sha "01f34ac"}}}) + io.github.rads/deps-info {:git/tag "v0.0.10", :git/sha "b5144db"}}}) (ns babashka.bbin.meta) (def min-bb-version "This def was generated by the bbin build script." "0.9.162") @@ -161,7 +161,6 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi (:require [babashka.bbin.util :as util :refer [sh]] [babashka.deps :as deps] [babashka.fs :as fs] - [cheshire.core :as json] [clojure.edn :as edn] [clojure.java.io :as io] [clojure.pprint :as pprint] @@ -503,16 +502,10 @@ WARNING: - Set the BABASHKA_BBIN_BIN_DIR env variable to \"$HOME/.babashka/bbi {:main-opts ["-m" (str top "." name)] :ns-default (str top "." name)})) -(def ^:private deps-info-client - {:http-get-json #(json/parse-string (:body @(apply http/get %&)) true)}) - -(defn- deps-info-infer [& {:as opts}] - (deps-info-infer/infer deps-info-client opts)) - (defn- install-deps-git-or-local [cli-opts {:keys [procurer] :as _summary}] (let [script-deps (if (and (#{:local} procurer) (not (:local/root cli-opts))) {::no-lib {:local/root (str (fs/canonicalize (:script/lib cli-opts) {:nofollow-links true}))}} - (deps-info-infer (assoc cli-opts :lib (:script/lib cli-opts)))) + (deps-info-infer/infer (assoc cli-opts :lib (:script/lib cli-opts)))) lib (key (first script-deps)) coords (val (first script-deps)) header (merge {:coords coords} (when-not (#{::no-lib} lib) {:lib lib})) diff --git a/deps.edn b/deps.edn index 9171101..9788b9e 100644 --- a/deps.edn +++ b/deps.edn @@ -4,6 +4,6 @@ fipp/fipp {:mvn/version "0.6.26"} com.taoensso/timbre {:mvn/version "5.2.1"} selmer/selmer {:mvn/version "1.12.53"} - io.github.rads/deps-info {:git/tag "v0.0.9" :git/sha "01f34ac"}} + io.github.rads/deps-info {:git/tag "v0.0.10" :git/sha "b5144db"}} :aliases {:neil {:project {:name babashka/bbin :version "0.1.5"}}}} diff --git a/src/babashka/bbin/scripts.clj b/src/babashka/bbin/scripts.clj index 76b14a0..94fa8ef 100644 --- a/src/babashka/bbin/scripts.clj +++ b/src/babashka/bbin/scripts.clj @@ -2,7 +2,6 @@ (:require [babashka.bbin.util :as util :refer [sh]] [babashka.deps :as deps] [babashka.fs :as fs] - [cheshire.core :as json] [clojure.edn :as edn] [clojure.java.io :as io] [clojure.pprint :as pprint] @@ -344,16 +343,10 @@ {:main-opts ["-m" (str top "." name)] :ns-default (str top "." name)})) -(def ^:private deps-info-client - {:http-get-json #(json/parse-string (:body @(apply http/get %&)) true)}) - -(defn- deps-info-infer [& {:as opts}] - (deps-info-infer/infer deps-info-client opts)) - (defn- install-deps-git-or-local [cli-opts {:keys [procurer] :as _summary}] (let [script-deps (if (and (#{:local} procurer) (not (:local/root cli-opts))) {::no-lib {:local/root (str (fs/canonicalize (:script/lib cli-opts) {:nofollow-links true}))}} - (deps-info-infer (assoc cli-opts :lib (:script/lib cli-opts)))) + (deps-info-infer/infer (assoc cli-opts :lib (:script/lib cli-opts)))) lib (key (first script-deps)) coords (val (first script-deps)) header (merge {:coords coords} (when-not (#{::no-lib} lib) {:lib lib})) diff --git a/test/babashka/bbin/scripts_test.clj b/test/babashka/bbin/scripts_test.clj index 0fbfa2e..ee84ec0 100644 --- a/test/babashka/bbin/scripts_test.clj +++ b/test/babashka/bbin/scripts_test.clj @@ -12,7 +12,13 @@ (def bbin-test-lib '{:lib io.github.rads/bbin-test-lib, - :coords {:git/url "https://github.com/rads/bbin-test-lib", + :coords {:git/url "https://github.com/rads/bbin-test-lib.git", + :git/tag "v0.0.1", + :git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}}) + +(def bbin-test-lib-private + '{:lib io.github.rads/bbin-test-lib-private, + :coords {:git/url "git@github.com:rads/bbin-test-lib-private.git", :git/tag "v0.0.1", :git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}}) @@ -25,18 +31,7 @@ (util/ensure-bbin-dirs cli-opts) (is (= {} (scripts/load-scripts cli-opts))) (spit (fs/file (util/bin-dir cli-opts) "test-script") test-script) - (is (= '{test-script - {:lib io.github.rads/bbin-test-lib, - :coords {:git/url "https://github.com/rads/bbin-test-lib", - :git/tag "v0.0.1", - :git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}}} - (scripts/load-scripts cli-opts))))) - -(def test-lib - {:lib 'io.github.rads/bbin-test-lib - :coords {:git/url "https://github.com/rads/bbin-test-lib" - :git/tag "v0.0.1" - :git/sha "9140acfc12d8e1567fc6164a50d486de09433919"}}) + (is (= {'test-script bbin-test-lib} (scripts/load-scripts cli-opts))))) (def portal-script-url (str "https://gist.githubusercontent.com" @@ -56,14 +51,25 @@ {:keys [out]} (sh args {:err :inherit})] (str/trim out))) -(deftest install-from-qualified-lib-name-test - (testing "install */*" +(deftest install-from-qualified-lib-name-public-test + (testing "install */* (public Git repo)" (reset-test-dir) (util/ensure-bbin-dirs {}) (let [cli-opts {:script/lib "io.github.rads/bbin-test-lib"} out (run-install cli-opts) bin-file (fs/file bin-dir "hello")] - (is (= test-lib out)) + (is (= bbin-test-lib out)) + (is (fs/exists? bin-file)) + (is (= "Hello world!" (run-bin-script 'hello)))))) + +(deftest install-from-qualified-lib-name-private-test + (testing "install */* (private Git repo)" + (reset-test-dir) + (util/ensure-bbin-dirs {}) + (let [cli-opts {:script/lib "io.github.rads/bbin-test-lib-private"} + out (run-install cli-opts) + bin-file (fs/file bin-dir "hello")] + (is (= bbin-test-lib-private out)) (is (fs/exists? bin-file)) (is (= "Hello world!" (run-bin-script 'hello))))))