Skip to content

Commit fc03543

Browse files
ci: test with Valkey
Related: socketio/socket.io#5281
1 parent 71ed4e4 commit fc03543

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ jobs:
3838
--health-retries 5
3939
ports:
4040
- "7000-7005:7000-7005"
41+
valkey:
42+
image: valkey/valkey:8
43+
options: >-
44+
--health-cmd "valkey-cli ping"
45+
--health-interval 10s
46+
--health-timeout 5s
47+
--health-retries 5
48+
ports:
49+
- 6389:6379
50+
4151
steps:
4252
- name: Checkout repository
4353
uses: actions/checkout@v4

compose.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ services:
88
image: grokzen/redis-cluster:7.0.10
99
ports:
1010
- "7000-7005:7000-7005"
11+
12+
valkey:
13+
image: valkey/valkey:8
14+
ports:
15+
- "6389:6379"

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
"format:check": "prettier --parser typescript --check \"lib/**/*.ts\" \"test/**/*.ts\"",
1818
"format:fix": "prettier --parser typescript --write \"lib/**/*.ts\" \"test/**/*.ts\"",
1919
"prepack": "npm run compile",
20-
"test": "npm run format:check && npm run compile && npm run test:redis-standalone && npm run test:redis-cluster && npm run test:ioredis-standalone && npm run test:ioredis-cluster",
20+
"test": "npm run format:check && npm run compile && npm run test:redis-standalone && npm run test:redis-cluster && npm run test:ioredis-standalone && npm run test:ioredis-cluster && npm run test:valkey-standalone",
2121
"test:redis-standalone": "nyc mocha --require ts-node/register test/**/*.ts",
2222
"test:redis-cluster": "cross-env REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts",
2323
"test:ioredis-standalone": "cross-env REDIS_LIB=ioredis mocha --require ts-node/register test/**/*.ts",
24-
"test:ioredis-cluster": "cross-env REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts"
24+
"test:ioredis-cluster": "cross-env REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts",
25+
"test:valkey-standalone": "cross-env VALKEY=1 mocha --require ts-node/register test/**/*.ts"
2526
},
2627
"prettier": {
2728
"endOfLine": "auto"

test/util.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const lib = process.env.REDIS_LIB || "redis";
4343
console.log(`[INFO] testing in ${mode} mode with ${lib}`);
4444

4545
async function initRedisClient() {
46-
if (process.env.REDIS_CLUSTER === "1") {
47-
if (process.env.REDIS_LIB === "ioredis") {
46+
if (mode === "cluster") {
47+
if (lib === "ioredis") {
4848
return new Cluster([
4949
{
5050
host: "localhost",
@@ -100,10 +100,13 @@ async function initRedisClient() {
100100
return redisClient;
101101
}
102102
} else {
103-
if (process.env.REDIS_LIB === "ioredis") {
103+
if (lib === "ioredis") {
104104
return new Redis();
105105
} else {
106-
const redisClient = createClient();
106+
const port = process.env.VALKEY === "1" ? 6389 : 6379;
107+
const redisClient = createClient({
108+
url: `redis://localhost:${port}`,
109+
});
107110
await redisClient.connect();
108111

109112
return redisClient;

0 commit comments

Comments
 (0)