Skip to content

Commit

Permalink
fix: Fix to be able to upgrade third party action with the name attri…
Browse files Browse the repository at this point in the history
…bute

cf. #192
  • Loading branch information
liquidz committed Jun 17, 2023
1 parent baef607 commit 32ef2cb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/antq/upgrade/github_action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(loop [loc loc]
(if-let [loc (ri.zip/find-next-string loc #(re-seq target-re %))]
(recur (cond-> loc
(some? (ri.zip/find-ancestor-string loc (action? "DeLaGuardo/setup-clojure")))
(some? (ri.zip/find-previous-string loc (action? "DeLaGuardo/setup-clojure")))
(ri.zip/update (update-value (:latest-version version-checked-dep)))

:always
Expand All @@ -68,7 +68,7 @@
(loop [loc loc]
(if-let [loc (ri.zip/find-next-string loc #(re-seq #"version\s*:" %))]
(recur (cond-> loc
(some? (ri.zip/find-ancestor-string loc (action? "DeLaGuardo/setup-clj-kondo")))
(some? (ri.zip/find-previous-string loc (action? "DeLaGuardo/setup-clj-kondo")))
(ri.zip/update (update-value (:latest-version version-checked-dep)))

:always
Expand All @@ -81,7 +81,7 @@
(if-let [loc (or (ri.zip/find-next-string loc #(re-seq #"graalvm\s*:" %))
(ri.zip/find-next-string loc #(re-seq #"graalvm-version\s*:" %)))]
(recur (cond-> loc
(some? (ri.zip/find-ancestor-string loc (action? "DeLaGuardo/setup-graalvm")))
(some? (ri.zip/find-previous-string loc (action? "DeLaGuardo/setup-graalvm")))
(ri.zip/update (update-value (:latest-version version-checked-dep)))

:always
Expand All @@ -93,7 +93,7 @@
(loop [loc loc]
(if-let [loc (ri.zip/find-next-string loc #(re-seq #"cljstyle-version\s*:" %))]
(recur (cond-> loc
(some? (ri.zip/find-ancestor-string loc (action? "0918nobita/setup-cljstyle")))
(some? (ri.zip/find-previous-string loc (action? "0918nobita/setup-cljstyle")))
(ri.zip/update (update-value (:latest-version version-checked-dep)))

:always
Expand Down
18 changes: 12 additions & 6 deletions test/antq/upgrade/github_action_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
to-deps (->> dummy-clojure-cli-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "clojure/brew-install" :version {:- 1 :+ "9.0.0"}}}
(t/is (= #{{:name "clojure/brew-install" :version {:- 1 :+ "9.0.0"}}
{:name "clojure/brew-install" :version {:- -1 :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps)))))

(t/testing "leiningen"
Expand All @@ -105,7 +106,8 @@
to-deps (->> dummy-leiningen-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "technomancy/leiningen" :version {:- 2 :+ "9.0.0"}}}
(t/is (= #{{:name "technomancy/leiningen" :version {:- 2 :+ "9.0.0"}}
{:name "technomancy/leiningen" :version {:- -2 :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps)))))

(t/testing "boot"
Expand All @@ -115,7 +117,8 @@
to-deps (->> dummy-boot-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "boot-clj/boot" :version {:- 3 :+ "9.0.0"}}}
(t/is (= #{{:name "boot-clj/boot" :version {:- 3 :+ "9.0.0"}}
{:name "boot-clj/boot" :version {:- -3 :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps))))))

(t/testing "clj-kondo"
Expand All @@ -125,7 +128,8 @@
to-deps (->> dummy-clj-kondo-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "clj-kondo/clj-kondo" :version {:- "5" :+ "9.0.0"}}}
(t/is (= #{{:name "clj-kondo/clj-kondo" :version {:- "5" :+ "9.0.0"}}
{:name "clj-kondo/clj-kondo" :version {:- "-5" :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps)))))

(t/testing "graalvm"
Expand All @@ -135,7 +139,8 @@
to-deps (->> dummy-graalvm-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "graalvm/graalvm-ce-builds" :version {:- "6" :+ "9.0.0"}}}
(t/is (= #{{:name "graalvm/graalvm-ce-builds" :version {:- "6" :+ "9.0.0"}}
{:name "graalvm/graalvm-ce-builds" :version {:- "-6" :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps)))))

(t/testing "cljstyle"
Expand All @@ -145,5 +150,6 @@
to-deps (->> dummy-cljstyle-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "greglook/cljstyle" :version {:- "7" :+ "9.0.0"}}}
(t/is (= #{{:name "greglook/cljstyle" :version {:- "7" :+ "9.0.0"}}
{:name "greglook/cljstyle" :version {:- "-7" :+ "9.0.0"}}}
(h/diff-deps from-deps to-deps))))))
20 changes: 20 additions & 0 deletions test/resources/dep/test_github_action_third_party.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,23 @@ jobs:
- uses: 0918nobita/setup-cljstyle@master
with:
cljstyle-version: "7"

- name: with name
uses: DeLaGuardo/setup-clojure@master
with:
cli: -1
lein: -2
boot: -3
bb: -4
- name: with name
uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '-5'
- name: with name
uses: DeLaGuardo/setup-graalvm@master
with:
graalvm: -6
- name: with name
uses: 0918nobita/setup-cljstyle@master
with:
cljstyle-version: "-7"

0 comments on commit 32ef2cb

Please sign in to comment.