diff --git a/.github/workflows/logseq-common.yml b/.github/workflows/logseq-common.yml index 2c6d3f076..26c1a4060 100644 --- a/.github/workflows/logseq-common.yml +++ b/.github/workflows/logseq-common.yml @@ -34,6 +34,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'yarn' + cache-dependency-path: deps/publishing/yarn.lock + - name: Set up Java uses: actions/setup-java@v3 with: @@ -46,8 +53,15 @@ jobs: cli: ${{ env.CLOJURE_VERSION }} bb: ${{ env.BABASHKA_VERSION }} - - name: Run clj-kondo lint - run: clojure -M:clj-kondo --parallel --lint src test + - name: Fetch yarn deps + run: yarn install --frozen-lockfile + + - name: Run nbb-logseq tests + run: yarn test + + # In this job because it depends on an npm package + - name: Load namespaces into nbb-logseq + run: bb test:load-all-namespaces-with-nbb . - name: Clojure cache uses: actions/cache@v3 @@ -65,3 +79,34 @@ jobs: - name: Run ClojureScript tests run: clojure -M:test + + lint: + 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 --lint src test + + - name: Carve lint for unused vars + run: bb lint:carve + + - name: Lint for vars that are too large + run: bb lint:large-vars + + - name: Lint for namespaces that aren't documented + run: bb lint:ns-docstrings \ No newline at end of file diff --git a/deps/common/README.md b/deps/common/README.md index 5c6a67c60..39ad33b1a 100644 --- a/deps/common/README.md +++ b/deps/common/README.md @@ -2,7 +2,10 @@ This library provides common util namespaces to share between the frontend and other non-frontend namespaces. This library is not supposed to depend on other logseq -libraries. +libraries. This library is compatible with ClojureScript and with +node/[nbb-logseq](https://github.com/logseq/nbb-logseq) to respectively provide +frontend and Electron/commandline functionality. + ## API @@ -15,15 +18,35 @@ follows](/docs/dev-practices.md). Most of the same linters are used, with configurations that are specific to this library. See [this library's CI file](/.github/workflows/logseq-common.yml) for linting examples. +### Setup + +To run linters and tests, you'll want to install yarn dependencies once: +``` +yarn install +``` ### Testing +To run nbb-logseq tests: + +``` +# Run all tests +$ yarn test +# List available options +$ yarn test -H +# Run tests with :focus metadata flag +$ yarn test -i focus +``` + To run ClojureScript tests: ``` clojure -M:test ``` -To auto-run tests while writing tests: +To auto-run ClojureScript tests while writing tests: ``` clojure -M:test -w src ``` +### Managing dependencies + +See [standard nbb/cljs library advice in graph-parser](/deps/graph-parser/README.md#managing-dependencies). \ No newline at end of file diff --git a/deps/common/bb.edn b/deps/common/bb.edn new file mode 100644 index 000000000..4a681f504 --- /dev/null +++ b/deps/common/bb.edn @@ -0,0 +1,26 @@ +{:min-bb-version "1.0.168" + :deps + {logseq/bb-tasks + #_{:local/root "../../../bb-tasks"} + {:git/url "https://github.com/logseq/bb-tasks" + :git/sha "0d49051909bfa0c6b414e86606d82b4ea54f382c"}} + + :pods + {clj-kondo/clj-kondo {:version "2023.03.17"}} + + :tasks + {test:load-all-namespaces-with-nbb + logseq.bb-tasks.nbb.test/load-all-namespaces + + lint:large-vars + logseq.bb-tasks.lint.large-vars/-main + + lint:carve + logseq.bb-tasks.lint.carve/-main + + lint:ns-docstrings + logseq.bb-tasks.lint.ns-docstrings/-main} + + :tasks/config + {:large-vars + {:max-lines-count 45}}} \ No newline at end of file