forked from liveblocks/liveblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
397 lines (326 loc) · 12.5 KB
/
tests.yml
File metadata and controls
397 lines (326 loc) · 12.5 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: Tests
on: [pull_request]
jobs:
# Check if there are any code changes in the PR (not docs, examples, changelogs, etc.)
# If not, the tests will be skipped and marked as successful
check_for_code_changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
predicate-quantifier: "every"
filters: |
changes:
- '**/*'
- '!docs/**'
- '!examples/**'
- '!guides/**'
- '!starter-kits/**'
- '!tutorials/**'
- '!CHANGELOG.md'
- '!CHANGELOG_PUBLIC.md'
test:
needs: check_for_code_changes
runs-on: ubuntu-latest
# Run the Liveblocks dev server on port 1154 for all tests
services:
liveblocks:
image: ghcr.io/liveblocks/dev-server:main
ports:
- 1154:1153
strategy:
matrix:
node-version: [22.21.0]
pkg:
[
"@liveblocks/core",
"@liveblocks/client",
"@liveblocks/react",
"@liveblocks/redux",
"@liveblocks/zustand",
"@liveblocks/node",
"@liveblocks/yjs",
"@liveblocks/react-ui",
"@liveblocks/react-lexical",
"@liveblocks/react-tiptap",
"@liveblocks/react-blocknote",
"@liveblocks/node-lexical",
"@liveblocks/node-prosemirror",
"@liveblocks/codemod",
"@liveblocks/emails",
]
steps:
- name: Checkout
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/checkout@v4
- name: Use Node ${{ matrix.node-version }}
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Install dependencies
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm install
- name: Turbo Cache
if: needs.check_for_code_changes.outputs.changes == 'true'
id: turbo-cache
uses: actions/cache@v4
with:
key: turbo-cache-${{ matrix.node-version }}-${{ matrix.pkg }}-bust3
path: node_modules/.cache/turbo
restore-keys:
turbo-cache-${{ matrix.node-version }}-${{ matrix.pkg }}-bust3
- name: Install Bun
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: oven-sh/setup-bun@v1
- name: Build
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run build -- --filter ${{ matrix.pkg }}
- name: Ensure no files are changed
if: needs.check_for_code_changes.outputs.changes == 'true'
run: |
CHANGED=$(git status --porcelain)
if [ -n "$CHANGED" ]; then
echo "Local, uncommitted changes found:"
echo "$CHANGED"
exit 1
fi
- name: Run unit tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test:ci -- --filter ${{ matrix.pkg }} -- --coverage
- name: Run type tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test:types -- --filter ${{ matrix.pkg }}
- name: Run dependency tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test:deps -- --filter ${{ matrix.pkg }}
- name: Run lint checks
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run lint -- --filter ${{ matrix.pkg }}
- name: Run public NPM packaging lint checks
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run lint:package -- --filter ${{ matrix.pkg }}
# E2E tests defined in e2e/next-sandbox package
e2e-next-sandbox:
needs: check_for_code_changes
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.21.0]
timeout-minutes: 60
env:
LIVEBLOCKS_SECRET_KEY: ${{ secrets.E2E_TEST_LIVEBLOCKS_SECRET_KEY }}
NEXT_PUBLIC_GITHUB_SHA: ${{ github.sha }}
NEXT_PUBLIC_LIVEBLOCKS_BASE_URL: ${{ vars.E2E_TEST_LIVEBLOCKS_BASE_URL }}
NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY:
${{ secrets.E2E_TEST_LIVEBLOCKS_PUBLIC_KEY }}
steps:
- name: Checkout
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/checkout@v4
- name: Use Node ${{ matrix.node-version }}
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Install dependencies
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm install
- name: Install Playwright
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npx playwright install chromium --no-shell --with-deps
- name: Run Playwright tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test -- --filter @liveblocks/next-sandbox
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: e2e/next-sandbox/playwright-report
retention-days: 14
# E2E tests defined in e2e/next-ai-kitchen-sink package
e2e-next-ai-sandbox:
needs: check_for_code_changes
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.21.0]
timeout-minutes: 60
env:
NEXT_PUBLIC_GITHUB_SHA: ${{ github.sha }}
NEXT_PUBLIC_LIVEBLOCKS_BASE_URL: ${{ vars.E2E_TEST_LIVEBLOCKS_BASE_URL }}
NEXT_PUBLIC_LIVEBLOCKS_DEFAULT_COPILOT_ID:
${{ vars.NEXT_PUBLIC_LIVEBLOCKS_DEFAULT_COPILOT_ID }}
LIVEBLOCKS_SECRET_KEY: ${{ secrets.E2E_TEST_LIVEBLOCKS_SECRET_KEY }}
steps:
- name: Checkout
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/checkout@v4
- name: Use Node ${{ matrix.node-version }}
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Install dependencies
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm install
- name: Install Playwright
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npx playwright install chromium --no-shell --with-deps
- name: Run AI Playwright tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test -- --filter @liveblocks/next-ai-kitchen-sink
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ai-playwright-report
path: e2e/next-ai-kitchen-sink/playwright-report
retention-days: 14
# E2E tests defined in e2e/node-sandbox package
e2e-node-sandbox:
needs: check_for_code_changes
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.21.0]
timeout-minutes: 60
env:
LIVEBLOCKS_SECRET_KEY: ${{ secrets.E2E_TEST_LIVEBLOCKS_SECRET_KEY }}
PUBLIC_LIVEBLOCKS_PUBLIC_KEY:
${{ secrets.E2E_TEST_LIVEBLOCKS_PUBLIC_KEY }}
NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY:
${{ secrets.E2E_TEST_LIVEBLOCKS_PUBLIC_KEY }}
NEXT_PUBLIC_LIVEBLOCKS_BASE_URL: ${{ vars.E2E_TEST_LIVEBLOCKS_BASE_URL }}
steps:
- name: Checkout
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/checkout@v4
- name: Use Node ${{ matrix.node-version }}
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Install dependencies
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm install
- name: Run node-sandbox tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test -- --filter node-sandbox
# E2E tests defined in @liveblocks/core package
e2e-client-specs:
needs: check_for_code_changes
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.21.0]
timeout-minutes: 60
steps:
- name: Checkout
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/checkout@v4
- name: Use Node ${{ matrix.node-version }}
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Install Bun
if: needs.check_for_code_changes.outputs.changes == 'true'
uses: oven-sh/setup-bun@v1
- name: Install dependencies
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm install
- name: Run e2e client specs tests
if: needs.check_for_code_changes.outputs.changes == 'true'
run: npm run test:e2e
working-directory: packages/liveblocks-core
# Check that the generated Python SDK is up to date with the OpenAPI spec
python-sdk-sync:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
python_sdk:
- 'docs/references/v2.openapi.json'
- 'packages/liveblocks-python-codegen/templates/**'
- 'packages/liveblocks-python-codegen/config.yaml'
- 'packages/liveblocks-python-codegen/generate.py'
- name: Checkout
if: steps.filter.outputs.python_sdk == 'true'
uses: actions/checkout@v4
- name: Install uv
if: steps.filter.outputs.python_sdk == 'true'
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
- name: Regenerate Python SDK
if: steps.filter.outputs.python_sdk == 'true'
run: uv run python generate.py
working-directory: packages/liveblocks-python-codegen
- name: Check for uncommitted changes
if: steps.filter.outputs.python_sdk == 'true'
run: |
CHANGED=$(git status --porcelain packages/liveblocks-python)
if [ -n "$CHANGED" ]; then
echo "The generated Python SDK is out of date. Please run 'uv run python generate.py' in packages/liveblocks-python-codegen and commit the changes."
echo ""
echo "Changed files:"
echo "$CHANGED"
echo ""
git diff packages/liveblocks-python
exit 1
fi
# Python lint + tests with coverage
test-python:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
python_sdk:
- 'packages/liveblocks-python/**'
- 'packages/liveblocks-python-codegen/**'
- name: Checkout
if: steps.filter.outputs.python_sdk == 'true'
uses: actions/checkout@v4
- name: Install uv
if: steps.filter.outputs.python_sdk == 'true'
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
- name: Lint
if: steps.filter.outputs.python_sdk == 'true'
run: uvx ruff check .
working-directory: packages/liveblocks-python
- name: Run Python tests with coverage
if: steps.filter.outputs.python_sdk == 'true'
run:
uv run pytest --cov --cov-report=term-missing
--cov-report=xml:coverage.xml
working-directory: packages/liveblocks-python
- name: Post coverage report as PR comment
if:
steps.filter.outputs.python_sdk == 'true' && github.event_name ==
'pull_request'
uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac # v3.2
with:
coverageFile: packages/liveblocks-python/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.0