Skip to content

Commit

Permalink
Fetch latest stable slipset/deps-deploy, instead of hard-coding (#206)
Browse files Browse the repository at this point in the history
* Fetch latest stable slipset/deps-deploy, instead of hard-coding

This is a minor change, which removes the hard-coding of the
`slipset/deps-deploy` version in the `build-alias` function.

I have tested the change locally using `bbin`, and see that `neil add
build` now uses `slipset/deps-deploy {:mvn/version "0.2.2}`

* Fix: broken tests due to real-world changes

The following tests were breaking before the changes in this commit:

```
FAIL in (latest-version-test) (dep_add_test.clj:9)
expected: (= "1.11.1" (neil/latest-stable-mvn-version (quote org.clojure/clojure)))
  actual: (not (= "1.11.1" "1.11.2"))

FAIL in (dep-upgrade-test-using-git-tags) (dep_upgrade_test.clj:71)
deps can be added with --tag
expected: (= "v2022.03.08" (:git/tag original))
  actual: (not (= "v2022.03.08" "v2024.03.13"))

FAIL in (dep-upgrade-test-using-git-tags) (dep_upgrade_test.clj:79)
deps with :git/tag coords upgrade to latest tags
expected: (= "v2022.03.08" (:git/tag original))
  actual: (not (= "v2022.03.08" "v2024.03.13"))

FAIL in (dep-upgrade-test-using-git-tags) (dep_upgrade_test.clj:84)
deps with :git/tag coords upgrade to latest tags
expected: (not= (:git/tag original) (:git/tag upgraded))
  actual: (not (not= "v2024.03.13" "v2024.03.13"))
```

The reasons for this are:

1. The latest stable version of `org.clojure/clojure` is `1.11.2`
2. Running `git/find-github-tag 'clj-kondo/clj-kondo "v2022.03.08"`
returns `nil`, which makes `neil` fetch the latest github tag instead.

To fix this, we:
1. Bump the latest stable version for Clojure in tests to 1.11.2
2. Bump the tag version used for `clj-kondo/clj-kondo` to
`v2024.03.13` (latest) in `dep add` tests.
3. Bump the tag version used for `clj-kondo/clj-kondo` to
`v2024.03.05` (not latest, but exists) in `dep upgrade` tests.
  • Loading branch information
vedang authored Mar 19, 2024
1 parent 8cbb77e commit 2a0a95b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

See the [New Clojure project quickstart](https://blog.michielborkent.nl/new-clojure-project-quickstart.html) blog post for a gentle introduction into `neil`.

## 0.2.64
- [#205](https://github.com/babashka/neil/issues/205): `neil add build` now adds the latest version of `deps-deploy` from Clojars

## 0.2.63

- [#194](https://github.com/babashka/neil/issues/41): `dep search` in addition to Clojars, now also searches on Maven
Expand Down
5 changes: 3 additions & 2 deletions src/babashka/neil.clj
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,12 @@ chmod +x bin/kaocha
(let [latest-tag (git/latest-github-tag 'clojure/tools.build)
tag (:name latest-tag)
sha (-> latest-tag :commit :sha (subs 0 7))
slipset-version (latest-stable-clojars-version 'slipset/deps-deploy)
s (format "
{:deps {io.github.clojure/tools.build {:git/tag \"%s\" :git/sha \"%s\"}
slipset/deps-deploy {:mvn/version \"0.2.0\"}}
slipset/deps-deploy {:mvn/version \"%s\"}}
:ns-default build}"
tag sha)]
tag sha slipset-version)]
{:s s
:tag tag
:sha sha}))
Expand Down
2 changes: 1 addition & 1 deletion test/babashka/neil/dep_add_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
(deftest latest-version-test
(is (= "1.0.5" (neil/latest-stable-clojars-version 'hiccup/hiccup)))
(is (= "2.0.0-RC3" (neil/latest-clojars-version 'hiccup/hiccup)))
(is (= "1.11.1" (neil/latest-stable-mvn-version 'org.clojure/clojure))))
(is (= "1.11.2" (neil/latest-stable-mvn-version 'org.clojure/clojure))))
12 changes: 6 additions & 6 deletions test/babashka/neil/dep_upgrade_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@

(testing "deps can be added with --tag"
(spit test-file-path "{}")
(test-util/neil "dep add :lib clj-kondo/clj-kondo :tag \"v2022.03.08\"" :deps-file test-file-path)
(test-util/neil "dep add :lib clj-kondo/clj-kondo :tag \"v2024.03.13\"" :deps-file test-file-path)
(let [original (get-dep-version 'clj-kondo/clj-kondo)]
(is (= "v2022.03.08" (:git/tag original)))
(is (= "v2024.03.13" (:git/tag original)))
(is (:git/sha original))
(is (:git/url original))))

(testing "deps with :git/tag coords upgrade to latest tags"
(spit test-file-path "{}")
(test-util/neil "dep add :lib clj-kondo/clj-kondo :tag \"v2022.03.08\"" :deps-file test-file-path)
(test-util/neil "dep add :lib clj-kondo/clj-kondo :tag \"v2024.03.05\"" :deps-file test-file-path)
(let [original (get-dep-version 'clj-kondo/clj-kondo)]
(is (= "v2022.03.08" (:git/tag original)))
(is (= "v2024.03.05" (:git/tag original)))
(test-util/neil "dep upgrade" :deps-file test-file-path)
(let [upgraded (get-dep-version 'clj-kondo/clj-kondo)]
(is (= (:git/url original) (:git/url upgraded)))
Expand All @@ -85,9 +85,9 @@
(is (:git/sha upgraded)))))

(testing "deps with :tag coords are also supported"
(spit test-file-path "{:deps {clj-kondo/clj-kondo {:tag \"v2022.03.08\" :sha \"247e538\"}}}")
(spit test-file-path "{:deps {clj-kondo/clj-kondo {:tag \"v2024.03.05\" :sha \"58ed56e\"}}}")
(let [original (get-dep-version 'clj-kondo/clj-kondo)]
(is (= "v2022.03.08" (:tag original)))
(is (= "v2024.03.05" (:tag original)))
(test-util/neil "dep upgrade" :deps-file test-file-path)
(let [upgraded (get-dep-version 'clj-kondo/clj-kondo)]
(is (:git/tag upgraded))
Expand Down

0 comments on commit 2a0a95b

Please sign in to comment.