Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1dbfcec
wip
borkdude Feb 21, 2022
3e02617
wip
borkdude Feb 21, 2022
0426090
No headless in CI
borkdude Feb 21, 2022
cc01ff2
headless in CI
borkdude Feb 21, 2022
be87fcd
Fix test
borkdude Feb 21, 2022
e1f023b
wip
borkdude Feb 21, 2022
f8ced61
Test for zero console errors
borkdude Feb 22, 2022
1037afd
wip
borkdude Feb 22, 2022
f8cb240
Use -m invocation
borkdude Feb 22, 2022
459af2c
Run ui tests via bb
borkdude Feb 22, 2022
155c923
Add bb dir
borkdude Feb 22, 2022
75d4714
Multitasking is hard
borkdude Feb 22, 2022
9233250
dude
borkdude Feb 22, 2022
3b679de
dude1
borkdude Feb 22, 2022
4f2448b
dude1
borkdude Feb 22, 2022
d053a66
solve bitrot
borkdude Feb 22, 2022
c7b2f72
Revert "solve bitrot"
borkdude Feb 22, 2022
7c858c7
move ui tests to separate step
borkdude Mar 1, 2022
eb3f293
wip
borkdude Mar 1, 2022
5a86f72
wip
borkdude Mar 1, 2022
e974634
wip
borkdude Mar 1, 2022
bcb6337
use yarn instead of npx
borkdude Mar 1, 2022
bee6aa1
delete package lock json
borkdude Mar 1, 2022
bc2e5c1
increase timeout
borkdude Mar 1, 2022
ce47b25
weird
borkdude Mar 1, 2022
15d8fc5
remove bb dir
borkdude Mar 1, 2022
6cc25b2
fetch depth
borkdude Mar 1, 2022
284ceb3
fix
borkdude Mar 1, 2022
63ac0b3
fix dir
borkdude Mar 1, 2022
7d1433b
trigger UI error
borkdude Mar 1, 2022
fc9b119
wip
borkdude Mar 1, 2022
7695c39
Revert "wip"
borkdude Mar 1, 2022
8aeedac
Merge branch 'main' into nbb-ui-tests
borkdude Mar 8, 2022
b9eb5c3
hmm
borkdude Mar 8, 2022
b3dac1c
checkout
borkdude Mar 8, 2022
0465c74
trigger error in render fn
borkdude Mar 8, 2022
b94ccfb
yeah
borkdude Mar 8, 2022
f201875
nrepl port ignore
borkdude Mar 8, 2022
581502d
nrepl port ignore
borkdude Mar 8, 2022
957bb81
Process comments of #107
borkdude Mar 8, 2022
f0977a4
clean
borkdude Mar 8, 2022
ff66b19
Keep data files in /data
mk Mar 8, 2022
9e3c21f
Append data for copied file as well
mk Mar 8, 2022
40fab5e
Trigger rebuild
mk Mar 8, 2022
f71bcb4
Don't make clojure tests dependent on cljs build
mk Mar 8, 2022
2512320
Bust cache
mk Mar 9, 2022
59a9065
Bust cache & set clerk.resource_manifest to make tests run
mk Mar 9, 2022
9a62fe7
Set resource_manifest value to a value that works
mk Mar 9, 2022
f9e7b1f
Try quoting jvm opt to fix windows failure
mk Mar 9, 2022
ab696c2
Try running tests via bb clojure
mk Mar 9, 2022
d058130
Revert "Try quoting jvm opt to fix windows failure"
mk Mar 9, 2022
c1d4a48
Also cache ~/.deps.clj
mk Mar 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
nextjournal.view/defview clojure.core/defn
nextjournal.devcards/defcard clj-kondo.lint-as/def-catch-all
taoensso.encore/defonce clojure.core/defonce
taoensso.encore/defalias clojure.core/def}
taoensso.encore/defalias clojure.core/def
promesa.core/let clojure.core/let}
:skip-comments true
:linters {:consistent-alias {:aliases {datomic.api datomic
nextjournal.log log
Expand Down
89 changes: 56 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,51 @@ name: Continuous Delivery
on: push

jobs:

build-and-upload-viewer-resources:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch_depth: 0

- name: 🔧 Install java
uses: actions/setup-java@v1
with:
java-version: '11.0.7'

- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.10.3.943'

- name: Setup Babashka
uses: turtlequeue/setup-babashka@v1.3.0
with:
babashka-version: 0.7.6

- name: 🗝 maven cache
uses: actions/cache@v2
with:
path: |
~/.m2
~/.gitlibs
key: ${{ runner.os }}-maven-${{ github.sha }}
restore-keys: |
${{ runner.os }}-maven-

- name: 🔐 Google Auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}

- name: 🔧 Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0.3.0

- name: Build and upload viewer resources
run: bb build+upload-viewer-resources

test:
needs: [build-and-upload-viewer-resources]
runs-on: ${{matrix.sys.os}}

strategy:
Expand Down Expand Up @@ -33,18 +76,24 @@ jobs:
with:
cli: '1.10.3.943'

- name: Setup Babashka
uses: turtlequeue/setup-babashka@v1.3.0
with:
babashka-version: 0.7.6

- name: 🗝 maven cache
uses: actions/cache@v2
with:
path: |
~/.m2
~/.gitlibs
~/.deps.clj
key: ${{ runner.os }}-maven-${{ github.sha }}
restore-keys: |
${{ runner.os }}-maven-

- name: 🧪 Run tests
run: clojure -X:test
run: bb clojure -X:test

static-build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -109,45 +158,19 @@ jobs:
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: https://snapshots.nextjournal.com/clerk/build/${{ github.sha }}

build-and-upload-viewer-resources:
ui-tests:
needs: [static-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch_depth: 0

- name: 🔧 Install java
uses: actions/setup-java@v1
with:
java-version: '11.0.7'

- name: 🔧 Install clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: '1.10.3.943'

- name: Setup Babashka
uses: turtlequeue/setup-babashka@v1.3.0
with:
babashka-version: 0.7.6

- name: 🗝 maven cache
uses: actions/cache@v2
with:
path: |
~/.m2
~/.gitlibs
key: ${{ runner.os }}-maven-${{ github.sha }}
restore-keys: |
${{ runner.os }}-maven-

- name: 🔐 Google Auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}

- name: 🔧 Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0.3.0

- name: Build and upload viewer resources
run: bb build+upload-viewer-resources
- name: Run Playwright tests against static assets
run: |
bb test:static-app ${{ github.sha }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.clerk/
.cpcache/
.lsp/
node_modules/
node_modules
/public/js/
/.shadow-cljs/
/target/
Expand All @@ -16,3 +16,4 @@ yarn.lock
.work
/build
/public/build
.nrepl-port
16 changes: 13 additions & 3 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
[babashka.deps :as deps]
[babashka.fs :as fs]
[babashka.process :as p])
:init (defn viewer-css-path []
(let [cp (str/trim (with-out-str (deps/clojure ["-A:sci" "-Spath"])))]
(str/trim (:out (shell {:out :string} (str "bb -cp " cp " -e '(println (.getPath (clojure.java.io/resource \"css/viewer.css\")))'"))))))
:init (do
(defn viewer-css-path []
(let [cp (str/trim (with-out-str (deps/clojure ["-A:sci" "-Spath"])))]
(str/trim (:out (shell {:out :string} (str "bb -cp " cp " -e '(println (.getPath (clojure.java.io/resource \"css/viewer.css\")))'"))))))

(defn latest-sha []
(str/trim (:out (p/sh "git rev-parse HEAD")))))

print-viewer-css {:task (println (viewer-css-path))}
copy-viewer-css {:task (fs/copy (viewer-css-path) "resources/stylesheets/viewer.css" #{:replace-existing})}
Expand Down Expand Up @@ -41,6 +44,13 @@
:depends [release:js]
:task (clojure "-X:demo nextjournal.clerk/build-static-app!")}

test:static-app {:doc "Run UI tests for current SHA. Provide SHA as command line arg."
:task (do
(shell {:dir "ui_tests"} "yarn install")
(apply shell {:dir "ui_tests"}
"yarn nbb -m playwright-tests"
(or *command-line-args* [(latest-sha)])))}

release:jar {:doc "Builds the jar"
:task (let [rev-count (-> (p/process ["git" "rev-list" "HEAD" "--count"] {:out :string}) p/check :out str/trim Integer/parseInt)
version (format "0.6.%d" (inc rev-count))]
Expand Down
12 changes: 5 additions & 7 deletions bb/viewer_resources_hashing.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
;; Example link in bucket:
;; "https://storage.googleapis.com/nextjournal-cas-eu/data/8VwKauX6JACEP3K6ahNmP5p1w7rWdhKzeGXCDrHMnJiVrUxHVxcm3Xj84K2r3fcAKWxMQKzqoFe92osgFEHCuKCtZC"

(def gs-bucket "gs://nextjournal-cas-eu/data")
(def base-url "https://storage.googleapis.com/nextjournal-cas-eu/data")
(def gs-bucket "gs://nextjournal-cas-eu")
(def base-url "https://storage.googleapis.com/nextjournal-cas-eu")

(defn sha512s []
(let [files (map str (mapcat #(fs/glob % "**.{js,css}") output-dirs))
Expand Down Expand Up @@ -48,13 +48,11 @@
(let [front-end-hash (str (djv/file-set-hash (file-set)))]
(spit viewer-js-hash-file front-end-hash)))

(def gs-url-prefix "https://storage.googleapis.com/nextjournal-cas-eu/data")

(defn lookup-url [lookup-hash]
(str gs-bucket "/lookup/" lookup-hash))

(defn cas-link [hash]
(str gs-url-prefix "/" hash))
(str base-url "/data/" hash))

(defn build+upload-viewer-resources []
(let [front-end-hash (str/trim (slurp viewer-js-hash-file))
Expand All @@ -63,9 +61,9 @@
(when (= res ::djv/not-found)
(tasks/run 'build:js)
(let [content-hash (djv/sha512 (slurp "build/viewer.js"))
viewer-js-http-link (str (cas-link content-hash) "?cache=false")]
viewer-js-http-link (str (cas-link content-hash))]
(spit manifest {"/js/viewer.js" viewer-js-http-link})
(println "Manifest:" (slurp manifest))
(println "Coping manifest to" (lookup-url front-end-hash))
(djv/gs-copy manifest (lookup-url front-end-hash))
(djv/gs-copy "build/viewer.js" (str gs-bucket "/" content-hash))))))
(djv/gs-copy "build/viewer.js" (str gs-bucket "/data/" content-hash))))))
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
:test {:extra-deps {nubank/matcher-combinators {:mvn/version "3.3.1"}
io.github.cognitect-labs/test-runner {:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
:extra-paths ["test"]
:exec-fn cognitect.test-runner.api/test}
:exec-fn cognitect.test-runner.api/test
:jvm-opts ["-Dclerk.resource_manifest={\"/js/viewer.js\" \"http://localhost:7778/js/viewer.js\"}"]}

:demo {:extra-deps {com.github.seancorfield/next.jdbc {:mvn/version "1.2.659"}
org.xerial/sqlite-jdbc {:mvn/version "3.34.0"}
Expand Down
2 changes: 1 addition & 1 deletion resources/viewer-js-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yh4majqZ75XpcUpjEFqRovMNjpk
2qvjUtnvEguryFhLN9ZpY4VRcKRo
6 changes: 3 additions & 3 deletions src/nextjournal/clerk/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(when-let [prop (System/getProperty "clerk.disable_cache")]
(not= "false" prop)))

(def gs-url-prefix "https://storage.googleapis.com/nextjournal-cas-eu/data")
(def gs-url-prefix "https://storage.googleapis.com/nextjournal-cas-eu")
(def lookup-hash (str/trim (slurp (io/resource "viewer-js-hash"))))
(def lookup-url (str gs-url-prefix "/lookup/" lookup-hash))

Expand All @@ -21,9 +21,9 @@
(read-string prop))))

(defonce !resource->url
;; contains asset manifest in the form:
;; {"/js/viewer.js" "https://..."}
(atom (or resource-manifest-from-props
;; assume that CI will have published a CAS-link under this lookup,
;; prior to hitting this code-path
(edn/read-string (slurp lookup-url)))))

#_(swap! !resource->url assoc "/css/viewer.css" "https://storage.googleapis.com/nextjournal-cas-eu/data/8VvAV62HzsvhcsXEkHP33uj4cV9UvdDz7DU9qLeVRCfEP9kWLFAzaMKL77trdx898DzcVyDVejdfxvxj5XB84UpWvQ")
Expand Down
6 changes: 2 additions & 4 deletions src/nextjournal/clerk/sci_viewer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
[nextjournal.markdown.transform :as md.transform]
[nextjournal.sci-configs.js-interop :as sci-configs.js-interop]
[nextjournal.sci-configs.reagent :as sci-configs.reagent]
[nextjournal.ui.components.icon :as icon]
[nextjournal.ui.components.d3-require :as d3-require]
[nextjournal.ui.components.icon :as icon]
[nextjournal.view.context :as view-context]
[nextjournal.viewer.code :as code]
[nextjournal.viewer.katex :as katex]
Expand All @@ -33,7 +33,6 @@
:label-color (if selected? "white-90" "black-60")
:badge-background-color (if selected? "bg-white-20" "bg-black-10")})


(declare inspect)

(defn value-of
Expand Down Expand Up @@ -125,7 +124,7 @@
(map (partial str/join "="))
(str/join "&")))

#_(opts->query {:s 10 :num 42})
#_(opts->query {:s 12 :num 42})

(defn unreadable-edn [edn]
(html [:span.inspected-value.whitespace-nowrap.cmt-default edn]))
Expand Down Expand Up @@ -1023,7 +1022,6 @@ black")}]))}
sci-configs.js-interop/namespaces
sci-configs.reagent/namespaces)})))


(defn eval-form [f]
(sci/eval-form @!sci-ctx f))

Expand Down
6 changes: 6 additions & 0 deletions ui_tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"nbb": "^0.1.9",
"playwright": "^1.19.1"
}
}
Loading