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

Next release #167

Merged
merged 41 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0b1c6fb
deps: Add core.async
liquidz Jun 3, 2022
82359cb
feat: Add antq.log/async-print
liquidz Jun 3, 2022
5ab25de
feat: Update core to initialize async-logger
liquidz Jun 3, 2022
27642d2
feat: Add run-progress / init-progress to antq.report
liquidz Jun 3, 2022
21669cf
feat: Update to show progress bar
liquidz Jun 3, 2022
4104cd8
feat: Add antq.util.env/getlong
liquidz Jun 5, 2022
0844604
feat: Add antq.util.async/fn-with-timeout
liquidz Jun 5, 2022
6ea850d
feat: Add timeout constant values
liquidz Jun 5, 2022
669db97
feat: Apply timeout to antq.util.git/ls-remote*
liquidz Jun 5, 2022
111ef96
feat: Apply timeout to antq.util.maven/read-pom*
liquidz Jun 5, 2022
205873f
feat: Apply timeout to antq.ver.java/get-versions
liquidz Jun 7, 2022
41cfcac
feat: Apply timeout to antq.ver.github-tag/get-sorted-versions-by-url
liquidz Jun 7, 2022
80d96c7
chore: Set clojure.core.async.go-checking system prop while developing
liquidz Jun 20, 2022
6a9cd0d
chore: Rename default timeout env
liquidz Jun 20, 2022
ebf760c
fix: Fix gradle dep extractor to use `--project-dir` option
liquidz Jun 20, 2022
33266b0
fix: Fix util.async not to do blocking IO in go block
liquidz Jun 20, 2022
cddd6af
test: Fix test not to be affected by memoize
liquidz Jun 20, 2022
8d86942
test: Rename test resources
liquidz Jun 20, 2022
255efd2
deps: Bump kaocha to 1.67.1055
liquidz Jun 20, 2022
fdc149e
chore: Change default timeout msec
liquidz Jun 25, 2022
0b44559
deps: Bump kaocha to 1.68.1059
liquidz Jun 25, 2022
00825d5
deps: Bump build.edn to 0.4.107
liquidz Jun 25, 2022
42ab865
deps: Bump clj-kondo action
liquidz Jun 25, 2022
6297ecb
docs: Update Installing/updating Clojure CLI tool instruction
liquidz Jun 25, 2022
bdaf7d0
chore: Add description
liquidz Jun 25, 2022
67e6f83
docs: Add document for timeouts
liquidz Jun 25, 2022
bb347ae
refactor: Make inner functions private
liquidz Jun 26, 2022
9ad4980
feat: Add antq.util.exception
liquidz Jun 26, 2022
05ad48d
fix: Update fn-with-timeout to throw ex-timeout
liquidz Jun 26, 2022
f1b317f
feat: Update to show timed out message for java deps
liquidz Jun 26, 2022
0a4ec76
fix: Fix to skip ex-timeout for associating diff url
liquidz Jun 26, 2022
ca455fc
fix: Fix compare-deps to check args
liquidz Jun 26, 2022
c192ae2
feat: Update to show timed out message for git sha deps
liquidz Jun 26, 2022
152f832
feat: Update to show timed out message for git tag and sha deps
liquidz Jun 26, 2022
d920d57
feat: Update to show timed out message for github tag deps
liquidz Jun 26, 2022
2a4c540
fix: Fix to handle XmlPullParserException for read-pom
liquidz Jun 30, 2022
5cf2ccb
chore: Bump minor version
liquidz Jun 30, 2022
7f17c2c
docs: Update CHANGELOG
liquidz Jun 30, 2022
c7bd002
deps: Bump deep-diff2 to 2.3.127
liquidz Jul 1, 2022
0844fdc
deps: Bump build.edn to 0.5.116
liquidz Jul 1, 2022
50acc9d
docs: Update CHANGELOG
liquidz Jul 1, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v3
- uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2022.05.31'
version: '2022.06.22'
- run: clj-kondo --lint src:test --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'

cljstyle:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
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)
// {{{
=== Added
* https://github.com/liquidz/antq/pull/157[#157]: Added progress bar to `table` reporter.
* https://github.com/liquidz/antq/pull/158[#158]: Added environmental variables to customize timeout milli secs.
** See details link:./doc/timeout.adoc[here].

=== Changed
* https://github.com/liquidz/antq/pull/158[#158]: Applied timeouts to the following operations.
** Fetching data from Maven repositories
** Fetching data from GitHub API
** Fetching data from git repositories
* Bumped kaocha to 1.68.1059.
* Bumped deep-diff2 to 2.3.127.
* Bumped build.edn to 0.5.116.

=== Fixed
* https://github.com/liquidz/antq/pull/166[#166]: Fixed to catch `XmlPullParserExceptio`.
// }}}

== 1.7.804 (2022-06-11)
// {{{
Expand Down
27 changes: 18 additions & 9 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,26 @@ Or add the following alias to your `$HOME/.clojure/deps.edn`.
Then, run `clojure -M:outdated`.
(run `clojure -A:outdated` for Clojure CLI Tool 1.10.1.645 or earlier).

=== Clojure CLI Tools (`1.10.3.933` or later)
=== Clojure CLI Tools (`1.11.1.1139` or later)

From Clojure CLI ver `1.10.3.933`, https://clojure.org/reference/deps_and_cli#tool_install[tool] installation is supported.
From Clojure CLI ver `1.11.1.1139`, https://clojure.org/reference/deps_and_cli#tool_install[tool] installation is supported.

[source,sh]
----
# install
clojure -Ttools install com.github.liquidz/antq '{:git/tag "1.7.804"}' :as antq
# uninstall
# Install tool
clojure -Ttools install-latest :lib com.github.liquidz/antq :as antq
# Uninstall tool
clojure -Ttools remove :tool antq
# execute
# Update tool
clojure -Ttools install-latest :tool antq

# Execute
clojure -Tantq outdated
# execute with parameter
# Execute with parameter
clojure -Tantq outdated :upgrade true
# help
# Show help
clojure -A:deps -Tantq help/doc
# upgrade
# Upgrade oudated dependencies
clojure -Tantq outdated :check-clojure-tools true :upgrade true
----

Expand Down Expand Up @@ -147,6 +150,11 @@ In another way, you can use the following action.
Antq experimentally supports https://gradle.org[Gradle].
See link:./doc/gradle.adoc[here] for details.

=== Timeouts

Antq has timeouts for acquiring various information.
See link:./doc/timeout.adoc[here] for details.

== Options
=== --upgrade
Upgrade outdated versions interactively.
Expand Down Expand Up @@ -289,6 +297,7 @@ You can also upgrade them with `--upgrade` option.
* link:./doc/clojure-1.8.adoc[Antq with Clojure 1.8.0 or earlier]
* link:./doc/gradle.adoc[Work with Gradle]
* link:./doc/proxy.adoc[Run behind proxy]
* link:./doc/timeout.adoc[Timeouts]

== License

Expand Down
9 changes: 3 additions & 6 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

(def ^:private config
{:lib 'com.github.liquidz/antq
:version "1.7.{{git/commit-count}}"
:version "1.8.{{git/commit-count}}"
:description "Point out your outdated dependencies"
:main 'antq.core
:documents [{:file "CHANGELOG.adoc"
:match "Unreleased"
:action :append-after
:text "\n== {{version}} ({{now/yyyy}}-{{now/mm}}-{{now/dd}})"}
{:file "README.adoc"
:match "install com\\.github\\.liquidz/antq"
:action :replace
:text "clojure -Ttools install com.github.liquidz/antq '{:git/tag \"{{version}}\"}' :as antq"}]
:text "\n== {{version}} ({{now/yyyy}}-{{now/mm}}-{{now/dd}})"}]
:github-actions? true})

(defn jar
Expand Down
8 changes: 5 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
org.clojure/data.zip {:mvn/version "1.0.0"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
org.clojure/core.async {:mvn/version "1.5.648"}
;; NOTE: tools.deps.alpha v0.12.1098 or later does not work with CLojure 1.9.0
org.clojure/tools.deps.alpha {:mvn/version "0.12.1090"}
org.clojure/data.json {:mvn/version "2.4.0"}
Expand All @@ -25,8 +26,9 @@
:dev
{:extra-paths ["test"
"test/resources"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.66.1034"}
lambdaisland/deep-diff2 {:mvn/version "2.2.124"}}}
:extra-deps {lambdaisland/kaocha {:mvn/version "1.68.1059"}
lambdaisland/deep-diff2 {:mvn/version "2.3.127"}}
:jvm-opts ["-Dclojure.core.async.go-checking=true"]}

:nop
{:extra-deps {org.slf4j/slf4j-nop {:mvn/version "RELEASE"}}}
Expand All @@ -42,7 +44,7 @@
:main-opts ["-m" "cloverage.coverage" "--ns-exclude-regex" "leiningen.antq"]}

:build
{:deps {com.github.liquidz/build.edn {:git/tag "0.3.90" :git/sha "e3a3e31"}}
{:deps {com.github.liquidz/build.edn {:git/tag "0.5.116" :git/sha "f633fa3"}}
:ns-default build}

;; -X
Expand Down
35 changes: 35 additions & 0 deletions doc/timeout.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
= Timeouts

Antq has timeouts for acquiring various information.
These timeouts are customizable by following environmental variables.

[cols="1,4a,5a"]
|===
| Name | Default | Description

| ANTQ_DEFAULT_TIMEOUT
| `10,000`
| Unit is milli sec.


| ANTQ_LS_REMOTE_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for `git ls-remote`. +
Unit is milli sec.

| ANTQ_GITHUB_API_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for GitHub API. +
Unit is milli sec.

| ANTQ_MAVEN_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for accessing Maven repositories. +
Unit is milli sec.

| ANTQ_POM_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for reading POM. +
Unit is milli sec.

|===
37 changes: 34 additions & 3 deletions src/antq/constant.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
(ns antq.constant)
(ns antq.constant
(:require
[antq.util.env :as u.env]))

(def retry-limit 5)
(def retry-limit
"Retry count for
- antq.util.maven/read-pom
- antq.util.git/ls-remote*"
5)

(def clojure-deps-keys #{:deps :default-deps :extra-deps :override-deps :replace-deps})
(def clojure-deps-keys
"Keys for detecting dependencies in deps.edn"
#{:deps :default-deps :extra-deps :override-deps :replace-deps})

(def default-timeout-msec
(u.env/getlong "ANTQ_DEFAULT_TIMEOUT" 10000))

(def ls-remote-timeout-msec
"Timeout msec for
- antq.util.git/ls-remote*"
(u.env/getlong "ANTQ_LS_REMOTE_TIMEOUT" default-timeout-msec))

(def github-api-timeout-msec
"Timeout msec for
- antq.ver.github-tag/get-sorted-versions-by-ls-remote*"
(u.env/getlong "ANTQ_GITHUB_API_TIMEOUT" default-timeout-msec))

(def maven-timeout-msec
"Timeout msec for
- antq.ver.java/get-versions"
(u.env/getlong "ANTQ_MAVEN_TIMEOUT" default-timeout-msec))

(def pom-timeout-msec
"Timeout msec for
- antq.util.maven/read-pom*"
(u.env/getlong "ANTQ_POM_TIMEOUT" default-timeout-msec))
24 changes: 17 additions & 7 deletions src/antq/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
[antq.upgrade.leiningen]
[antq.upgrade.pom]
[antq.upgrade.shadow]
[antq.util.exception :as u.ex]
[antq.util.maven :as u.maven]
[antq.ver :as ver]
[antq.ver.git-sha]
Expand All @@ -44,7 +45,9 @@
[antq.ver.java]
[clojure.string :as str]
[clojure.tools.cli :as cli]
[version-clj.core :as version]))
[version-clj.core :as version])
(:import
clojure.lang.ExceptionInfo))

(defn- concat-assoc-fn
[opt k v]
Expand Down Expand Up @@ -117,7 +120,9 @@

(defn- assoc-versions
[dep options]
(assoc dep :_versions (ver/get-sorted-versions dep options)))
(let [res (assoc dep :_versions (ver/get-sorted-versions dep options))]
(report/run-progress dep options)
res))

(defn latest
[arg-map]
Expand Down Expand Up @@ -169,9 +174,9 @@
(let [org-deps (remove #(or (skip-artifacts? % options)
(using-release-version? %))
deps)
uniq-deps-with-vers (->> org-deps
distinct-deps
(pmap #(assoc-versions % options)))
uniq-deps (distinct-deps org-deps)
_ (report/init-progress uniq-deps options)
uniq-deps-with-vers (pmap #(assoc-versions % options) uniq-deps)
assoc-latest-version* #(assoc-latest-version % options)]
(->> org-deps
(pmap #(complete-versions-by % uniq-deps-with-vers))
Expand All @@ -181,7 +186,10 @@

(defn assoc-diff-url
[version-checked-dep]
(if-let [url (diff/get-diff-url version-checked-dep)]
(if-let [url (try (diff/get-diff-url version-checked-dep)
(catch ExceptionInfo ex
(when-not (u.ex/ex-timeout? ex)
(throw ex))))]
(assoc version-checked-dep :diff-url url)
version-checked-dep))

Expand Down Expand Up @@ -236,13 +244,15 @@

(defn antq
[options deps]
(let [deps (->> deps
(let [alog (log/start-async-logger!)
deps (->> deps
(mark-only-newest-version-flag)
(unify-deps-having-only-newest-version-flag))
outdated (->> (outdated-deps deps options)
(map assoc-diff-url)
(concat (unverified-deps deps)))]
(report/reporter outdated options)
(log/stop-async-logger! alog)
outdated))

(defn main*
Expand Down
9 changes: 6 additions & 3 deletions src/antq/dep/gradle.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

(defn- get-repositories
[file-path]
(let [{:keys [exit out]} (sh/sh gradle-command "--build-file" file-path
(let [parent-path (.getParent (io/file file-path))
{:keys [exit out]} (sh/sh gradle-command
"--project-dir" parent-path
"antq_list_repositories")]
(when (= 0 exit)
(->> (str/split-lines out)
Expand All @@ -24,8 +26,9 @@

(defn- filter-deps-from-gradle-dependencies
[file-path]
(let [{:keys [exit out]} (sh/sh gradle-command
"--build-file" file-path
(let [parent-path (.getParent (io/file file-path))
{:keys [exit out]} (sh/sh gradle-command
"--project-dir" parent-path
"--quiet"
"dependencies")]
(if (= 0 exit)
Expand Down
41 changes: 36 additions & 5 deletions src/antq/log.clj
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
(ns antq.log)
(ns antq.log
(:require
[clojure.core.async :as async]))

(defonce logger-ch nil)

(def ^:dynamic *verbose* false)

(defn stop-async-logger!
[logger-end-ch]
(when logger-ch
(async/>!! logger-ch ::eol)
(async/<!! logger-end-ch)
(async/close! logger-ch)
(async/close! logger-end-ch)
(alter-var-root #'logger-ch (fn [_] nil))))

(defn start-async-logger!
[]
(let [end-ch (async/chan)]
(alter-var-root #'logger-ch (fn [_] (async/chan)))
(async/go-loop []
(let [v (async/<! logger-ch)]
(when (string? v)
(print v)
(flush))
(if (= ::eol v)
(async/>! end-ch ::end)
(recur))))
end-ch))

(defn info
[s]
(println s))

(defn warning
[s]
(when *verbose*
(binding [*out* *err*]
(println s))))

(defn error
[s]
(binding [*out* *err*]
(println s)))

(defn warning
(defn async-print
[s]
(when *verbose*
(binding [*out* *err*]
(println s))))
(async/>!! logger-ch s))
12 changes: 12 additions & 0 deletions src/antq/report.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@
(defmethod reporter :default
[_ options]
(log/error (str "Unknown reporter: " (:reporter options))))

(defmulti init-progress
(fn [_deps options]
(:reporter options)))

(defmethod init-progress :default [_ _] nil)

(defmulti run-progress
(fn [_dep options]
(:reporter options)))

(defmethod run-progress :default [_ _] nil)
Loading