Skip to content

Commit

Permalink
Merge pull request #571 from clj-commons/lread-ci-ci-oh
Browse files Browse the repository at this point in the history
ci changes
  • Loading branch information
lread authored May 3, 2024
2 parents 676e08d + 086e590 commit 08e7114
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 17 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Test

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
setup:
Expand Down Expand Up @@ -71,6 +77,30 @@ jobs:
if: ${{ matrix.os == 'ubuntu' }}
run: sudo apt-get -y install fluxbox

# No longer pre-installed on macOS github action runners
- name: Install Image Magick on macOS
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'imagemagick') }}
run: brew install imagemagick

# No longer pre-installed on macOS github action runners
- name: Install Microsoft Edge on macOS
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'edge') }}
run: |
brew install --cask microsoft-edge
EDGE_VERSION=$(defaults read /Applications/Microsoft\ Edge.app/Contents/Info CFBundleShortVersionString)
DRIVER_URL="https://msedgedriver.azureedge.net/${EDGE_VERSION}/edgedriver_mac64_m1.zip"
curl -o msedgedriver.zip $DRIVER_URL
mkdir $RUNNER_TEMP/edgedriver
unzip msedgedriver.zip -d $RUNNER_TEMP/edgedriver
echo "$RUNNER_TEMP/edgedriver" >> $GITHUB_PATH
# No longer pre-installed on macOS github action runners
- name: Install Firefox on macOS
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'firefox') }}
run: |
brew install --cask firefox
brew install geckodriver
- uses: actions/checkout@v4

- name: Clojure deps cache
Expand Down
7 changes: 4 additions & 3 deletions doc/01-user-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Etaoin's test suite covers the following OSes and browsers for both Clojure and
| -
| -

| macOS
| macOS ^1^
| yes
| yes
| yes
Expand All @@ -68,7 +68,8 @@ Etaoin's test suite covers the following OSes and browsers for both Clojure and

|===

NOTE: We did once test against PhantomJS, but since work has long ago stopped on this project, we have dropped testing
1. Our GitHub Actions macOS tests run on silicon (aka arm64, aarch64 or M*) hardware
2. We did once test against PhantomJS, but since work has long ago stopped on this project, we have dropped testing

== Installation

Expand Down Expand Up @@ -2097,7 +2098,7 @@ a| Random port when lanching local WebDriver process, else varies by vendor:
a| `:webdriver-url` for *WebDriver* process. When:

* omitted, creates a new local WebDriver process (unless `:host` was specified).
* specified, attempts to connect to an existing running WebDriver process.
* specified, attempts to connect to an existing running WebDriver process.

See <<connecting-existing>>.

Expand Down
30 changes: 23 additions & 7 deletions script/test_matrix.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
(when (= "ubuntu" os) "--launch-virtual-display")]
(remove nil?)
(string/join " "))
:needs (case id
"unit"
["chrome" "firefox"]

"api"
(conj ["imagemagick"] browser)

"ide"
[browser])
:desc (->> [id os browser (if (= "jvm" platform)
(str "jdk" jdk-version)
platform)]
Expand All @@ -27,14 +36,18 @@
:cmd (if (= "ubuntu" os)
"bb test-doc --launch-virtual-display"
"bb test-doc")
:needs ["chrome" "firefox"]
:desc (str "test-doc " os " jdk" jdk-version)} )

(defn- github-actions-matrix []
(let [oses ["macos" "ubuntu" "windows"]
(let [os-jdks {"ubuntu" ["8" "11" "17" "21"]
;; macOS on GitHub Actions is now arm-based and does not include jdk8
"macos" ["11" "17" "21"]
"windows" ["8" "11" "17" "21"]}
oses (keys os-jdks)
ide-browsers ["chrome" "firefox"]
api-browsers ["chrome" "firefox" "edge" "safari"]
platforms ["jvm" "bb"]
jdk-versions ["8" "11" "17" "21"]
default-opts {:jdk-version "21"}]
(->> (concat
(for [os oses
Expand All @@ -43,7 +56,8 @@
(for [os oses
platform platforms
browser ide-browsers]
(test-def (merge default-opts {:os os :id "ide" :platform platform :browser browser})))
(test-def (merge default-opts
{:os os :id "ide" :platform platform :browser browser})))
(for [os oses
platform platforms
browser api-browsers
Expand All @@ -52,12 +66,14 @@
(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
jdk-version (get os-jdks "ubuntu")
:when (not= jdk-version (:jdk-version default-opts))]
(test-def {:jdk-version jdk-version :os "ubuntu" :id id :platform "jvm" :browser "firefox"}))
(test-def {:jdk-version jdk-version :os "ubuntu" :id id
:platform "jvm"
:browser (when (not= "unit" id) "firefox")}))
(for [os oses]
(test-doc (merge default-opts {:os os})))
(for [jdk-version jdk-versions
(for [jdk-version (get os-jdks "ubuntu")
:when (not= jdk-version (:jdk-version default-opts))]
(test-doc {:jdk-version jdk-version :os "ubuntu"})))
(sort-by (juxt #(parse-long (:jdk-version %)) :desc))
Expand Down Expand Up @@ -91,7 +107,7 @@
(status/line :detail
(if (= "json" (:format opts))
(json/generate-string matrix)
(doric/table [:os :jdk-version :cmd :desc] matrix)))))))
(doric/table [:os :jdk-version :cmd :needs :desc] matrix)))))))

(main/when-invoked-as-script
(apply -main *command-line-args*))
32 changes: 26 additions & 6 deletions test/etaoin/unit/unit_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[babashka.fs :as fs]
[clojure.spec.alpha :as s]
[clojure.test :refer [deftest is testing]]
[clojure.tools.logging :as log]
[etaoin.api :as e]
[etaoin.ide.flow :as ide]
[etaoin.ide.impl.spec :as spec]
Expand Down Expand Up @@ -108,21 +109,35 @@

(deftest test-retry-launch
(testing "give up after max tries"
(let [run-calls (atom 0)]
(let [run-calls (atom 0)
warnings-logged (atom [])
ex (ex-info "firefox badness" {})]
(with-redefs
[etaoin.impl.proc/run (fn [_ _]
(swap! run-calls inc)
{:some :process})
e/running? (fn [_] (throw (ex-info "firefox badness" {})))]
e/running? (fn [_] (throw ex ))
log/log* (fn [_logger level _throwable message]
(swap! warnings-logged conj [level message]))]
(is (thrown-with-msg?
ExceptionInfo
#"gave up trying to launch :firefox after 8 tries"
(e/with-firefox {:webdriver-failed-launch-retries 7} driver
driver)))
(is (= 8 @run-calls)))))
(is (= 8 @run-calls) "run calls")
(is (= [[:warn "unexpected exception occurred launching :firefox, try 1 (of a max of 8)"]
[:warn "unexpected exception occurred launching :firefox, try 2 (of a max of 8)"]
[:warn "unexpected exception occurred launching :firefox, try 3 (of a max of 8)"]
[:warn "unexpected exception occurred launching :firefox, try 4 (of a max of 8)"]
[:warn "unexpected exception occurred launching :firefox, try 5 (of a max of 8)"]
[:warn "unexpected exception occurred launching :firefox, try 6 (of a max of 8)"]
[:warn "unexpected exception occurred launching :firefox, try 7 (of a max of 8)"]]
@warnings-logged) "warnings logged"))))
(testing "succeed before max tries"
(let [run-calls (atom 0)
succeed-when-calls 3]
succeed-when-calls 3
warnings-logged (atom [])
ex (ex-info "safari badness" {})]
(with-redefs
[etaoin.impl.proc/run (fn [_ _]
(swap! run-calls inc)
Expand All @@ -132,8 +147,10 @@
e/delete-session identity
e/running? (fn [_]
(if (< @run-calls succeed-when-calls)
(throw (ex-info "safari badness" {}))
(throw ex)
true))
log/log* (fn [_logger level _throwable message]
(swap! warnings-logged conj [level message]))
util/get-free-port (constantly 12345)]
;; safari driver has a default of 4 retries
(e/with-safari driver
Expand All @@ -146,7 +163,10 @@
:session "session-key"
:type :safari,
:url "http://127.0.0.1:12345"} driver)))
(is (= succeed-when-calls @run-calls))))))
(is (= succeed-when-calls @run-calls))
(is (= [[:warn "unexpected exception occurred launching :safari, try 1 (of a max of 5)"]
[:warn "unexpected exception occurred launching :safari, try 2 (of a max of 5)"]]
@warnings-logged) "warnings logged")))))

(deftest test-actions
(let [keyboard (-> (e/make-key-input)
Expand Down

0 comments on commit 08e7114

Please sign in to comment.