-
Notifications
You must be signed in to change notification settings - Fork 669
567 lines (498 loc) · 20.7 KB
/
Copy pathtest.yml
File metadata and controls
567 lines (498 loc) · 20.7 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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Tests
on:
push:
branches: [master]
pull_request:
branches: [master, feat/v6]
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
# Detect which parts of the repository changed so we only run the test
# suites that are actually affected:
# - Any Lua script change (the shared core used by every runtime), or a
# change under `scripts/**` used by pretest/build generation, runs ALL
# runtime suites.
# - A change scoped to a single runtime (node/php) runs only that
# runtime's suite.
# - Documentation-only changes only run this change-detection job and a
# no-op `smoke` job (to satisfy required checks).
# Shared build inputs (package.json, yarn.lock, this workflow) are grouped
# under `lua` so that changing them re-runs every runtime as well.
changes:
runs-on: ubuntu-latest
name: detect changed paths
permissions:
contents: read
pull-requests: read
outputs:
lua: ${{ steps.filter.outputs.lua }}
node: ${{ steps.filter.outputs.node }}
php: ${{ steps.filter.outputs.php }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Detect changed paths
id: filter
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
with:
filters: |
lua:
- 'src/commands/**/*.lua'
- 'package.json'
- 'yarn.lock'
- 'scripts/**'
- '.github/workflows/test.yml'
node:
- 'src/**'
- 'tests/**'
- 'tsconfig*.json'
- 'vitest*.ts'
- 'bun-test-preload.ts'
- 'mocha.setup.ts'
- '.mocharc.js'
- 'eslint.config.mjs'
php:
- 'php/**'
# Fast smoke test gate. Runs a small subset of fast, representative tests
# against the default (node + ioredis) adapter with --bail so we fail fast.
# All other heavier jobs depend on this so a quick failure cancels the rest.
# (Vulnerability scanning runs in the separate `osv-scanner.yml` workflow
# and gates merging via branch protection / required checks.)
smoke:
runs-on: ubuntu-latest
needs: changes
name: smoke (lint + fast tests on node@lts, ioredis, redis@7)
env:
node-version: lts/*
redis-version: 7-alpine
steps:
- name: Skip smoke run when node/lua inputs are unchanged
if: ${{ needs.changes.outputs.node != 'true' && needs.changes.outputs.lua != 'true' }}
run: echo "No node/lua changes detected; skipping smoke steps."
- name: Checkout repository
if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js
if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
- name: Start Redis
if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1
with:
redis-version: ${{ env.redis-version }}
- if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- name: Run ESLint
if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
run: yarn lint
- if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
run: yarn build
- if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
run: yarn test:smoke
# Primary ioredis test run on a single (current LTS) Node version.
# Also produces the coverage report — the test set executed by
# `yarn coverage` is exactly `yarn test` + `yarn test:ioredis`, so running
# them under coverage avoids doing the same work twice in CI.
# Acts as the gating job for the other adapters: if this passes,
# node-redis, node-valkey, node-dragonflydb, bun, and the additional
# ioredis Node/Redis version matrix run in parallel.
ioredis-redis:
runs-on: ubuntu-latest
needs: [changes, smoke]
# Keep the matrix job itself materialized so required checks still get the
# concrete matrix-expanded name even when path filtering decides the steps
# should no-op for this PR.
if: ${{ !cancelled() && needs.smoke.result == 'success' }}
name: testing node@${{ matrix.node-version }}, redis@${{ matrix.redis-version }}
env:
allowed_coverage_change: -0.25
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
strategy:
matrix:
node-version: [lts/*]
redis-version: [7-alpine]
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping ioredis coverage job."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Start Redis
if: env.should_run == 'true'
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1
with:
redis-version: ${{ matrix.redis-version }}
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- name: Run tests with coverage (default + ioredis-only suites)
if: env.should_run == 'true'
run: yarn coverage
- name: Upload LCOV to Coveralls
if: ${{ env.should_run == 'true' && (( github.event_name == 'pull_request' && github.event.pull_request.head.fork == false ) || github.event_name == 'push') }}
uses: coverallsapp/github-action@0a51d2e0b5417d06e4ecceb534aec87defc53926 # branch=master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-error: false
- name: Check coverage change not below threshold
if: ${{ env.should_run == 'true' && (( github.event_name == 'pull_request' && github.event.pull_request.head.fork == false ) || github.event_name == 'push') }}
shell: bash
run: |
sleep 2
COVERALLS_RESPONSE=$(curl -fsSL https://coveralls.io/builds/${{ github.sha }}.json || true)
COVERAGE_CHANGE=$(echo "${COVERALLS_RESPONSE}" | jq -er '.coverage_change | select(type == "number")' 2>/dev/null || true)
if [[ -z "${COVERAGE_CHANGE}" ]]; then
echo "::warning::Skipping coverage threshold check because Coveralls was unavailable or did not return a numeric coverage_change."
exit 0
fi
echo coverage changed by ${COVERAGE_CHANGE}%
if [[ -z "$(echo ${COVERAGE_CHANGE} ${{ env.allowed_coverage_change }} | awk '$1 >= $2')" ]]; then
echo current coverage change ${COVERAGE_CHANGE}% below threshold ${{ env.allowed_coverage_change }}%
exit 1
fi
# Additional ioredis matrix coverage. Only runs once the primary
# ioredis-redis job has passed to avoid burning runner time on
# multiple Node/Redis versions when the suite is already broken.
ioredis-redis-extra:
runs-on: ubuntu-latest
needs: [changes, ioredis-redis]
name: testing node@${{ matrix.node-version }}, redis@${{ matrix.redis-version }}
env:
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
strategy:
fail-fast: false
matrix:
node-version: [lts/-1, lts/-2]
redis-version: [7-alpine]
include:
- node-version: 'lts/*'
redis-version: 6-alpine
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping extra ioredis matrix steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Start Redis
if: env.should_run == 'true'
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1
with:
redis-version: ${{ matrix.redis-version }}
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: yarn test
- if: env.should_run == 'true'
run: yarn test:ioredis
node-redis:
runs-on: ubuntu-latest
needs: [changes, ioredis-redis]
name: testing node-redis node@${{ matrix.node-version }}, redis@${{ matrix.redis-version }}
env:
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
strategy:
matrix:
node-version: [lts/*]
redis-version: [7-alpine]
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping node-redis test steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Start Redis
if: env.should_run == 'true'
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1
with:
redis-version: ${{ matrix.redis-version }}
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: yarn test:adapter-conformance
- if: env.should_run == 'true'
run: yarn test:node-redis
node-valkey:
runs-on: ubuntu-latest
needs: [changes, ioredis-redis]
env:
node-version: lts/*
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
name: testing node@lts/*, valkey@8
services:
valkey:
image: valkey/valkey:8-alpine3.20
ports:
- 6379:6379
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping valkey test steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@v7.0.1
- name: Use Node.js ${{ env.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: lts/*
cache: 'yarn'
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: yarn test
node-dragonflydb:
runs-on: ubuntu-latest
needs: [changes, ioredis-redis]
env:
node-version: lts/*
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
name: testing node@lts/*, dragonflydb@latest
services:
dragonflydb:
image: docker.dragonflydb.io/dragonflydb/dragonfly:latest
env:
DFLY_cluster_mode: emulated
DFLY_lock_on_hashtags: true
HEALTHCHECK_PORT: 6379
ports:
- 6379:6379
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping dragonflydb test steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@v7.0.1
- name: Use Node.js ${{ env.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: lts/*
cache: 'yarn'
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: BULLMQ_TEST_PREFIX={b} yarn test
postgres:
runs-on: ubuntu-latest
needs: [changes, ioredis-redis]
name: testing node@${{ matrix.node-version }}, postgres@${{ matrix.postgres-version }}
env:
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
strategy:
matrix:
node-version: [lts/*]
postgres-version: [16]
services:
# The PostgreSQL backend under test. Credentials/database match the
# default POSTGRES_URL used by the tests (see tests/postgres/utils).
# No Redis service: the PostgreSQL test run uses a no-op connection
# factory, so `yarn test:postgres` needs no Redis server.
postgres:
image: postgres:${{ matrix.postgres-version }}-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bullmq_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping postgres test steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
# `yarn build` runs the pretest codegen (raw scripts, command transforms)
# and compiles the sources the shared test classes import.
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: yarn test:postgres
bun-redis:
runs-on: ubuntu-latest
needs: [changes, ioredis-redis]
name: testing bun@${{ matrix.bun-version }}, redis@${{ matrix.redis-version }}
env:
should_run: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.lua == 'true' }}
strategy:
matrix:
bun-version: [latest]
redis-version: [7-alpine]
steps:
- name: Skip when node/lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No node/lua changes detected; skipping Bun test steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Bun
if: env.should_run == 'true'
uses: oven-sh/setup-bun@v2.2.0
with:
bun-version: ${{ matrix.bun-version }}
- name: Use Node.js for yarn
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: lts/*
cache: 'yarn'
- name: Start Redis
if: env.should_run == 'true'
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1
with:
redis-version: ${{ matrix.redis-version }}
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: yarn test:bun:smoke
- if: env.should_run == 'true'
run: yarn test:bun
# node-upstash:
# runs-on: ubuntu-latest
# continue-on-error: true
# env:
# node-version: lts/*
# REDIS_HOST: ${{ secrets.REDIS_HOST }}
# name: testing node@lts/*, upstash@latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3 # v3
# - name: Use Node.js ${{ env.node-version }}
# uses: actions/setup-node@v3 # v3
# with:
# node-version: lts/*
# cache: 'yarn'
# - run: yarn install --ignore-engines --frozen-lockfile --non-interactive
# - run: yarn build
# - run: yarn test
php:
runs-on: ubuntu-latest
needs: [changes, smoke, ioredis-redis]
# Keep failure/cancellation gating at the job level, but leave path gating
# to step-level no-op checks so the matrix-expanded required check name
# still materializes when PHP/Lua files are unchanged.
if: >-
always() &&
!cancelled() &&
needs.smoke.result == 'success' &&
needs.ioredis-redis.result != 'failure' &&
needs.ioredis-redis.result != 'cancelled'
name: testing php@${{ matrix.php-version }}, redis@7
env:
should_run: ${{ needs.changes.outputs.php == 'true' || needs.changes.outputs.lua == 'true' }}
strategy:
matrix:
node-version: [lts/*]
php-version: ['8.1', '8.2', '8.3']
steps:
- name: Skip when PHP/Lua inputs are unchanged
if: env.should_run != 'true'
run: echo "No PHP/Lua changes detected; skipping PHP test steps."
- name: Checkout repository
if: env.should_run == 'true'
uses: actions/checkout@v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
if: env.should_run == 'true'
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Start Redis
if: env.should_run == 'true'
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1
with:
redis-version: 7-alpine
- if: env.should_run == 'true'
run: yarn install --ignore-engines --frozen-lockfile --non-interactive
- if: env.should_run == 'true'
run: yarn build
- if: env.should_run == 'true'
run: yarn copy:lua:php
- name: Setup PHP
if: env.should_run == 'true'
uses: shivammathur/setup-php@2.37.2
with:
php-version: ${{ matrix.php-version }}
extensions: redis, msgpack
tools: composer:v2
- name: Get Composer Cache Directory
if: env.should_run == 'true'
id: composer-cache
working-directory: php
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
if: env.should_run == 'true'
uses: actions/cache@v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('php/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php-version }}-
- name: Install PHP dependencies
if: env.should_run == 'true'
working-directory: php
run: composer install --prefer-dist --no-progress
- name: Run PHPStan
if: env.should_run == 'true'
working-directory: php
run: ./vendor/bin/phpstan analyse src --level=6
- name: Run tests
if: env.should_run == 'true'
working-directory: php
run: ./vendor/bin/phpunit