Skip to content

Commit

Permalink
Add a workflow for test+lint and misc fixes
Browse files Browse the repository at this point in the history
- Setup cljs tests
- No need for :no-doc
- No need to bind an unused _repo value
- Remove unused datascript dep
  • Loading branch information
logseq-cldwalker authored and andelf committed Mar 28, 2023
1 parent e803e2d commit 94f35bd
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 34 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/logseq-common.yml
@@ -0,0 +1,67 @@
name: logseq/common CI

on:
# Path filters ensure jobs only kick off if a change is made to common
push:
branches: [master]
paths:
- 'deps/common/**'
- '.github/workflows/logseq-common.yml'
- '!deps/common/**.md'
pull_request:
branches: [master]
paths:
- 'deps/common/**'
- '.github/workflows/logseq-common.yml'
- '!deps/common/**.md'

defaults:
run:
working-directory: deps/common

env:
CLOJURE_VERSION: '1.10.1.763'
JAVA_VERSION: '11'
# This is the latest node version we can run.
NODE_VERSION: '18'
BABASHKA_VERSION: '1.0.168'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}

- name: Set up Clojure
uses: DeLaGuardo/setup-clojure@10.1
with:
cli: ${{ env.CLOJURE_VERSION }}
bb: ${{ env.BABASHKA_VERSION }}

- name: Run clj-kondo lint
run: clojure -M:clj-kondo --parallel --lint src test

- name: Clojure cache
uses: actions/cache@v3
id: clojure-deps
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
restore-keys: ${{ runner.os }}-clojure-deps-

- name: Fetch Clojure deps
if: steps.clojure-deps.outputs.cache-hit != 'true'
run: clojure -A:test -P

- name: Run ClojureScript tests
run: clojure -M:test
11 changes: 6 additions & 5 deletions deps/common/deps.edn
@@ -1,7 +1,8 @@
{:deps
;; External deps should be kept in sync with https://github.com/logseq/nbb-logseq/blob/main/bb.edn
{datascript/datascript {:mvn/version "1.3.8"}}
:aliases
{:clj-kondo
{:aliases
{:test {:extra-paths ["test"]
:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}
org.clojure/clojurescript {:mvn/version "1.11.54"}}
:main-opts ["-m" "cljs-test-runner.main"]}
:clj-kondo
{:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.12.08"}}
:main-opts ["-m" "clj-kondo.main"]}}}
8 changes: 4 additions & 4 deletions src/main/frontend/fs/memory_fs.cljs
@@ -1,6 +1,6 @@
(ns ^:no-doc frontend.fs.memory-fs
(ns frontend.fs.memory-fs
"Memory FS backed by lightning-fs
Paths are denoted by `memory://`. No open-dir/get-files support."
(:require [cljs-bean.core :as bean]
[frontend.db :as db]
Expand All @@ -10,7 +10,7 @@

(defn- <readdir
"Read dir recursively, return all paths
accept dir as path, without memory:// prefix for simplicity"
[dir]
(p/let [result (p/loop [result []
Expand Down Expand Up @@ -44,7 +44,7 @@
(p/resolved nil)))
(p/catch (fn [_error]
(js/window.pfs.mkdir dir)))))


(defrecord Bfs []
protocol/Fs
Expand Down
50 changes: 25 additions & 25 deletions src/main/frontend/modules/file/core.cljs
Expand Up @@ -108,31 +108,31 @@

(defn- transact-file-tx-if-not-exists!
[page-block ok-handler]
(when-let [_repo (state/get-current-repo)]
(when (:block/name page-block)
(let [format (name (get page-block :block/format
(state/get-preferred-format)))
title (string/capitalize (:block/name page-block))
whiteboard-page? (model/whiteboard-page? page-block)
format (if whiteboard-page? "edn" format)
journal-page? (date/valid-journal-title? title)
journal-title (date/normalize-journal-title title)
filename (if (and journal-page? (not (string/blank? journal-title)))
(date/date->file-name journal-title)
(-> (or (:block/original-name page-block) (:block/name page-block))
(fs-util/file-name-sanity)))
sub-dir (cond
journal-page? (config/get-journals-directory)
whiteboard-page? (config/get-whiteboards-directory)
:else (config/get-pages-directory))
ext (if (= format "markdown") "md" format)
file-rpath (path/path-join sub-dir (str filename "." ext))
file {:file/path file-rpath}
tx [{:file/path file-rpath}
{:block/name (:block/name page-block)
:block/file file}]]
(db/transact! tx)
(when ok-handler (ok-handler))))))
(when (and (state/get-current-repo)
(:block/name page-block))
(let [format (name (get page-block :block/format
(state/get-preferred-format)))
title (string/capitalize (:block/name page-block))
whiteboard-page? (model/whiteboard-page? page-block)
format (if whiteboard-page? "edn" format)
journal-page? (date/valid-journal-title? title)
journal-title (date/normalize-journal-title title)
filename (if (and journal-page? (not (string/blank? journal-title)))
(date/date->file-name journal-title)
(-> (or (:block/original-name page-block) (:block/name page-block))
(fs-util/file-name-sanity)))
sub-dir (cond
journal-page? (config/get-journals-directory)
whiteboard-page? (config/get-whiteboards-directory)
:else (config/get-pages-directory))
ext (if (= format "markdown") "md" format)
file-rpath (path/path-join sub-dir (str filename "." ext))
file {:file/path file-rpath}
tx [{:file/path file-rpath}
{:block/name (:block/name page-block)
:block/file file}]]
(db/transact! tx)
(when ok-handler (ok-handler)))))

(defn- remove-transit-ids [block] (dissoc block :db/id :block/file))

Expand Down

0 comments on commit 94f35bd

Please sign in to comment.