cli.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. name: logseq/cli CI
  2. on:
  3. # Path filters ensure jobs only kick off if a change is made to cli or
  4. # its local dependencies
  5. push:
  6. branches: [master]
  7. paths:
  8. - 'deps/cli/**'
  9. - '.github/workflows/cli.yml'
  10. - '!deps/cli/**.md'
  11. # Deps that logseq/cli depends on should trigger this workflow
  12. - 'deps/outliner/**'
  13. - 'deps/graph-parser/**'
  14. - 'deps/db/**'
  15. - 'deps/common/**'
  16. pull_request:
  17. branches: [master]
  18. paths:
  19. - 'deps/cli/**'
  20. - '.github/workflows/cli.yml'
  21. - '!deps/cli/**.md'
  22. # Deps that logseq/cli depends on should trigger this workflow
  23. - 'deps/outliner/**'
  24. - 'deps/graph-parser/**'
  25. - 'deps/db/**'
  26. - 'deps/common/**'
  27. workflow_dispatch:
  28. inputs:
  29. git-ref:
  30. description: "Release Git Ref (Which branch to build?)"
  31. required: true
  32. default: "master"
  33. release-tag:
  34. type: choice
  35. description: "Npm Release Tag (Use 'latest' for a stable release)"
  36. required: true
  37. options:
  38. - alpha
  39. - latest
  40. default: "latest"
  41. defaults:
  42. run:
  43. working-directory: deps/cli
  44. env:
  45. CLOJURE_VERSION: '1.11.1.1413'
  46. # This is the same as 1.8.
  47. JAVA_VERSION: '11'
  48. # This is the latest node version we can run.
  49. NODE_VERSION: '22'
  50. BABASHKA_VERSION: '1.0.168'
  51. jobs:
  52. test:
  53. runs-on: ubuntu-latest
  54. steps:
  55. - name: Checkout
  56. uses: actions/checkout@v4
  57. - name: Set up Node
  58. uses: actions/setup-node@v3
  59. with:
  60. node-version: ${{ env.NODE_VERSION }}
  61. cache: 'yarn'
  62. cache-dependency-path: deps/cli/yarn.lock
  63. - name: Set up Java
  64. uses: actions/setup-java@v3
  65. with:
  66. distribution: 'zulu'
  67. java-version: ${{ env.JAVA_VERSION }}
  68. # Clojure needed for bb step
  69. - name: Set up Clojure
  70. uses: DeLaGuardo/[email protected]
  71. with:
  72. cli: ${{ env.CLOJURE_VERSION }}
  73. bb: ${{ env.BABASHKA_VERSION }}
  74. - name: Fetch yarn deps
  75. run: yarn install --frozen-lockfile
  76. - name: Run nbb-logseq tests
  77. run: yarn test
  78. # In this job because it depends on an npm package
  79. - name: Load namespaces into nbb-logseq
  80. run: bb test:load-all-namespaces-with-nbb .
  81. lint:
  82. runs-on: ubuntu-latest
  83. steps:
  84. - name: Checkout
  85. uses: actions/checkout@v4
  86. - name: Set up Java
  87. uses: actions/setup-java@v3
  88. with:
  89. distribution: 'zulu'
  90. java-version: ${{ env.JAVA_VERSION }}
  91. - name: Set up Clojure
  92. uses: DeLaGuardo/[email protected]
  93. with:
  94. cli: ${{ env.CLOJURE_VERSION }}
  95. bb: ${{ env.BABASHKA_VERSION }}
  96. - name: Run clj-kondo lint
  97. run: clojure -M:clj-kondo --lint src test
  98. - name: Carve lint for unused vars
  99. run: bb lint:carve
  100. - name: Lint for vars that are too large
  101. run: bb lint:large-vars
  102. - name: Lint for namespaces that aren't documented
  103. run: bb lint:ns-docstrings
  104. - name: Lint for public vars that are private based on usage
  105. run: bb lint:minimize-public-vars
  106. release:
  107. if: ${{ github.event_name == 'workflow_dispatch' }}
  108. runs-on: ubuntu-latest
  109. steps:
  110. - name: Check out Git repository
  111. uses: actions/checkout@v4
  112. with:
  113. ref: ${{ github.event.inputs.git-ref }}
  114. - name: Set up Node
  115. uses: actions/setup-node@v3
  116. with:
  117. node-version: ${{ env.NODE_VERSION }}
  118. cache: 'yarn'
  119. cache-dependency-path: deps/cli/yarn.lock
  120. - name: Set up Java
  121. uses: actions/setup-java@v3
  122. with:
  123. distribution: 'zulu'
  124. java-version: ${{ env.JAVA_VERSION }}
  125. # Clojure needed for bb step
  126. - name: Set up Clojure
  127. uses: DeLaGuardo/[email protected]
  128. with:
  129. cli: ${{ env.CLOJURE_VERSION }}
  130. bb: ${{ env.BABASHKA_VERSION }}
  131. - name: Fetch yarn deps
  132. run: yarn install --frozen-lockfile
  133. - name: Bundle vendor deps
  134. run: bb build:vendor-nbb-deps
  135. # - name: Debug package
  136. # run: yarn pack && tar -tf logseq-cli-*.tgz
  137. - name: Authenticate with registry
  138. env:
  139. NPM_TOKEN: ${{ secrets.NPM_CLI_TOKEN }}
  140. run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
  141. - name: Publish package
  142. run: npm publish --tag "${{ github.event.inputs.release-tag || 'alpha' }}" --access public