From 0e3a11ed55a516d47774786f2e0d9453ae6f24ab Mon Sep 17 00:00:00 2001 From: Lee Read Date: Sun, 17 Mar 2024 18:45:44 -0400 Subject: [PATCH] Fix jdk8 compatibility (#565) Addendum for #552 Add jdk variants for CI. Default to jdk 21 but also sanity test on jdks 8, 11 and 17. Fixes #560 --- .github/workflows/test.yml | 2 +- script/test_matrix.clj | 45 ++++++++++++++++++++++++++------------ src/etaoin/api.clj | 2 +- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 782e3a14..546031de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,7 +87,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '11' + java-version: ${{ matrix.jdk-version }} - name: Install Clojure Tools uses: DeLaGuardo/setup-clojure@12.5 diff --git a/script/test_matrix.clj b/script/test_matrix.clj index f287147a..34781599 100644 --- a/script/test_matrix.clj +++ b/script/test_matrix.clj @@ -6,45 +6,62 @@ [helper.main :as main] [lread.status-line :as status])) -(defn- test-def [os id platform browser] +(defn- test-def [{:keys [os id platform browser jdk-version]}] {:os os + :jdk-version jdk-version :cmd (->> ["bb" (str "test:" platform) "--suites" id (when browser (str "--browsers " browser)) (when (= "ubuntu" os) "--launch-virtual-display")] (remove nil?) (string/join " ")) - :desc (->> [id os browser platform] + :desc (->> [id os browser (if (= "jvm" platform) + (str "jdk" jdk-version) + platform)] (remove nil?) (string/join " "))}) +(defn- test-doc [{:keys [os jdk-version]}] + {:os os + :jdk-version jdk-version + :cmd (if (= "ubuntu" os) + "bb test-doc --launch-virtual-display" + "bb test-doc") + :desc (str "test-doc " os " jdk" jdk-version)} ) + (defn- github-actions-matrix [] (let [oses ["macos" "ubuntu" "windows"] ide-browsers ["chrome" "firefox"] api-browsers ["chrome" "firefox" "edge" "safari"] - platforms ["jvm" "bb"]] + platforms ["jvm" "bb"] + jdk-versions ["8" "11" "17" "21"] + default-opts {:jdk-version "21"}] (->> (concat (for [os oses platform platforms] - (test-def os "unit" platform nil)) + (test-def (merge default-opts {:os os :id "unit" :platform platform}))) (for [os oses platform platforms browser ide-browsers] - (test-def os "ide" platform browser)) + (test-def (merge default-opts {:os os :id "ide" :platform platform :browser browser}))) (for [os oses platform platforms browser api-browsers :when (not (or (and (= "ubuntu" os) (some #{browser} ["edge" "safari"])) (and (= "windows" os) (= "safari" browser))))] - (test-def os "api" platform browser)) + (test-def (merge default-opts {:os os :id "api" :platform platform :browser browser}))) + ;; for jdk coverage we don't need to run across all oses and browsers + (for [id ["unit" "ide" "api"] + jdk-version jdk-versions + :when (not= jdk-version (:jdk-version default-opts))] + (test-def {:jdk-version jdk-version :os "ubuntu" :id id :platform "jvm" :browser "firefox"})) (for [os oses] - {:os os - :cmd (if (= "ubuntu" os) - "bb test-doc --launch-virtual-display" - "bb test-doc") - :desc (str "test-doc " os)})) - (sort-by :desc) - (into [{:os "ubuntu" :cmd "bb lint" :desc "lint"}])))) + (test-doc (merge default-opts {:os os}))) + (for [jdk-version jdk-versions + :when (not= jdk-version (:jdk-version default-opts))] + (test-doc {:jdk-version jdk-version :os "ubuntu"}))) + (sort-by (juxt #(parse-long (:jdk-version %)) :desc)) + (into [(merge default-opts {:os "ubuntu" :cmd "bb lint" :desc "lint"})])))) (def valid-formats ["json" "table"]) (def cli-spec {:help {:desc "This usage help"} @@ -74,7 +91,7 @@ (status/line :detail (if (= "json" (:format opts)) (json/generate-string matrix) - (doric/table [:os :cmd :desc] matrix))))))) + (doric/table [:os :jdk-version :cmd :desc] matrix))))))) (main/when-invoked-as-script (apply -main *command-line-args*)) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index cfb5c2c9..6d795483 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -2818,7 +2818,7 @@ .codePoints .iterator iterator-seq - (map #(Character/toString %)))) + (map #(String. (Character/toChars %))))) (defn- make-input* [text & more] (codepoints (apply str text more)))