test.yml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. name: Tests
  2. on:
  3. push:
  4. branches:
  5. - main
  6. workflow_dispatch:
  7. pull_request:
  8. branches:
  9. - main
  10. workflow_call:
  11. # Set default permissions for all jobs
  12. permissions:
  13. contents: read # Needed to check out code
  14. checks: write # Needed to report test results
  15. pull-requests: write # Needed to add comments/annotations to PRs
  16. jobs:
  17. quality-checks:
  18. runs-on: ubuntu-latest
  19. name: Quality Checks
  20. steps:
  21. - name: Checkout code
  22. uses: actions/checkout@v4
  23. - name: Setup Node.js environment
  24. uses: actions/setup-node@v4
  25. with:
  26. node-version: 22
  27. - name: Cache root dependencies
  28. uses: actions/cache@v4
  29. id: root-cache
  30. with:
  31. path: node_modules
  32. key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
  33. - name: Cache webview-ui dependencies
  34. uses: actions/cache@v4
  35. id: webview-cache
  36. with:
  37. path: webview-ui/node_modules
  38. key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }}
  39. - name: Install root dependencies
  40. if: steps.root-cache.outputs.cache-hit != 'true'
  41. run: npm ci
  42. - name: Install webview-ui dependencies
  43. if: steps.webview-cache.outputs.cache-hit != 'true'
  44. run: cd webview-ui && npm ci
  45. - name: Run Quality Checks (Parallel)
  46. run: npm run ci:check-all
  47. test:
  48. needs: quality-checks
  49. strategy:
  50. fail-fast: false
  51. matrix:
  52. os: [ubuntu-latest, windows-latest]
  53. runs-on: ${{ matrix.os }}
  54. name: ${{ matrix.os == 'ubuntu-latest' && 'test' || format('test ({0})', matrix.os) }}
  55. defaults:
  56. run:
  57. shell: bash
  58. steps:
  59. - name: Checkout code
  60. uses: actions/checkout@v4
  61. - name: Setup Node.js environment
  62. uses: actions/setup-node@v4
  63. with:
  64. node-version: 22
  65. - name: Cache root dependencies
  66. uses: actions/cache@v4
  67. id: root-cache
  68. with:
  69. path: node_modules
  70. key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
  71. - name: Cache webview-ui dependencies
  72. uses: actions/cache@v4
  73. id: webview-cache
  74. with:
  75. path: webview-ui/node_modules
  76. key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }}
  77. - name: Install root dependencies
  78. if: steps.root-cache.outputs.cache-hit != 'true'
  79. run: npm ci
  80. - name: Install webview-ui dependencies
  81. if: steps.webview-cache.outputs.cache-hit != 'true'
  82. run: cd webview-ui && npm ci
  83. - name: Set up NPM on Windows
  84. if: runner.os == 'Windows'
  85. run: |
  86. npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"
  87. # Build the extension and tests (without redundant checks)
  88. - name: Build Tests and Extension
  89. id: build_step
  90. run: npm run ci:build
  91. - name: Unit Tests with coverage - Linux
  92. id: unit_tests_linux
  93. if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os == 'Linux' }}
  94. run: |
  95. npx nyc --nycrc-path .nycrc.unit.json --reporter=lcov npm run test:unit
  96. - name: Unit Tests - Non-Linux
  97. id: unit_tests_non_linux
  98. if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os != 'Linux' }}
  99. run: |
  100. npm run test:unit
  101. - name: Extension Integration Tests - Linux
  102. id: integration_tests_linux
  103. if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os == 'Linux' }}
  104. run: xvfb-run -a npm run test:coverage
  105. - name: Extension Integration Tests - Non-Linux
  106. id: integration_tests_non_linux
  107. if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os != 'Linux' }}
  108. run: npm run test:integration
  109. - name: Webview Tests with Coverage
  110. id: webview_tests
  111. if: ${{ !cancelled() && steps.build_step.outcome == 'success' }}
  112. run: |
  113. cd webview-ui
  114. npm run test:coverage
  115. - name: Save Coverage Reports
  116. uses: actions/upload-artifact@v4
  117. # Only upload artifacts on Linux - We only need coverage from one OS
  118. if: runner.os == 'Linux'
  119. with:
  120. name: pr-coverage-reports
  121. path: |
  122. coverage-unit/lcov.info
  123. webview-ui/coverage/lcov.info
  124. test-platform-integration:
  125. needs: quality-checks
  126. runs-on: ubuntu-latest
  127. steps:
  128. - name: Checkout code
  129. uses: actions/checkout@v4
  130. - name: Setup Node.js environment
  131. uses: actions/setup-node@v4
  132. with:
  133. node-version: 22
  134. - name: Cache root dependencies
  135. uses: actions/cache@v4
  136. id: root-cache
  137. with:
  138. path: node_modules
  139. key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
  140. - name: Cache webview-ui dependencies
  141. uses: actions/cache@v4
  142. id: webview-cache
  143. with:
  144. path: webview-ui/node_modules
  145. key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }}
  146. # Cache testing-platform dependencies
  147. - name: Cache testing-platform dependencies
  148. uses: actions/cache@v4
  149. id: testing-platform-cache
  150. with:
  151. path: testing-platform/node_modules
  152. key: ${{ runner.os }}-npm-testing-platform-${{ hashFiles('testing-platform/package-lock.json') }}
  153. - name: Install root dependencies
  154. if: steps.root-cache.outputs.cache-hit != 'true'
  155. run: npm ci
  156. - name: Install webview-ui dependencies
  157. if: steps.webview-cache.outputs.cache-hit != 'true'
  158. run: cd webview-ui && npm ci
  159. - name: Setup Go
  160. uses: actions/setup-go@v5
  161. with:
  162. go-version: '1.24'
  163. cache-dependency-path: cli/go.sum
  164. - name: Build CLI binaries
  165. run: npm run compile-cli-all-platforms
  166. - name: Download ripgrep binaries
  167. run: npm run download-ripgrep
  168. - name: Compile NPM package
  169. run: npm run compile-standalone-npm
  170. - name: Install testing platform dependencies
  171. if: steps.testing-platform-cache.outputs.cache-hit != 'true'
  172. run: cd testing-platform && npm ci
  173. - name: Running testing platform integration spec tests
  174. continue-on-error: true
  175. timeout-minutes: 7
  176. # Temporarily wrapping the test command to always return a neutral exit code.
  177. # This prevents the job from showing as failed and avoids distracting developers
  178. # until the integration tests are ready to be enforced.
  179. run: |
  180. npm run test:tp-orchestrator -- tests/specs/ --count=1 --coverage || true
  181. - name: Save Coverage Reports
  182. uses: actions/upload-artifact@v4
  183. with:
  184. name: test-platform-integration-core-coverage
  185. path: coverage/**/lcov.info
  186. qlty:
  187. needs: [test, test-platform-integration]
  188. runs-on: ubuntu-latest
  189. # Run on PRs to main, pushes to main, and manual dispatches
  190. steps:
  191. - name: Checkout code
  192. uses: actions/checkout@v4
  193. - name: Download unit tests coverage reports
  194. uses: actions/download-artifact@v4
  195. with:
  196. name: pr-coverage-reports
  197. path: .
  198. - name: Upload core unit tests coverage to Qlty
  199. uses: qltysh/qlty-action/coverage@v2
  200. with:
  201. token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
  202. # we can merge multiple files if necessary
  203. files: |
  204. coverage-unit/lcov.info
  205. tag: unit:core
  206. - name: Upload webview-ui unit tests coverage to Qlty
  207. uses: qltysh/qlty-action/coverage@v2
  208. with:
  209. token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
  210. # we can merge multiple files if necessary
  211. files: |
  212. webview-ui/coverage/lcov.info
  213. tag: unit:webview-ui
  214. add-prefix: webview-ui/
  215. - name: Download test platform integration core coverage artifact
  216. uses: actions/download-artifact@v4
  217. continue-on-error: true
  218. id: download-integration-coverage
  219. with:
  220. name: test-platform-integration-core-coverage
  221. path: integration-core-coverage-reports
  222. - name: Upload core integration tests coverage to Qlty
  223. if: steps.download-integration-coverage.outcome == 'success'
  224. uses: qltysh/qlty-action/coverage@v2
  225. with:
  226. token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
  227. files: integration-core-coverage-reports/**/lcov.info
  228. tag: integration:core