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

e2e-tests.yml

238 lines8.3 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 --filter '@tanstack/indexeddb-db-collection...'
67 build
68​
69 - name: Build desktop dependencies
70 if: matrix.group == 'desktop'
71 run: >-
72 pnpm
73 --filter '@tanstack/node-db-sqlite-persistence...'
74 --filter '@tanstack/electron-db-sqlite-persistence...'
75 build
76​
77 - name: Build cloud and mobile dependencies
78 if: matrix.group == 'cloud-mobile'
79 run: >-
80 pnpm
81 --filter '@tanstack/cloudflare-durable-objects-db-sqlite-persistence...'
82 --filter '@tanstack/react-native-db-sqlite-persistence...'
83 build
84​
85 - name: Run Electric E2E tests
86 if: matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
87 run: |
88 cd packages/electric-db-collection
89 pnpm test:e2e
90 env:
91 ELECTRIC_URL: http://localhost:3000
92 POSTGRES_HOST: localhost
93 POSTGRES_PORT: 54321
94 POSTGRES_USER: postgres
95 POSTGRES_PASSWORD: password
96 POSTGRES_DB: e2e_test
97​
98 - name: Run Query E2E tests
99 if: matrix.group == 'browser'
100 run: |
101 cd packages/query-db-collection
102 pnpm test:e2e
103 env:
104 ELECTRIC_URL: http://localhost:3000
105​
106 - name: Install Playwright browsers
107 if: matrix.group == 'browser'
108 run: |
109 cd examples/react/start-ssr-e2e
110 pnpm exec playwright install --with-deps chromium
111​
112 - name: Install IndexedDB oracle browsers
113 if: matrix.group == 'browser'
114 working-directory: packages/indexeddb-db-collection
115 run: pnpm exec playwright install --with-deps chromium firefox webkit
116 env:
117 PLAYWRIGHT_SKIP_BROWSER_GC: '1'
118​
119 - name: Run IndexedDB native cross-tab oracles
120 if: matrix.group == 'browser'
121 working-directory: packages/indexeddb-db-collection
122 run: pnpm test:browser
123​
124 - name: Upload IndexedDB oracle evidence
125 if: always() && matrix.group == 'browser'
126 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
127 with:
128 name: indexeddb-oracle-evidence
129 path: packages/indexeddb-db-collection/test-results/
130 retention-days: 7
131​
132 - name: Run Browser SQLite OPFS fairness E2E tests
133 if: matrix.group == 'browser'
134 run: |
135 cd packages/browser-db-sqlite-persistence
136 pnpm test:opfs-fairness
137​
138 - name: Run Browser SQLite OPFS with live Electric E2E tests
139 if: matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
140 run: |
141 cd packages/browser-db-sqlite-persistence
142 pnpm test:opfs-electric
143 env:
144 ELECTRIC_URL: http://localhost:3000
145​
146 - name: Run React Start SSR E2E tests
147 if: matrix.group == 'browser'
148 run: |
149 cd examples/react/start-ssr-e2e
150 pnpm exec playwright test
151​
152 - name: Run Next.js SSR E2E tests
153 if: matrix.group == 'browser'
154 run: |
155 cd examples/react/next-ssr-e2e
156 pnpm exec playwright test
157​
158 - name: Run Node SQLite persisted collection E2E tests
159 if: matrix.group == 'desktop'
160 run: |
161 cd packages/node-db-sqlite-persistence
162 pnpm exec vitest --config vitest.e2e.config.ts --run
163​
164 - name: Run Electron SQLite persisted collection E2E tests
165 if: matrix.group == 'desktop'
166 run: |
167 cd packages/electron-db-sqlite-persistence
168 pnpm exec vitest --config vitest.e2e.config.ts --run
169​
170 - name: Run Cloudflare Durable Object persisted collection E2E tests
171 if: matrix.group == 'cloud-mobile'
172 run: |
173 cd packages/cloudflare-durable-objects-db-sqlite-persistence
174 pnpm exec vitest --config vitest.e2e.config.ts --run
175​
176 - name: Run React Native/Expo persisted collection E2E tests
177 if: matrix.group == 'cloud-mobile'
178 run: |
179 cd packages/react-native-db-sqlite-persistence
180 pnpm exec vitest --config vitest.e2e.config.ts --run
181​
182 - name: Run React Native/Expo runtime E2E lane
183 if: matrix.group == 'cloud-mobile'
184 run: |
185 is_fork_pr=false
186 require_runtime_lane=${TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE:-0}
187 if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
188 is_fork_pr=$(jq -r '.pull_request.head.repo.fork' "${GITHUB_EVENT_PATH}")
189 fi
190​
191 if [ "${is_fork_pr}" = "true" ]; then
192 echo "Skipping runtime mobile lane for fork PR (repo vars are unavailable)."
193 exit 0
194 fi
195​
196 if [ -z "${TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE}" ]; then
197 if [ "${require_runtime_lane}" = "1" ]; then
198 echo "::error::Missing repository variable TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE while TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE=1."
199 echo "::error::Set TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE (and optional TANSTACK_DB_MOBILE_SQLITE_FACTORY_EXPORT)."
200 exit 1
201 fi
202​
203 echo "Skipping runtime mobile lane (no TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE configured)."
204 echo "Set TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE=1 to enforce this lane."
205 exit 0
206 fi
207​
208 cd packages/react-native-db-sqlite-persistence
209 TANSTACK_DB_MOBILE_REQUIRE_RUNTIME_FACTORY=1 pnpm exec vitest --config vitest.e2e.config.ts --run
210 env:
211 TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE: ${{ vars.TANSTACK_DB_MOBILE_SQLITE_FACTORY_MODULE }}
212 TANSTACK_DB_MOBILE_SQLITE_FACTORY_EXPORT: ${{ vars.TANSTACK_DB_MOBILE_SQLITE_FACTORY_EXPORT }}
213 TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE: ${{ vars.TANSTACK_DB_REQUIRE_MOBILE_RUNTIME_LANE }}
214​
215 - name: Stop Docker services
216 if: always() && matrix.group == 'browser' && env.ELECTRIC_E2E == 'true'
217 run: |
218 cd packages/db-collection-e2e/docker
219 docker compose down -v
220​
221 - name: Upload test results
222 if: failure()
223 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
224 with:
225 name: test-results-${{ matrix.group }}
226 path: packages/db-collection-e2e/junit/
227 retention-days: 7
228​
229 e2e-tests:
230 name: Run E2E Tests
231 if: always()
232 needs: [e2e-group]
233 runs-on: ubuntu-latest
234 steps:
235 - name: Require every E2E group to succeed
236 env:
237 E2E_RESULT: ${{ needs.e2e-group.result }}
238 run: test "$E2E_RESULT" = success