summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/test.yml
blob: 9c58be30abf54c6196fdf324c18fb8a44a788961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: test

on:
  push:
    branches:
      - dev
  pull_request:
  workflow_dispatch:

concurrency:
  # Keep every run on dev so cancelled checks do not pollute the default branch
  # commit history. PRs and other branches still share a group and cancel stale runs.
  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)) }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  unit:
    name: unit (${{ matrix.settings.name }})
    strategy:
      fail-fast: false
      matrix:
        settings:
          - name: linux
            host: blacksmith-4vcpu-ubuntu-2404
          - name: windows
            host: blacksmith-4vcpu-windows-2025
    runs-on: ${{ matrix.settings.host }}
    defaults:
      run:
        shell: bash
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Setup Bun
        uses: ./.github/actions/setup-bun

      - name: Configure git identity
        run: |
          git config --global user.email "[email protected]"
          git config --global user.name "opencode"

      - name: Run unit tests
        run: bun turbo test

  e2e:
    name: e2e (${{ matrix.settings.name }})
    strategy:
      fail-fast: false
      matrix:
        settings:
          - name: linux
            host: blacksmith-4vcpu-ubuntu-2404
          - name: windows
            host: blacksmith-4vcpu-windows-2025
    runs-on: ${{ matrix.settings.host }}
    env:
      PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.playwright-browsers
    defaults:
      run:
        shell: bash
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Setup Bun
        uses: ./.github/actions/setup-bun

      - name: Read Playwright version
        id: playwright-version
        run: |
          version=$(node -e 'console.log(require("./packages/app/package.json").devDependencies["@playwright/test"])')
          echo "version=$version" >> "$GITHUB_OUTPUT"

      - name: Cache Playwright browsers
        id: playwright-cache
        uses: actions/cache@v4
        with:
          path: ${{ github.workspace }}/.playwright-browsers
          key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ steps.playwright-version.outputs.version }}-chromium

      - name: Install Playwright system dependencies
        if: runner.os == 'Linux'
        working-directory: packages/app
        run: bunx playwright install-deps chromium

      - name: Install Playwright browsers
        if: steps.playwright-cache.outputs.cache-hit != 'true'
        working-directory: packages/app
        run: bunx playwright install chromium

      - name: Run app e2e tests
        run: bun --cwd packages/app test:e2e:local
        env:
          CI: true
        timeout-minutes: 30

      - name: Upload Playwright artifacts
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-${{ matrix.settings.name }}-${{ github.run_attempt }}
          if-no-files-found: ignore
          retention-days: 7
          path: |
            packages/app/e2e/test-results
            packages/app/e2e/playwright-report