test.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. name: test
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. pull_request:
  7. workflow_dispatch:
  8. concurrency:
  9. # Keep every run on dev so cancelled checks do not pollute the default branch
  10. # commit history. PRs and other branches still share a group and cancel stale runs.
  11. group: ${{ case(github.ref == 'refs/heads/dev', format('{0}-{1}', github.workflow, github.run_id), format('{0}-{1}', github.workflow, github.event.pull_request.number || github.ref)) }}
  12. cancel-in-progress: true
  13. permissions:
  14. contents: read
  15. checks: write
  16. env:
  17. FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
  18. jobs:
  19. unit:
  20. name: unit (${{ matrix.settings.name }})
  21. strategy:
  22. fail-fast: false
  23. matrix:
  24. settings:
  25. - name: linux
  26. host: blacksmith-4vcpu-ubuntu-2404
  27. - name: windows
  28. host: blacksmith-4vcpu-windows-2025
  29. runs-on: ${{ matrix.settings.host }}
  30. defaults:
  31. run:
  32. shell: bash
  33. steps:
  34. - name: Checkout repository
  35. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
  36. with:
  37. token: ${{ secrets.GITHUB_TOKEN }}
  38. - name: Setup Node
  39. uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  40. with:
  41. node-version: "24"
  42. - name: Setup Bun
  43. uses: ./.github/actions/setup-bun
  44. - name: Configure git identity
  45. run: |
  46. git config --global user.email "bot@opencode.ai"
  47. git config --global user.name "opencode"
  48. - name: Cache Turbo
  49. uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
  50. with:
  51. path: node_modules/.cache/turbo
  52. key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json', '**/package.json') }}-${{ github.sha }}
  53. restore-keys: |
  54. turbo-${{ runner.os }}-${{ hashFiles('turbo.json', '**/package.json') }}-
  55. turbo-${{ runner.os }}-
  56. - name: Run unit tests
  57. timeout-minutes: 20
  58. run: GITHUB_ACTIONS=false bun turbo test
  59. env:
  60. OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: ${{ runner.os == 'Windows' && 'true' || 'false' }}
  61. - name: Check generated client
  62. if: runner.os == 'Linux'
  63. working-directory: packages/client
  64. run: bun run check:generated
  65. - name: Run HttpApi exerciser gates
  66. if: runner.os == 'Linux'
  67. working-directory: packages/opencode
  68. run: bun run test:httpapi
  69. e2e:
  70. name: e2e (${{ matrix.settings.name }})
  71. strategy:
  72. fail-fast: false
  73. matrix:
  74. settings:
  75. - name: linux
  76. host: blacksmith-4vcpu-ubuntu-2404
  77. - name: windows
  78. host: blacksmith-4vcpu-windows-2025
  79. runs-on: ${{ matrix.settings.host }}
  80. env:
  81. PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.playwright-browsers
  82. defaults:
  83. run:
  84. shell: bash
  85. steps:
  86. - name: Checkout repository
  87. uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
  88. with:
  89. token: ${{ secrets.GITHUB_TOKEN }}
  90. - name: Setup Node
  91. uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  92. with:
  93. # Playwright 1.59 hangs while extracting Chromium with Node 24.16.
  94. node-version: "24.15"
  95. - name: Setup Bun
  96. uses: ./.github/actions/setup-bun
  97. - name: Read Playwright version
  98. id: playwright-version
  99. run: |
  100. version=$(node -e 'console.log(require("./package.json").workspaces.catalog["@playwright/test"])')
  101. echo "version=$version" >> "$GITHUB_OUTPUT"
  102. - name: Cache Playwright browsers
  103. id: playwright-cache
  104. uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
  105. with:
  106. path: ${{ github.workspace }}/.playwright-browsers
  107. key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ steps.playwright-version.outputs.version }}-chromium
  108. - name: Install Playwright system dependencies
  109. if: runner.os == 'Linux'
  110. working-directory: packages/app
  111. run: bunx playwright install-deps chromium
  112. - name: Install Playwright browsers
  113. if: steps.playwright-cache.outputs.cache-hit != 'true'
  114. working-directory: packages/app
  115. run: bunx playwright install chromium
  116. - name: Run app e2e tests
  117. run: bun --cwd packages/app test:e2e:local
  118. env:
  119. CI: true
  120. timeout-minutes: 30
  121. - name: Upload Playwright artifacts
  122. if: always()
  123. uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  124. with:
  125. name: playwright-${{ matrix.settings.name }}-${{ github.run_attempt }}
  126. if-no-files-found: ignore
  127. retention-days: 7
  128. path: |
  129. packages/app/e2e/test-results
  130. packages/app/e2e/playwright-report