build.yml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. name: CI
  2. on:
  3. push:
  4. branches: [master]
  5. paths-ignore:
  6. - '*.md'
  7. pull_request:
  8. branches: [master, "feat/db"]
  9. paths-ignore:
  10. - '*.md'
  11. env:
  12. CLOJURE_VERSION: '1.11.1.1413'
  13. JAVA_VERSION: '11'
  14. # This is the latest node version we can run.
  15. NODE_VERSION: '22'
  16. BABASHKA_VERSION: '1.0.168'
  17. jobs:
  18. typos:
  19. name: Spell Check with Typos
  20. runs-on: ubuntu-22.04
  21. steps:
  22. - name: Checkout Actions Repository
  23. uses: actions/checkout@v4
  24. - name: Check spelling with custom config file
  25. uses: crate-ci/[email protected]
  26. with:
  27. config: ./typos.toml
  28. test:
  29. strategy:
  30. matrix:
  31. operating-system: [ubuntu-22.04]
  32. runs-on: ${{ matrix.operating-system }}
  33. steps:
  34. - name: Checkout
  35. uses: actions/checkout@v4
  36. - name: Set up Node
  37. uses: actions/setup-node@v3
  38. with:
  39. node-version: ${{ env.NODE_VERSION }}
  40. cache: 'yarn'
  41. cache-dependency-path: |
  42. yarn.lock
  43. static/yarn.lock
  44. - name: Set up Java
  45. uses: actions/setup-java@v3
  46. with:
  47. distribution: 'zulu'
  48. java-version: ${{ env.JAVA_VERSION }}
  49. - name: Set up Clojure
  50. uses: DeLaGuardo/[email protected]
  51. with:
  52. cli: ${{ env.CLOJURE_VERSION }}
  53. - name: Clojure cache
  54. uses: actions/cache@v3
  55. id: clojure-deps
  56. with:
  57. path: |
  58. ~/.m2/repository
  59. ~/.gitlibs
  60. key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
  61. restore-keys: ${{ runner.os }}-clojure-deps-
  62. - name: Fetch Clojure deps
  63. if: steps.clojure-deps.outputs.cache-hit != 'true'
  64. run: clojure -A:cljs -P
  65. - name: Fetch yarn deps
  66. run: yarn install --frozen-lockfile
  67. - name: Build test asset
  68. run: clojure -M:test compile test
  69. - name: Run some ClojureScript tests against DB version
  70. run: DB_GRAPH=1 node static/tests.js -r frontend.db.query-dsl-test
  71. - name: Run ClojureScript query tests against DB version with basic query type
  72. run: DB_GRAPH=1 DB_QUERY_TYPE=basic node static/tests.js -r frontend.db.query-dsl-test
  73. - name: Run ClojureScript tests
  74. run: node static/tests.js -e fix-me
  75. lint:
  76. runs-on: ubuntu-22.04
  77. steps:
  78. - name: Checkout
  79. uses: actions/checkout@v4
  80. - name: Set up Java
  81. uses: actions/setup-java@v3
  82. with:
  83. distribution: 'zulu'
  84. java-version: ${{ env.JAVA_VERSION }}
  85. - name: Set up Clojure
  86. uses: DeLaGuardo/[email protected]
  87. with:
  88. cli: ${{ env.CLOJURE_VERSION }}
  89. bb: ${{ env.BABASHKA_VERSION }}
  90. - name: Run clj-kondo lint
  91. run: clojure -M:clj-kondo --parallel --lint src
  92. - name: Carve lint for unused vars
  93. run: bb lint:carve
  94. - name: Lint for vars that are too large
  95. run: bb lint:large-vars
  96. - name: Lint for namespaces that aren't documented
  97. run: bb lint:ns-docstrings
  98. - name: Lint invalid translation entries
  99. run: bb lang:validate-translations
  100. - name: Lint to keep worker independent of frontend
  101. run: bb lint:worker-and-frontend-separate
  102. - name: Lint to keep db and file graph code separate
  103. run: bb lint:db-and-file-graphs-separate
  104. db-graph-test:
  105. strategy:
  106. matrix:
  107. operating-system: [ubuntu-latest]
  108. runs-on: ${{ matrix.operating-system }}
  109. steps:
  110. - name: Checkout
  111. uses: actions/checkout@v4
  112. - name: Set up Node
  113. uses: actions/setup-node@v3
  114. with:
  115. node-version: ${{ env.NODE_VERSION }}
  116. cache: 'yarn'
  117. cache-dependency-path: |
  118. deps/db/yarn.lock
  119. scripts/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. - name: Set up Clojure
  126. uses: DeLaGuardo/[email protected]
  127. with:
  128. cli: ${{ env.CLOJURE_VERSION }}
  129. bb: ${{ env.BABASHKA_VERSION }}
  130. - name: Fetch scripts yarn deps
  131. run: cd scripts && yarn install --frozen-lockfile
  132. - name: Create DB graph with properties
  133. run: cd scripts && yarn nbb-logseq src/logseq/tasks/db_graph/create_graph_with_properties.cljs ./properties-graph
  134. # TODO: Use a smaller, test-focused graph to test classes
  135. - name: Create DB graph with classes
  136. run: cd scripts && yarn nbb-logseq src/logseq/tasks/db_graph/create_graph_with_schema_org.cljs ./schema-graph
  137. - name: Fetch deps/db yarn deps
  138. run: cd deps/db && yarn install --frozen-lockfile
  139. - name: Validate created DB graphs
  140. run: cd deps/db && yarn nbb-logseq script/validate_db.cljs ../../scripts/properties-graph ../../scripts/schema-graph --closed-maps --group-errors
  141. - name: Export a created DB graph
  142. run: cd deps/db && yarn nbb-logseq script/export_graph.cljs ../../scripts/properties-graph -f properties.edn -t
  143. - name: Create graph from the export and diff the two graphs
  144. run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -t
  145. e2e-test:
  146. # TODO: Re-enable when ready to enable tests for file graphs
  147. if: false
  148. runs-on: ubuntu-22.04
  149. steps:
  150. - name: Checkout
  151. uses: actions/checkout@v4
  152. - name: Set up Node
  153. uses: actions/setup-node@v3
  154. with:
  155. node-version: ${{ env.NODE_VERSION }}
  156. cache: 'yarn'
  157. cache-dependency-path: |
  158. yarn.lock
  159. static/yarn.lock
  160. - name: Set up Java
  161. uses: actions/setup-java@v3
  162. with:
  163. distribution: 'zulu'
  164. java-version: ${{ env.JAVA_VERSION }}
  165. - name: Set up Clojure
  166. uses: DeLaGuardo/[email protected]
  167. with:
  168. cli: ${{ env.CLOJURE_VERSION }}
  169. - name: Clojure cache
  170. uses: actions/cache@v3
  171. id: clojure-deps
  172. with:
  173. path: |
  174. ~/.m2/repository
  175. ~/.gitlibs
  176. key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
  177. restore-keys: ${{ runner.os }}-clojure-deps-
  178. - name: Fetch Clojure deps
  179. if: steps.clojure-deps.outputs.cache-hit != 'true'
  180. run: clojure -A:cljs -P
  181. - name: Shadow-cljs cache
  182. uses: actions/cache@v3
  183. with:
  184. path: .shadow-cljs
  185. # ensure update cache every time
  186. key: ${{ runner.os }}-shadow-cljs-${{ github.sha }}
  187. # will match most recent upload
  188. restore-keys: |
  189. ${{ runner.os }}-shadow-cljs-
  190. - name: Fetch yarn deps
  191. run: yarn install
  192. env:
  193. PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
  194. # NOTE: require the app to be build in debug mode(compile instead of build).
  195. - name: Prepare E2E test build
  196. run: |
  197. yarn gulp:build && clojure -M:cljs compile app publishing electron
  198. (cd static && yarn install && yarn rebuild:all)
  199. # Exits with 0 if yarn.lock is up to date or 1 if we forgot to update it
  200. - name: Ensure static yarn.lock is up to date
  201. run: git diff --exit-code static/yarn.lock
  202. - name: Install Fluxbox
  203. run: sudo apt-get update && sudo apt-get install -y fluxbox
  204. # Emulate a virtual framebuffer on machines with no display hardware
  205. - name: Run XVFB
  206. run: Xvfb :1 -screen 0 1024x768x24 >/dev/null 2>&1 &
  207. # Start a lightweight window manager to simulate window actions (maximize,restore etc)
  208. - name: Start Fluxbox
  209. run: DISPLAY=:1.0 fluxbox >/dev/null 2>&1 &
  210. - name: Run Playwright test - 1/2
  211. run: DISPLAY=:1.0 npx playwright test --reporter github --shard=1/2
  212. env:
  213. LOGSEQ_CI: true
  214. DEBUG: "pw:api"
  215. RELEASE: true # skip dev only test
  216. - name: Run Playwright test - 2/2
  217. run: DISPLAY=:1.0 npx playwright test --reporter github --shard=2/2
  218. env:
  219. LOGSEQ_CI: true
  220. DEBUG: "pw:api"
  221. RELEASE: true # skip dev only test
  222. - name: Save test artifacts
  223. if: ${{ failure() }}
  224. uses: actions/upload-artifact@v4
  225. with:
  226. name: e2e-test-report
  227. path: e2e-dump/*
  228. retention-days: 1