Skip to content

Commit

Permalink
Merge pull request #434 from lread/lread-move-to-deps-edn
Browse files Browse the repository at this point in the history
Switch from lein to clojure tools cli
  • Loading branch information
lread authored May 22, 2022
2 parents f53a1c4 + 8ed32fa commit f8cc870
Show file tree
Hide file tree
Showing 34 changed files with 163 additions and 128 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
~/.m2/repository
~/.deps.clj
~/.gitlibs
key: cljdeps-${{ hashFiles('project.clj, bb.edn') }}
restore-keys: ${{ runner.os }}-cljdeps-
key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }}
restore-keys: cljdeps-

- name: "Setup Java"
uses: actions/setup-java@v3
Expand All @@ -35,13 +35,10 @@ jobs:
uses: DeLaGuardo/[email protected]
with:
bb: 'latest'
lein: 'latest'

# This assumes downloaded deps are same for all OSes
- name: Bring down deps
run: |
lein deps
bb --version
run: bb download-deps

- id: set-tests
name: Set test var for matrix
Expand Down Expand Up @@ -69,8 +66,8 @@ jobs:
~/.m2/repository
~/.deps.clj
~/.gitlibs
key: cljdeps-${{ hashFiles('project.clj, bb.edn') }}
restore-keys: ${{ runner.os }}-cljdeps-
key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }}
restore-keys: cljdeps-

- name: "Setup Java"
uses: actions/setup-java@v3
Expand All @@ -82,7 +79,6 @@ jobs:
uses: DeLaGuardo/[email protected]
with:
bb: 'latest'
lein: 'latest'

- name: Tools versions
run: bb tools-versions
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
Expand All @@ -23,3 +22,5 @@ build.xml
.cache
# VSCode Calva extension
/.calva
# Clojure tools cli classpath cache
/.cpcache
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Other Changes
* https://github.com/clj-commons/etaoin/issues/402[#402]: Only send body for webdriver `POST` requests to appease `safaridriver`
* https://github.com/clj-commons/etaoin/issues/403[#403]: The `select` fn now clicks on the `select` element before clicking the `option` element to appease `safaridriver`
* https://github.com/clj-commons/etaoin/issues/408[#408]: Fix `switch-window` for `msedgedriver`
* https://github.com/clj-commons/etaoin/issues/432[#432]: Switched from `project.clj` to `deps.edn`.
This will allow for easier testing of unreleased versions of Etaoin via git deps.
It also unconvered that our minimum Clojure version was 1.10, instead of the advertised v1.9.
Fixed.
* Docs
** https://github.com/clj-commons/etaoin/issues/393[#393]: Add changelog
** https://github.com/clj-commons/etaoin/issues/396[#396]: Move from Markdown to AsciiDoc
Expand Down
33 changes: 6 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@

repl:
lein repl

repl-1.9:
lein with-profile +1.9 repl

.PHONY: test
test:
lein test

orig:
find . -name '*.orig' -delete

.PHONY: tags
tags:
ctags -e -R ./src

deploy:
lein deploy clojars

.PHONY: release
release:
lein release
;; TODO: lread move to bb tasks

.PHONY: kill
kill:
Expand All @@ -30,9 +7,9 @@ kill:
pkill safaridriver || true
pkill phantomjs || true


IMAGE := etaoin

;; TODO: lread: have never tried, test, fix if necessary
.PHONY: docker-build
docker-build:
docker build --no-cache -t ${IMAGE}:latest .
Expand All @@ -43,6 +20,7 @@ check-host:
$(error The HOST variable is not set, please do `export HOST=$$HOST` first)
endif

;; TODO: lread: have never tried, test, fix if necessary
# works only on mac + quartz
.PHONY: docker-test-display
docker-test-display: check-host
Expand All @@ -51,12 +29,13 @@ docker-test-display: check-host
-v ${CURDIR}:/etaoin \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$(HOST):0 \
-w /etaoin ${IMAGE}:latest \
lein test || \
bb test all || \
xhost -

;; TODO: lread: have never tried, test, fix if necessary
.PHONY: docker-test
docker-test:
docker run --rm \
-v ${CURDIR}:/etaoin \
-w /etaoin ${IMAGE}:latest \
lein test
bb test all
14 changes: 8 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ You may run tests for this library by launching:

[source,bash]
----
lein test
bb test all
----

You'll see browser windows open and close in series.
Expand Down Expand Up @@ -1870,7 +1870,9 @@ Once an error occurs, you will find a PNG image that represents your browser pag

Since UI tests may take lots of time to pass, it's definitely a good practice to pass both server and UI tests independently from each other.

First, add `+^:integration+` tag to all the tests that are run inder the browser like follows:
If you are using lneiningen, here are a few tips.

First, add `+^:integration+` tag to all the tests that are run under the browser like follows:

[source,clojure]
----
Expand All @@ -1896,7 +1898,7 @@ To run integration tests, launch `lein test :integration`.
The main difference between a program and a human is that the first one operates very fast.
It means so fast, that sometimes a browser cannot render new HTML in time.
So after each action you need to put `wait-<something>` function that just polls a browser checking for a predicate.
O just `(wait <seconds>)` if you don't care about optimization.
Or just `(wait <seconds>)` if you don't care about optimization.

=== Check whether a file has been downloaded

Expand Down Expand Up @@ -1986,11 +1988,11 @@ Everything related to the IDE is stored under the `etaoin.ide` package.
=== CLI arguments

You may also run a script from the command line.
Here is the `lein run` example:
Here is a `clojure` example:

[source,shell]
----
lein run -m etaoin.ide.main -d firefox -p '{:port 8888 :args ["--no-sandbox"]}' -r ide/test.side
clojure -M -m etaoin.ide.main -d firefox -p '{:port 8888 :args ["--no-sandbox"]}' -r ide/test.side
----

As well as from an uberjar.
Expand All @@ -2001,7 +2003,7 @@ In this case, Etaoin must be in the primary dependencies, not the `:dev` or `:te
java -cp .../poject.jar -m etaoin.ide.main -d firefox -p '{:port 8888}' -f ide/test.side
----

We support the following arguments (check them out using the `lein run -m etaoin.ide.main -h` command):
We support the following arguments (check them out using the `clojure -M -m etaoin.ide.main -h` command):

----
-d, --driver-name name :chrome The name of driver. The default is `:chrome`
Expand Down
1 change: 1 addition & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
:leave (let [{:keys [name]} (current-task)] (status/line :detail "\nTASK %s done." name))

;; commands
download-deps {:task download-deps/-main :doc "download all deps (useful for CI prep)"}
tools-versions {:task tools-versions/-main :doc "report on tools versions"}
test {:task test/-main :doc "run all or a subset of tests, use --help for args"}}}
14 changes: 14 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.9.0"} ;; min clojure version
babashka/fs {:mvn/version "0.1.6"}
clj-http/clj-http {:mvn/version "3.10.1"}
cheshire/cheshire {:mvn/version "5.9.0"}
org.clojure/tools.cli {:mvn/version "1.0.194"}
org.clojure/tools.logging {:mvn/version "0.3.1"}}
:aliases
{:1.11 {:replace-deps {org.clojure/clojure {:mvn/version "1.11.1"}}}
:debug {:extra-paths ["env/dev/resources"]}
:test {:extra-paths ["test" "env/test/resources"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
ch.qos.logback/logback-classic {:mvn/version "1.3.0-alpha16"}}
:main-opts ["-m" "cognitect.test-runner"]}}}
5 changes: 0 additions & 5 deletions env/dev/resources/log4j.properties

This file was deleted.

19 changes: 19 additions & 0 deletions env/dev/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<configuration>
<!-- Stop output INFO at start -->
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date %-5level %logger{36} - %message%n</pattern>
</encoder>
</appender>

<logger name="etaoin" level="debug" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>

</configuration>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions env/test/resources/log4j.properties

This file was deleted.

19 changes: 19 additions & 0 deletions env/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<configuration>
<!-- Stop output INFO at start -->
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date %-5level %logger{36} - %message%n</pattern>
</encoder>
</appender>

<logger name="etaoin" level="info" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<root level="info">
<appender-ref ref="STDOUT"/>
</root>

</configuration>
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>etaoin</name>
<description>Pure Clojure Webdriver protocol implementation</description>
<url>https://github.com/clj-commons/etaoin</url>
<licenses>
<license>
<name>Eclipse Public License</name>
<url>http://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>
<scm>
<url>https://github.com/clj-commons/etaoin</url>
<connection>scm:git:git://github.com/clj-commons/etaoin.git</connection>
<developerConnection>scm:git:ssh://[email protected]/clj-commons/etaoin.git</developerConnection>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>clojars</id>
<name>Clojars repository</name>
<url>https://clojars.org/repo</url>
</repository>
</distributionManagement>
</project>
53 changes: 0 additions & 53 deletions project.clj

This file was deleted.

22 changes: 22 additions & 0 deletions script/download_deps.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(ns download-deps
(:require [clojure.edn :as edn]
[helper.main :as main]
[helper.shell :as shell]
[lread.status-line :as status]))

;; clojure has a -P command, but to bring down all deps we need to specify all aliases
;; bb deps will be brought down just from running bb (which assumedly is how this code is run)

(defn -main [& args]
(when (main/doc-arg-opt args)
(let [aliases (->> "deps.edn"
slurp
edn/read-string
:aliases
keys)]
;; one at a time because aliases with :replace-deps will... well... you know.
(status/line :detail "Bring down default deps")
(shell/clojure "-P")
(doseq [a aliases]
(status/line :detail "Bring down deps for alias: %s" a)
(shell/clojure "-P" (str "-M" a))))))
Loading

0 comments on commit f8cc870

Please sign in to comment.