-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: user guide examples now os agnostic (#546)
* docs: user guide chord examples now os-agnostic Keyboard chord examples formerly macOS specific. Add Ubuntu and Windows for test-doc to CI matrix. Weirdness: when testing locally on Linux, for sessions with no real interaction, was sporadically getting socket timeout when trying to quit session. For now, introduce a couple of waits in doc examples to appease the mystery. I expect I'll need to tweak a thing or two to get this working on CI. Do I need to setup a virtual display for Ubuntu? * tests: support running test-doc under linux/docker Add virtual display support to test-doc. Extract out common support to new script/virtual_display.clj that is now shared between test and test-doc scripts. Adjust dev docker image to: - run from a non-root user - copy over etaoin sources so that they are usable by this non-root user - mimic Selenium docker images by always invoking chrome with the --no-sandbox option * docs: changelog [skip ci] Closes #536
- Loading branch information
Showing
13 changed files
with
277 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(ns docker-entry | ||
;; keep deps to built in to avoid having to bring over more sources to docker image | ||
(:require [babashka.fs :as fs] | ||
[babashka.process :as proc])) | ||
|
||
(defn copy-etaoin-sources | ||
"If the conditions are right, copy over mounted etaoin sources, if not warn." | ||
[] | ||
;; some sanity checks first | ||
(let [errors (reduce (fn [errors check] | ||
(if-let [error (check)] | ||
(conj errors error) | ||
errors)) | ||
[] | ||
[#(when (not (fs/exists? "/etaoin")) | ||
"/etaoin sources not mounted") | ||
#(when (not (= "/home/etaoin-user/etaoin" (str (fs/cwd)))) | ||
"expected cwd to be /home/etaoin-user/etaoin")])] | ||
|
||
(if (seq errors) | ||
(do | ||
(println "* WARNING: etaoin sources not copied:") | ||
(run! #(println "-" %) errors)) | ||
(do | ||
(println "copying mounted etaoin sources") | ||
(fs/copy-tree "/etaoin" "."))))) | ||
|
||
(defn -main | ||
"Docker image entry point script to run at docker image launch. | ||
We cannot simply use a -v mounted /etaoin due to permissions, so we copy over | ||
the a mounted /etaoin to a spot where we do have full rights." | ||
[& args] | ||
(copy-etaoin-sources) | ||
;; and now run provided command, else bash if none specified | ||
(let [cmd (if (seq args) args "/bin/bash")] | ||
(println "running command:" cmd) | ||
(proc/exec cmd))) | ||
|
||
(when (= *file* (System/getProperty "babashka.file")) | ||
(apply -main *command-line-args*)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(ns helper.virtual-display | ||
(:require [babashka.fs :as fs] | ||
[babashka.process :as process] | ||
[helper.shell :as shell] | ||
[lread.status-line :as status])) | ||
|
||
(defn- launch-xvfb [] | ||
(if (fs/which "Xvfb") | ||
(process/process "Xvfb :99 -screen 0 1024x768x24" {:out (fs/file "/dev/null") | ||
:err (fs/file "/dev/null")}) | ||
(status/die 1 "Xvfb not found")) | ||
(let [deadline (+ (System/currentTimeMillis) 10000)] | ||
(loop [] | ||
(let [{:keys [exit]} (shell/command {:out (fs/file "/dev/null") | ||
:err (fs/file "/dev/null") | ||
:continue true} | ||
"xdpyinfo -display :99")] | ||
(if (zero? exit) | ||
(status/line :detail "Xvfb process looks good.") | ||
(if (> (System/currentTimeMillis) deadline) | ||
(status/die 1 "Failed to get status from Xvfb process") | ||
(do | ||
(status/line :detail "Waiting for Xvfb process.") | ||
(Thread/sleep 500) | ||
(recur)))))))) | ||
|
||
(defn- launch-fluxbox [] | ||
(if (fs/which "fluxbox") | ||
(process/process "fluxbox -display :99" {:out (fs/file "/dev/null") | ||
:err (fs/file "/dev/null")}) | ||
(status/die 1 "fluxbox not found"))) | ||
|
||
(defn launch [] | ||
(status/line :head "Launching virtual display") | ||
(launch-xvfb) | ||
(launch-fluxbox)) | ||
|
||
(defn extra-env "Returns env vars required for programs using launched virtual display" | ||
[] | ||
{"DISPLAY" ":99.0"}) |
Oops, something went wrong.