mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
Add standard lint tasks to common lib
This commit is contained in:
committed by
Tienson Qin
parent
91beda09d5
commit
c86fd3cd4d
49
.github/workflows/logseq-common.yml
vendored
49
.github/workflows/logseq-common.yml
vendored
@@ -34,6 +34,13 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
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
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
@@ -46,8 +53,15 @@ jobs:
|
|||||||
cli: ${{ env.CLOJURE_VERSION }}
|
cli: ${{ env.CLOJURE_VERSION }}
|
||||||
bb: ${{ env.BABASHKA_VERSION }}
|
bb: ${{ env.BABASHKA_VERSION }}
|
||||||
|
|
||||||
- name: Run clj-kondo lint
|
- name: Fetch yarn deps
|
||||||
run: clojure -M:clj-kondo --parallel --lint src test
|
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
|
- name: Clojure cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
@@ -65,3 +79,34 @@ jobs:
|
|||||||
|
|
||||||
- name: Run ClojureScript tests
|
- name: Run ClojureScript tests
|
||||||
run: clojure -M:test
|
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
|
||||||
27
deps/common/README.md
vendored
27
deps/common/README.md
vendored
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
This library provides common util namespaces to share between the frontend and
|
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
|
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
|
## 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
|
configurations that are specific to this library. See [this library's CI
|
||||||
file](/.github/workflows/logseq-common.yml) for linting examples.
|
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
|
### 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:
|
To run ClojureScript tests:
|
||||||
```
|
```
|
||||||
clojure -M:test
|
clojure -M:test
|
||||||
```
|
```
|
||||||
|
|
||||||
To auto-run tests while writing tests:
|
To auto-run ClojureScript tests while writing tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
clojure -M:test -w src
|
clojure -M:test -w src
|
||||||
```
|
```
|
||||||
|
### Managing dependencies
|
||||||
|
|
||||||
|
See [standard nbb/cljs library advice in graph-parser](/deps/graph-parser/README.md#managing-dependencies).
|
||||||
26
deps/common/bb.edn
vendored
Normal file
26
deps/common/bb.edn
vendored
Normal file
@@ -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}}}
|
||||||
Reference in New Issue
Block a user