Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

e2e-tests.yml

217 lines7.4 KB

1name: E2E Tests
2​
3on:
4 push:
5 branches: [main]
6 pull_request:
7​
8concurrency:
9 group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
10 cancel-in-progress: true
11​
12permissions:
13 contents: read
14​
15jobs:
16 e2e-group:
17 name: E2E (${{ matrix.group }})
18 strategy:
19 fail-fast: false
20 matrix:
21 group: [browser, desktop, cloud-mobile]
22 runs-on: ubuntu-latest
23 timeout-minutes: 35
24 env:
25 # Since 2026-10-01 Docker Hub rejects anonymous pulls of
26 # electricsql/electric (401 "authentication required"). The Docker
27 # services and the suites that need Electric are skipped until the
28 # image can be pulled again. Set this back to 'true' then.
29 ELECTRIC_E2E: 'false'
30​
31 steps:
32 - name: Checkout code
33 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34 with:
35 persist-credentials: false
36​
37 - name: Setup pnpm
38 uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7
39 with:
40 cache: false
41​
42 - name: Setup Node.js
43 uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
44 with:
45 node-version: '22.13'
46 cache: 'pnpm'
47​
48 - name: Install dependencies
49 run: pnpm install --frozen-lockfile
50​
51 - name: Start Docker services
52 if: matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
53 run: |
54 cd packages/db-collection-e2e/docker
55 docker compose up -d
56 echo "Waiting for services to be healthy..."
57 timeout 60 bash -c 'until docker compose ps | grep -q "healthy"; do sleep 2; done'
58​
59 - name: Build browser dependencies
60 if: matrix.group == 'browser'
61 run: >-
62 pnpm
63 --filter '@tanstack/react-router-with-db...'
64 --filter '@tanstack/electric-db-collection...'
65 --filter '@tanstack/query-db-collection...'
66 build
67​
68 - name: Build desktop dependencies
69 if: matrix.group == 'desktop'
70 run: >-
71 pnpm
72 --filter '@tanstack/node-db-sqlite-persistence...'
73 --filter '@tanstack/electron-db-sqlite-persistence...'
74 build
75​
76 - name: Build cloud and mobile dependencies
77 if: matrix.group == 'cloud-mobile'
78 run: >-
79 pnpm
80 --filter '@tanstack/cloudflare-durable-objects-db-sqlite-persistence...'
81 --filter '@tanstack/react-native-db-sqlite-persistence...'
82 build
83​
84 - name: Run Electric E2E tests
85 if: matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
86 run: |
87 cd packages/electric-db-collection
88 pnpm test:e2e
89 env:
90 ELECTRIC_URL: http://localhost:3000
91 POSTGRES_HOST: localhost
92 POSTGRES_PORT: 54321
93 POSTGRES_USER: postgres
94 POSTGRES_PASSWORD: password
95 POSTGRES_DB: e2e_test
96​
97 - name: Run Query E2E tests
98 if: matrix.group == 'browser'
99 run: |
100 cd packages/query-db-collection
101 pnpm test:e2e
102 env:
103 ELECTRIC_URL: http://localhost:3000
104​
105 - name: Install Playwright browsers
106 if: matrix.group == 'browser'
107 run: |
108 cd examples/react/start-ssr-e2e
109 pnpm exec playwright install --with-deps chromium
110​
111 - name: Run Browser SQLite OPFS fairness E2E tests
112 if: matrix.group == 'browser'
113 run: |
114 cd packages/browser-db-sqlite-persistence
115 pnpm test:opfs-fairness
116​
117 - name: Run Browser SQLite OPFS with live Electric E2E tests
118 if: matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
119 run: |
120 cd packages/browser-db-sqlite-persistence
121 pnpm test:opfs-electric
122 env:
123 ELECTRIC_URL: http://localhost:3000
124​
125 - name: Run React Start SSR E2E tests
126 if: matrix.group == 'browser'
127 run: |
128 cd examples/react/start-ssr-e2e
129 pnpm exec playwright test
130​
131 - name: Run Next.js SSR E2E tests
132 if: matrix.group == 'browser'
133 run: |
134 cd examples/react/next-ssr-e2e
135 pnpm exec playwright test
136​
137 - name: Run Node SQLite persisted collection E2E tests
138 if: matrix.group == 'desktop'
139 run: |
140 cd packages/node-db-sqlite-persistence
141 pnpm exec vitest --config vitest.e2e.config.ts --run
142​
143 - name: Run Electron SQLite persisted collection E2E tests
144 if: matrix.group == 'desktop'
145 run: |
146 cd packages/electron-db-sqlite-persistence
147 pnpm exec vitest --config vitest.e2e.config.ts --run
148​
149 - name: Run Cloudflare Durable Object persisted collection E2E tests
150 if: matrix.group == 'cloud-mobile'
151 run: |
152 cd packages/cloudflare-durable-objects-db-sqlite-persistence
153 pnpm exec vitest --config vitest.e2e.config.ts --run
154​
155 - name: Run React Native/Expo persisted collection E2E tests
156 if: matrix.group == 'cloud-mobile'
157 run: |
158 cd packages/react-native-db-sqlite-persistence
159 pnpm exec vitest --config vitest.e2e.config.ts --run
160​
161 - name: Run React Native/Expo runtime E2E lane
162 if: matrix.group == 'cloud-mobile'
163 run: |
164 is_fork_pr=false
165 require_runtime_lane=${TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE:-0}
166 if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
167 is_fork_pr=$(jq -r '.pull_request.head.repo.fork' "${GITHUB_EVENT_PATH}")
168 fi
169​
170 if [ "${is_fork_pr}" = "true" ]; then
171 echo "Skipping runtime mobile lane for fork PR (repo vars are unavailable)."
172 exit 0
173 fi
174​
175 if [ -z "${TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE}" ]; then
176 if [ "${require_runtime_lane}" = "1" ]; then
177 echo "::error::Missing repository variable TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE while TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE=1."
178 echo "::error::Set TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE (and optional TANSTACK_DB_MOBILE_SQLITE_FACTORY_EXPORT)."
179 exit 1
180 fi
181​
182 echo "Skipping runtime mobile lane (no TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE configured)."
183 echo "Set TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE=1 to enforce this lane."
184 exit 0
185 fi
186​
187 cd packages/react-native-db-sqlite-persistence
188 TANSTACK_DB_MOBILE_REQUIRE_RUNTIME_FACTORY=1 pnpm exec vitest --config vitest.e2e.config.ts --run
189 env:
190 TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE: ${{ vars.TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE }}
191 TANSTACK_DB_MOBILE_SQLITE_FACTORY_EXPORT: ${{ vars.TANSTACK_DB_MOBILE_SQLITE_FACTORY_EXPORT }}
192 TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE: ${{ vars.TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE }}
193​
194 - name: Stop Docker services
195 if: always() && matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
196 run: |
197 cd packages/db-collection-e2e/docker
198 docker compose down -v
199​
200 - name: Upload test results
201 if: failure()
202 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
203 with:
204 name: test-results-${{ matrix.group }}
205 path: packages/db-collection-e2e/junit/
206 retention-days: 7
207​
208 e2e-tests:
209 name: Run E2E Tests
210 if: always()
211 needs: [e2e-group]
212 runs-on: ubuntu-latest
213 steps:
214 - name: Require every E2E group to succeed
215 env:
216 E2E_RESULT: ${{ needs.e2e-group.result }}
217 run: test "$E2E_RESULT" = success