e2e.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. name: E2E
  2. # Running E2E test multiple times to confirm test stability.
  3. # E2E test could be randomly failed due to the batch update mechanism of React.
  4. # Robust E2E test could help improving dev experience.
  5. on:
  6. push:
  7. branches: [master]
  8. paths:
  9. - 'e2e-tests/**'
  10. pull_request:
  11. branches: [master]
  12. paths:
  13. - 'e2e-tests/**'
  14. env:
  15. CLOJURE_VERSION: '1.10.1.763'
  16. JAVA_VERSION: '11'
  17. # This is the latest node version we can run.
  18. NODE_VERSION: '18'
  19. BABASHKA_VERSION: '1.0.168'
  20. jobs:
  21. e2e-test-build:
  22. name: Build Test Artifact
  23. runs-on: ubuntu-latest
  24. steps:
  25. - name: Checkout
  26. uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  27. - name: Set up Node
  28. uses: actions/setup-node@v3
  29. with:
  30. node-version: ${{ env.NODE_VERSION }}
  31. cache: 'yarn'
  32. cache-dependency-path: |
  33. yarn.lock
  34. static/yarn.lock
  35. - name: Set up Java
  36. uses: actions/setup-java@v3
  37. with:
  38. distribution: 'zulu'
  39. java-version: ${{ env.JAVA_VERSION }}
  40. - name: Set up Clojure
  41. uses: DeLaGuardo/[email protected]
  42. with:
  43. cli: ${{ env.CLOJURE_VERSION }}
  44. - name: Clojure cache
  45. uses: actions/cache@v3
  46. id: clojure-deps
  47. with:
  48. path: |
  49. ~/.m2/repository
  50. ~/.gitlibs
  51. key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
  52. restore-keys: ${{ runner.os }}-clojure-deps-
  53. - name: Fetch Clojure deps
  54. if: steps.clojure-deps.outputs.cache-hit != 'true'
  55. run: clojure -A:cljs -P
  56. - name: Shadow-cljs cache
  57. uses: actions/cache@v3
  58. with:
  59. path: .shadow-cljs
  60. # ensure update cache every time
  61. key: ${{ runner.os }}-shadow-cljs-${{ github.sha }}
  62. # will match most recent upload
  63. restore-keys: |
  64. ${{ runner.os }}-shadow-cljs-
  65. - name: Fetch yarn deps
  66. run: yarn install
  67. env:
  68. PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
  69. # NOTE: require the app to be build with DEV-RELEASE flag
  70. - name: Prepare E2E test build
  71. run: |
  72. yarn gulp:build && clojure -M:cljs release app electron --config-merge "{:closure-defines {frontend.config/DEV-RELEASE true}}" --debug
  73. # NOTE: should include .shadow-cljs if in dev mode(compile)
  74. - name: Create Archive for build
  75. run: tar czf static.tar.gz static
  76. - name: Upload Artifact
  77. uses: actions/upload-artifact@v3
  78. with:
  79. name: logseq-e2e-artifact
  80. path: static.tar.gz
  81. retention-days: 1
  82. e2e-test-run:
  83. needs: [ e2e-test-build ]
  84. name: Test Shard ${{ matrix.shard }} Repeat ${{ matrix.repeat }}
  85. runs-on: ubuntu-latest
  86. strategy:
  87. matrix:
  88. repeat: [1, 2]
  89. shard: [1, 2, 3]
  90. steps:
  91. - name: Repeat message
  92. run: echo ::info title=StartUp::E2E testing shard ${{ matrix.shard}}/3 repeat ${{ matrix.repeat }}
  93. - name: Checkout
  94. uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
  95. - name: Download test build artifact
  96. uses: actions/download-artifact@v3
  97. with:
  98. name: logseq-e2e-artifact
  99. - name: Extract test Artifact
  100. run: tar xzf static.tar.gz
  101. - name: Set up Node
  102. uses: actions/setup-node@v3
  103. with:
  104. node-version: ${{ env.NODE_VERSION }}
  105. cache: 'yarn'
  106. cache-dependency-path: |
  107. yarn.lock
  108. static/yarn.lock
  109. - name: Fetch yarn deps for E2E test
  110. run: |
  111. yarn install
  112. (cd static && yarn install && yarn rebuild:all)
  113. env:
  114. PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
  115. - name: Ensure static yarn.lock is up to date
  116. run: git diff --exit-code static/yarn.lock
  117. - name: Install Fluxbox
  118. run: sudo apt-get update && sudo apt-get install -y fluxbox
  119. # Emulate a virtual framebuffer on machines with no display hardware
  120. - name: Run XVFB
  121. run: Xvfb :1 -screen 0 1024x768x24 >/dev/null 2>&1 &
  122. # Start a lightweight window manager to simulate window actions (maximize,restore etc)
  123. - name: Start Fluxbox
  124. run: DISPLAY=:1.0 fluxbox >/dev/null 2>&1 &
  125. - name: Run Playwright test
  126. run: DISPLAY=:1.0 npx playwright test --reporter github --shard=${{ matrix.shard }}/3
  127. env:
  128. LOGSEQ_CI: true
  129. DEBUG: "pw:api"
  130. RELEASE: true # skip dev only test
  131. - name: Save e2e artifacts
  132. if: ${{ failure() }}
  133. uses: actions/upload-artifact@v3
  134. with:
  135. name: e2e-repeat-report-${{ matrix.shard}}-${{ matrix.repeat }}
  136. path: e2e-dump/*
  137. retention-days: 1