Skip to content

Commit

Permalink
get cljs test running in github
Browse files Browse the repository at this point in the history
  • Loading branch information
henryw374 committed Jan 15, 2024
1 parent dc22ce9 commit ee407fd
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 108 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ jobs:
with:
cli: 1.11.1.1155 # Clojure CLI based on tools.deps

#- name: Run Clj Unit tests
# run: make test-clj

- name: Install Chrome
uses: browser-actions/setup-chrome@latest

- name: Generate library code
run: make generate-all

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generate-all:
clojure -Adev -X com.widdindustries.gen.gen.tempo/generate-all
test-cljs:
clojure -Adev -X com.widdindustries.tiado-cljs2/tests-ci-shadow :compile-mode :release
clojure -Adev -X dev/tests-ci-shadow :compile-mode :release
test-clj:
clojure -Adev -X dev/run-clj-tests
.PHONY: list
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ api todo - see todos in tempo.cljc

### to/from legacy date

### clocks

todo: fixed, offset

### instant-from

- epoch millis + (optionally) nanos
Expand Down
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
backtick/backtick {:mvn/version "0.3.4"}
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}
medley/medley {:mvn/version "1.4.0"}
com.widdindustries/tiado-cljs2 {:git/url "https://github.com/henryw374/tiado-cljs2.git" :git/sha "8aa3042d834d2695ec9d4f9f65532573c849d6bf"}
com.widdindustries/tiado-cljs2 {:git/url "https://github.com/henryw374/tiado-cljs2.git" :git/sha "3229283d825a393008a1f1c408603dff775e87c2"}
com.widdindustries/cljc.java-time {:mvn/version "0.1.21"}
;com.widdindustries/time-literals {:mvn/version "0.1.10" :exclusions [com.widdindustries/cljs.java-time]}
org.clojure/tools.namespace {:mvn/version "1.4.4"}
babashka/fs {:mvn/version "0.5.20"}
}
}}
:release {:extra-deps {applied-science/deps-library {:mvn/version "RELEASE"}}
Expand Down
18 changes: 13 additions & 5 deletions dev/dev.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require [clojure.java.io :as io]
[com.widdindustries.tiado-cljs2 :as util]
[kaocha.repl :as kaocha]
[babashka.fs :as fs]
[clojure.tools.namespace.repl :as refresh]
[com.widdindustries.gen.gen.tempo :as gen]))

Expand All @@ -15,6 +16,8 @@
(refresh/refresh-all :after 'dev/x))

(defn browser-test-build [compile-mode opts]
((get util/compile-fns compile-mode)
(util/browser-test-config) opts)
(.mkdirs (io/file "web-target" "public" "browser-test"))
(spit "web-target/public/browser-test/index.html"
"<!DOCTYPE html>
Expand All @@ -29,15 +32,20 @@
<script src=\"/browser-test/js/test.js\">
</script>
<script>kaocha.cljs2.shadow_runner.init();</script></body></html>"
)
((get util/compile-fns compile-mode)
(util/browser-test-config) opts)
(println "for tests, open " util/test-url))

))

(defn test-watch []
(browser-test-build :watch {}))

(defn tests-ci-shadow [{:keys [compile-mode]}]
(util/start-server)
(browser-test-build compile-mode {})
(try
(util/kaocha-exit-if-fail (util/run-tests-headless nil))
(catch Exception e
(println e)
(System/exit 1))))

(comment

; start up live-compilation of tests
Expand Down
42 changes: 21 additions & 21 deletions src/com/widdindustries/tempo.clj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
[arg & args]
(assert (every? some? (cons arg args)))
(reduce
(fn* [p1__40486# p2__40487#] (greater p1__40486# p2__40487#))
(fn* [p1__34673# p2__34674#] (greater p1__34673# p2__34674#))
arg
args))

Expand All @@ -95,7 +95,7 @@
[arg & args]
(assert (every? some? (cons arg args)))
(reduce
(fn* [p1__40488# p2__40489#] (lesser p1__40488# p2__40489#))
(fn* [p1__34675# p2__34676#] (lesser p1__34675# p2__34676#))
arg
args))

Expand Down Expand Up @@ -153,38 +153,36 @@

^{:line 30, :column 9} (comment "accessors")

(defn zdt->month [^ZonedDateTime foo] (.getMonthValue foo))
(defn datetime->month [^LocalDateTime foo] (.getMonthValue foo))

(defn zdt->day-of-month [^ZonedDateTime foo] (.getDayOfMonth foo))
(defn date->month [^LocalDate foo] (.getMonthValue foo))

(defn datetime->second [^LocalDateTime foo] (.getSecond foo))

(defn zdt->date [^ZonedDateTime foo] (.toLocalDate foo))

(defn datetime->year [^LocalDateTime foo] (.getYear foo))

(defn date->month [^LocalDate foo] (.getMonthValue foo))

(defn datetime->month [^LocalDateTime foo] (.getMonthValue foo))
(defn zdt->day-of-month [^ZonedDateTime foo] (.getDayOfMonth foo))

(defn zdt->year [^ZonedDateTime foo] (.getYear foo))

(defn monthday->month [^MonthDay foo] (.getMonthValue foo))

(defn datetime->hour [^LocalDateTime foo] (.getHour foo))

(defn yearmonth->month [^YearMonth foo] (.getMonthValue foo))
(defn date->year [^LocalDate foo] (.getYear foo))

(defn monthday->day-of-month [^MonthDay foo] (.getDayOfMonth foo))
(defn yearmonth->year [^YearMonth foo] (.getYear foo))

(defn datetime->day-of-month [^LocalDateTime foo] (.getDayOfMonth foo))
(defn yearmonth->month [^YearMonth foo] (.getMonthValue foo))

(defn zdt->hour [^ZonedDateTime foo] (.getHour foo))

(defn zdt->instant [^ZonedDateTime foo] (.toInstant foo))

(defn zdt->nano [^ZonedDateTime foo] (.getNano foo))

(defn yearmonth->year [^YearMonth foo] (.getYear foo))

(defn zdt->minute [^ZonedDateTime foo] (.getMinute foo))

(defn datetime->date [^LocalDateTime foo] (.toLocalDate foo))
Expand All @@ -197,16 +195,18 @@

(defn time->second [^LocalTime foo] (.getSecond foo))

(defn date->year [^LocalDate foo] (.getYear foo))
(defn datetime->day-of-month [^LocalDateTime foo] (.getDayOfMonth foo))

(defn zdt->datetime [^ZonedDateTime foo] (.toLocalDateTime foo))

(defn zdt->time [^ZonedDateTime foo] (.toLocalTime foo))

(defn monthday->month [^MonthDay foo] (.getMonthValue foo))
(defn zdt->month [^ZonedDateTime foo] (.getMonthValue foo))

(defn datetime->minute [^LocalDateTime foo] (.getMinute foo))

(defn monthday->day-of-month [^MonthDay foo] (.getDayOfMonth foo))

(defn time->nano [^LocalTime foo] (.getNano foo))

(defn zdt->timezone [^ZonedDateTime foo] (.getZone foo))
Expand All @@ -221,8 +221,6 @@

^{:line 32, :column 9} (comment "parsers")

(defn zdt-parse [^java.lang.String foo] (ZonedDateTime/parse foo))

(defn datetime-parse [^java.lang.String foo] (LocalDateTime/parse foo))

(defn date-parse [^java.lang.String foo] (LocalDate/parse foo))
Expand All @@ -231,6 +229,8 @@

(defn time-parse [^java.lang.String foo] (LocalTime/parse foo))

(defn zdt-parse [^java.lang.String foo] (ZonedDateTime/parse foo))

(defn instant-parse [^java.lang.String foo] (Instant/parse foo))

(defn yearmonth-parse [^java.lang.String foo] (YearMonth/parse foo))
Expand All @@ -239,11 +239,6 @@

^{:line 34, :column 9} (comment "nowers")

(defn
zdt-now
([] (ZonedDateTime/now))
([^java.time.Clock clock] (ZonedDateTime/now clock)))

(defn
datetime-now
([] (LocalDateTime/now))
Expand All @@ -264,6 +259,11 @@
([] (LocalTime/now))
([^java.time.Clock clock] (LocalTime/now clock)))

(defn
zdt-now
([] (ZonedDateTime/now))
([^java.time.Clock clock] (ZonedDateTime/now clock)))

(defn
instant-now
([] (Instant/now))
Expand Down
66 changes: 33 additions & 33 deletions src/com/widdindustries/tempo.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
[arg & args]
(assert (every? some? (cons arg args)))
(reduce
(fn* [p1__40490# p2__40491#] (greater p1__40490# p2__40491#))
(fn* [p1__34677# p2__34678#] (greater p1__34677# p2__34678#))
arg
args))

Expand All @@ -71,7 +71,7 @@
[arg & args]
(assert (every? some? (cons arg args)))
(reduce
(fn* [p1__40492# p2__40493#] (lesser p1__40492# p2__40493#))
(fn* [p1__34679# p2__34680#] (lesser p1__34679# p2__34680#))
arg
args))

Expand Down Expand Up @@ -129,47 +129,39 @@

^{:line 30, :column 9} (comment "accessors")

(defn zdt->month [^js/Temporal.ZonedDateTime foo] (.-month foo))
(defn datetime->month [^js/Temporal.PlainDateTime foo] (.-month foo))

(defn
zdt->day-of-month
[^js/Temporal.ZonedDateTime foo]
(.-dayOfMonth foo))
(defn date->month [^js/Temporal.PlainDate foo] (.-month foo))

(defn datetime->second [^js/Temporal.PlainDateTime foo] (.-second foo))

(defn zdt->date [^js/Temporal.ZonedDateTime foo] (.toPlainDate foo))

(defn datetime->year [^js/Temporal.PlainDateTime foo] (.-year foo))

(defn date->month [^js/Temporal.PlainDate foo] (.-month foo))

(defn datetime->month [^js/Temporal.PlainDateTime foo] (.-month foo))
(defn
zdt->day-of-month
[^js/Temporal.ZonedDateTime foo]
(.-dayOfMonth foo))

(defn zdt->year [^js/Temporal.ZonedDateTime foo] (.-year foo))

(defn monthday->month [^js/Temporal.PlainMonthDay foo] (.-month foo))

(defn datetime->hour [^js/Temporal.PlainDateTime foo] (.-hour foo))

(defn yearmonth->month [^js/Temporal.PlainYearMonth foo] (.-month foo))
(defn date->year [^js/Temporal.PlainDate foo] (.-year foo))

(defn
monthday->day-of-month
[^js/Temporal.PlainMonthDay foo]
(.-dayOfMonth foo))
(defn yearmonth->year [^js/Temporal.PlainYearMonth foo] (.-year foo))

(defn
datetime->day-of-month
[^js/Temporal.PlainDateTime foo]
(.-dayOfMonth foo))
(defn yearmonth->month [^js/Temporal.PlainYearMonth foo] (.-month foo))

(defn zdt->hour [^js/Temporal.ZonedDateTime foo] (.-hour foo))

(defn zdt->instant [^js/Temporal.ZonedDateTime foo] (.toInstant foo))

(defn zdt->nano [^js/Temporal.ZonedDateTime foo] (.-nano foo))

(defn yearmonth->year [^js/Temporal.PlainYearMonth foo] (.-year foo))

(defn zdt->minute [^js/Temporal.ZonedDateTime foo] (.-minute foo))

(defn
Expand All @@ -188,7 +180,10 @@

(defn time->second [^js/Temporal.PlainTime foo] (.-second foo))

(defn date->year [^js/Temporal.PlainDate foo] (.-year foo))
(defn
datetime->day-of-month
[^js/Temporal.PlainDateTime foo]
(.-dayOfMonth foo))

(defn
zdt->datetime
Expand All @@ -197,10 +192,15 @@

(defn zdt->time [^js/Temporal.ZonedDateTime foo] (.toPlainTime foo))

(defn monthday->month [^js/Temporal.PlainMonthDay foo] (.-month foo))
(defn zdt->month [^js/Temporal.ZonedDateTime foo] (.-month foo))

(defn datetime->minute [^js/Temporal.PlainDateTime foo] (.-minute foo))

(defn
monthday->day-of-month
[^js/Temporal.PlainMonthDay foo]
(.-dayOfMonth foo))

(defn time->nano [^js/Temporal.PlainTime foo] (.-nano foo))

(defn zdt->timezone [^js/Temporal.ZonedDateTime foo] (.timeZoneId foo))
Expand All @@ -218,11 +218,6 @@

^{:line 32, :column 9} (comment "parsers")

(defn
zdt-parse
[^java.lang.String foo]
(js/Temporal.ZonedDateTime.from foo))

(defn
datetime-parse
[^java.lang.String foo]
Expand All @@ -243,6 +238,11 @@
[^java.lang.String foo]
(js/Temporal.PlainTime.from foo))

(defn
zdt-parse
[^java.lang.String foo]
(js/Temporal.ZonedDateTime.from foo))

(defn
instant-parse
[^java.lang.String foo]
Expand All @@ -260,11 +260,6 @@

^{:line 34, :column 9} (comment "nowers")

(defn
zdt-now
([] (clock/zdt))
([^java.time.Clock clock] (clock/zdt clock)))

(defn
datetime-now
([] (clock/datetime))
Expand All @@ -285,6 +280,11 @@
([] (clock/time))
([^java.time.Clock clock] (clock/time clock)))

(defn
zdt-now
([] (clock/zdt))
([^java.time.Clock clock] (clock/zdt clock)))

(defn
instant-now
([] (clock/instant))
Expand Down
3 changes: 2 additions & 1 deletion src/com/widdindustries/tempo/cljs_protocols.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
entities/month-day
(-equiv [o other] (.equals ^js o other)))
(extend-protocol IHash entities/month-day (-hash [o] (hash (str o))))
(extend-protocol
; cannot compare monthday
#_(extend-protocol
IComparable
entities/month-day
(-compare [x y] (.compare entities/month-day ^js x y))))
Expand Down
6 changes: 3 additions & 3 deletions src/com/widdindustries/tempo/clock.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
([^js clock] (js/Temporal.PlainYearMonth.from (date clock))))

(defn monthday
([] (js/Temporal.MonthDay.from (date)) )
([^js clock] (js/Temporal.MonthDay.from (date clock))))
([] (js/Temporal.PlainMonthDay.from (date)) )
([^js clock] (js/Temporal.PlainMonthDay.from (date clock))))

(defn time
([] (js/Temporal.Now.plainTimeISO))
([^js clock] (.plainTimeISO clock)))

(defn time-zone
([] (js/Temporal.Now.timeZone))
([] (js/Temporal.TimeZone.from (js/Temporal.Now.timeZoneId)))
([^js clock] (.timeZone clock)))

#_(defn zoned-date-time
Expand Down
Loading

0 comments on commit ee407fd

Please sign in to comment.