Skip to content

Commit 08e7114

Browse files
authored
Merge pull request #571 from clj-commons/lread-ci-ci-oh
ci changes
2 parents 676e08d + 086e590 commit 08e7114

File tree

4 files changed

+84
-17
lines changed

4 files changed

+84
-17
lines changed

.github/workflows/test.yml

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
410

511
jobs:
612
setup:
@@ -71,6 +77,30 @@ jobs:
7177
if: ${{ matrix.os == 'ubuntu' }}
7278
run: sudo apt-get -y install fluxbox
7379

80+
# No longer pre-installed on macOS github action runners
81+
- name: Install Image Magick on macOS
82+
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'imagemagick') }}
83+
run: brew install imagemagick
84+
85+
# No longer pre-installed on macOS github action runners
86+
- name: Install Microsoft Edge on macOS
87+
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'edge') }}
88+
run: |
89+
brew install --cask microsoft-edge
90+
EDGE_VERSION=$(defaults read /Applications/Microsoft\ Edge.app/Contents/Info CFBundleShortVersionString)
91+
DRIVER_URL="https://msedgedriver.azureedge.net/${EDGE_VERSION}/edgedriver_mac64_m1.zip"
92+
curl -o msedgedriver.zip $DRIVER_URL
93+
mkdir $RUNNER_TEMP/edgedriver
94+
unzip msedgedriver.zip -d $RUNNER_TEMP/edgedriver
95+
echo "$RUNNER_TEMP/edgedriver" >> $GITHUB_PATH
96+
97+
# No longer pre-installed on macOS github action runners
98+
- name: Install Firefox on macOS
99+
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'firefox') }}
100+
run: |
101+
brew install --cask firefox
102+
brew install geckodriver
103+
74104
- uses: actions/checkout@v4
75105

76106
- name: Clojure deps cache

doc/01-user-guide.adoc

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Etaoin's test suite covers the following OSes and browsers for both Clojure and
5454
| -
5555
| -
5656

57-
| macOS
57+
| macOS ^1^
5858
| yes
5959
| yes
6060
| yes
@@ -68,7 +68,8 @@ Etaoin's test suite covers the following OSes and browsers for both Clojure and
6868

6969
|===
7070

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

7374
== Installation
7475

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

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

21022103
See <<connecting-existing>>.
21032104

script/test_matrix.clj

+23-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
(when (= "ubuntu" os) "--launch-virtual-display")]
1616
(remove nil?)
1717
(string/join " "))
18+
:needs (case id
19+
"unit"
20+
["chrome" "firefox"]
21+
22+
"api"
23+
(conj ["imagemagick"] browser)
24+
25+
"ide"
26+
[browser])
1827
:desc (->> [id os browser (if (= "jvm" platform)
1928
(str "jdk" jdk-version)
2029
platform)]
@@ -27,14 +36,18 @@
2736
:cmd (if (= "ubuntu" os)
2837
"bb test-doc --launch-virtual-display"
2938
"bb test-doc")
39+
:needs ["chrome" "firefox"]
3040
:desc (str "test-doc " os " jdk" jdk-version)} )
3141

3242
(defn- github-actions-matrix []
33-
(let [oses ["macos" "ubuntu" "windows"]
43+
(let [os-jdks {"ubuntu" ["8" "11" "17" "21"]
44+
;; macOS on GitHub Actions is now arm-based and does not include jdk8
45+
"macos" ["11" "17" "21"]
46+
"windows" ["8" "11" "17" "21"]}
47+
oses (keys os-jdks)
3448
ide-browsers ["chrome" "firefox"]
3549
api-browsers ["chrome" "firefox" "edge" "safari"]
3650
platforms ["jvm" "bb"]
37-
jdk-versions ["8" "11" "17" "21"]
3851
default-opts {:jdk-version "21"}]
3952
(->> (concat
4053
(for [os oses
@@ -43,7 +56,8 @@
4356
(for [os oses
4457
platform platforms
4558
browser ide-browsers]
46-
(test-def (merge default-opts {:os os :id "ide" :platform platform :browser browser})))
59+
(test-def (merge default-opts
60+
{:os os :id "ide" :platform platform :browser browser})))
4761
(for [os oses
4862
platform platforms
4963
browser api-browsers
@@ -52,12 +66,14 @@
5266
(test-def (merge default-opts {:os os :id "api" :platform platform :browser browser})))
5367
;; for jdk coverage we don't need to run across all oses and browsers
5468
(for [id ["unit" "ide" "api"]
55-
jdk-version jdk-versions
69+
jdk-version (get os-jdks "ubuntu")
5670
:when (not= jdk-version (:jdk-version default-opts))]
57-
(test-def {:jdk-version jdk-version :os "ubuntu" :id id :platform "jvm" :browser "firefox"}))
71+
(test-def {:jdk-version jdk-version :os "ubuntu" :id id
72+
:platform "jvm"
73+
:browser (when (not= "unit" id) "firefox")}))
5874
(for [os oses]
5975
(test-doc (merge default-opts {:os os})))
60-
(for [jdk-version jdk-versions
76+
(for [jdk-version (get os-jdks "ubuntu")
6177
:when (not= jdk-version (:jdk-version default-opts))]
6278
(test-doc {:jdk-version jdk-version :os "ubuntu"})))
6379
(sort-by (juxt #(parse-long (:jdk-version %)) :desc))
@@ -91,7 +107,7 @@
91107
(status/line :detail
92108
(if (= "json" (:format opts))
93109
(json/generate-string matrix)
94-
(doric/table [:os :jdk-version :cmd :desc] matrix)))))))
110+
(doric/table [:os :jdk-version :cmd :needs :desc] matrix)))))))
95111

96112
(main/when-invoked-as-script
97113
(apply -main *command-line-args*))

test/etaoin/unit/unit_test.clj

+26-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[babashka.fs :as fs]
44
[clojure.spec.alpha :as s]
55
[clojure.test :refer [deftest is testing]]
6+
[clojure.tools.logging :as log]
67
[etaoin.api :as e]
78
[etaoin.ide.flow :as ide]
89
[etaoin.ide.impl.spec :as spec]
@@ -108,21 +109,35 @@
108109

109110
(deftest test-retry-launch
110111
(testing "give up after max tries"
111-
(let [run-calls (atom 0)]
112+
(let [run-calls (atom 0)
113+
warnings-logged (atom [])
114+
ex (ex-info "firefox badness" {})]
112115
(with-redefs
113116
[etaoin.impl.proc/run (fn [_ _]
114117
(swap! run-calls inc)
115118
{:some :process})
116-
e/running? (fn [_] (throw (ex-info "firefox badness" {})))]
119+
e/running? (fn [_] (throw ex ))
120+
log/log* (fn [_logger level _throwable message]
121+
(swap! warnings-logged conj [level message]))]
117122
(is (thrown-with-msg?
118123
ExceptionInfo
119124
#"gave up trying to launch :firefox after 8 tries"
120125
(e/with-firefox {:webdriver-failed-launch-retries 7} driver
121126
driver)))
122-
(is (= 8 @run-calls)))))
127+
(is (= 8 @run-calls) "run calls")
128+
(is (= [[:warn "unexpected exception occurred launching :firefox, try 1 (of a max of 8)"]
129+
[:warn "unexpected exception occurred launching :firefox, try 2 (of a max of 8)"]
130+
[:warn "unexpected exception occurred launching :firefox, try 3 (of a max of 8)"]
131+
[:warn "unexpected exception occurred launching :firefox, try 4 (of a max of 8)"]
132+
[:warn "unexpected exception occurred launching :firefox, try 5 (of a max of 8)"]
133+
[:warn "unexpected exception occurred launching :firefox, try 6 (of a max of 8)"]
134+
[:warn "unexpected exception occurred launching :firefox, try 7 (of a max of 8)"]]
135+
@warnings-logged) "warnings logged"))))
123136
(testing "succeed before max tries"
124137
(let [run-calls (atom 0)
125-
succeed-when-calls 3]
138+
succeed-when-calls 3
139+
warnings-logged (atom [])
140+
ex (ex-info "safari badness" {})]
126141
(with-redefs
127142
[etaoin.impl.proc/run (fn [_ _]
128143
(swap! run-calls inc)
@@ -132,8 +147,10 @@
132147
e/delete-session identity
133148
e/running? (fn [_]
134149
(if (< @run-calls succeed-when-calls)
135-
(throw (ex-info "safari badness" {}))
150+
(throw ex)
136151
true))
152+
log/log* (fn [_logger level _throwable message]
153+
(swap! warnings-logged conj [level message]))
137154
util/get-free-port (constantly 12345)]
138155
;; safari driver has a default of 4 retries
139156
(e/with-safari driver
@@ -146,7 +163,10 @@
146163
:session "session-key"
147164
:type :safari,
148165
:url "http://127.0.0.1:12345"} driver)))
149-
(is (= succeed-when-calls @run-calls))))))
166+
(is (= succeed-when-calls @run-calls))
167+
(is (= [[:warn "unexpected exception occurred launching :safari, try 1 (of a max of 5)"]
168+
[:warn "unexpected exception occurred launching :safari, try 2 (of a max of 5)"]]
169+
@warnings-logged) "warnings logged")))))
150170

151171
(deftest test-actions
152172
(let [keyboard (-> (e/make-key-input)

0 commit comments

Comments
 (0)