test.yml 4.7 KB

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