Skip to content

Commit

Permalink
Merge pull request #242 from liquidz/dev
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
liquidz committed Dec 10, 2023
2 parents 1cbbd2a + d4d745e commit 29ee7b7
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{:linters {:unresolved-namespace {:exclude [z]}}
:output {:exclude-files ["test/resources/dep"]}}
:output {:exclude-files ["test/resources/dep"]}
:lint-as {antq.test-helper/with-temp-file clojure.core/let}}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 11
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].

== Unreleased (dev)
// {{{
=== Changed
* Bumped tools.deps to 0.18.1374.
* Bumped build.edn to 0.11.241.

=== Fixed
* https://github.com/liquidz/antq/pull/192[#192]: Fixed github ation upgrader to check version correctly.
// }}}

== 2.7.1133 (2023-10-02)
// {{{
Expand Down
2 changes: 2 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{:lib 'com.github.liquidz/antq
:version "2.7.{{git/commit-count}}"
:description "Point out your outdated dependencies"
:licenses [{:name "Eclipse Public License - v 2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}]
:main 'antq.core
:documents [{:file "CHANGELOG.adoc"
:match "Unreleased"
Expand Down
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
org.clojure/data.zip {:mvn/version "1.0.0"}
org.clojure/tools.cli {:mvn/version "1.0.219"}
org.clojure/core.async {:mvn/version "1.6.681"}
org.clojure/tools.deps {:mvn/version "0.18.1354"}
org.clojure/tools.deps {:mvn/version "0.18.1374"}
org.clojure/data.json {:mvn/version "2.4.0"}
clj-commons/clj-yaml {:mvn/version "1.0.27"}
version-clj/version-clj {:mvn/version "2.0.2"}
Expand Down Expand Up @@ -42,7 +42,7 @@
:main-opts ["-m" "cloverage.coverage" "--ns-exclude-regex" "leiningen.antq"]}

:build
{:deps {com.github.liquidz/build.edn {:mvn/version "0.10.227"}}
{:deps {com.github.liquidz/build.edn {:mvn/version "0.11.241"}}
:ns-default build}

;; -X
Expand Down
11 changes: 8 additions & 3 deletions src/antq/upgrade/github_action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
(str "$1" new-value "$2"))))

(defn- action?
[action-name]
(let [re (re-pattern (str "uses\\s*:\\s*" action-name))]
[action-name & [version]]
(let [version' (some-> version
(str/replace "." "\\."))
re (re-pattern (if version'
(str "uses\\s*:\\s*" action-name "@" version')
(str "uses\\s*:\\s*" action-name)))]
#(some? (re-seq re %))))

(defmulti upgrade-dep
Expand All @@ -34,7 +38,8 @@
(defmethod upgrade-dep "uses"
[loc version-checked-dep]
(loop [loc loc]
(if-let [loc (ri.zip/find-next-string loc (action? (:name version-checked-dep)))]
(if-let [loc (ri.zip/find-next-string loc (action? (:name version-checked-dep)
(:version version-checked-dep)))]
(recur (cond-> loc
(some? (ri.zip/find-ancestor-string loc #(= "steps:" %)))
(ri.zip/update (update-action-version (:latest-version version-checked-dep)))
Expand Down
2 changes: 2 additions & 0 deletions test/antq/dep/github_action_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
(t/is (every? #(instance? antq.record.Dependency %) deps))
(t/is (= #{(git-tag-dependency {:name "foo/bar" :version "v1.0.0"
:extra {const.gh-action/type-key "uses"}})
(git-tag-dependency {:name "foo/bar" :version "v2.0.0"
:extra {const.gh-action/type-key "uses"}})
(git-tag-dependency {:name "bar/baz" :version "master"
:extra {const.gh-action/type-key "uses"}})
(git-sha-dependency {:name "git/sha" :version "8be09192b01d78912b03852f5d6141e8c48f4179"
Expand Down
10 changes: 10 additions & 0 deletions test/antq/test_helper.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[antq.upgrade.clojure]
[lambdaisland.deep-diff2 :as ddiff])
(:import
java.io.File
lambdaisland.deep_diff2.diff_impl.Mismatch))

(defn test-dep
Expand Down Expand Up @@ -41,3 +42,12 @@
(filter #(instance? Mismatch %))
(map #(select-keys % [:- :+]))
(set)))

(defmacro with-temp-file
[[sym content] & body]
`(let [~sym (File/createTempFile "tmp" "tmp")]
(try
(spit ~sym ~content)
~@body
(finally
(.delete ~sym)))))
16 changes: 12 additions & 4 deletions test/antq/upgrade/github_action_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
(r/map->Dependency {:project :github-action
:type :github-tag
:name "foo/bar"
:version "v1.0.0"
:latest-version "v9.0.0"
:file (io/resource "dep/test_github_action.yml")
:extra {const.gh-action/type-key "uses"}}))
Expand Down Expand Up @@ -77,10 +78,17 @@
(let [from-deps (->> (:file dummy-dep)
(slurp)
(dep.gha/extract-deps ""))
to-deps (->> dummy-dep
(upgrade/upgrader)
(dep.gha/extract-deps ""))]
(t/is (= #{{:name "foo/bar" :version {:- "v1.0.0" :+ "v9.0.0"}}}
temp-content (->> dummy-dep
(upgrade/upgrader))
to-deps (h/with-temp-file
[temp-file temp-content]
(->> (assoc dummy-dep
:version "v2.0.0"
:file temp-file)
(upgrade/upgrader)
(dep.gha/extract-deps "")))]
(t/is (= #{{:name "foo/bar" :version {:- "v1.0.0" :+ "v9.0.0"}}
{:name "foo/bar" :version {:- "v2.0.0" :+ "v9.0.0"}}}
(h/diff-deps from-deps to-deps)))))

(t/testing "not supported"
Expand Down
2 changes: 2 additions & 0 deletions test/resources/dep/test_github_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: foo/bar@v1.0.0
- name: Foo
uses: foo/bar@v2.0.0
- name: Bar
uses: bar/baz@master
- uses: ./
Expand Down

0 comments on commit 29ee7b7

Please sign in to comment.