Skip to content

Commit

Permalink
ci: test with Valkey
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Jan 28, 2025
1 parent 71ed4e4 commit 7b54269
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ jobs:
--health-retries 5
ports:
- "7000-7005:7000-7005"
valkey:
image: valkey/valkey:8
options: >-
--health-cmd "valkey-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6389:6379

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ services:
image: grokzen/redis-cluster:7.0.10
ports:
- "7000-7005:7000-7005"

valkey:
image: valkey/valkey:8
ports:
- "6389:6379"
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"format:check": "prettier --parser typescript --check \"lib/**/*.ts\" \"test/**/*.ts\"",
"format:fix": "prettier --parser typescript --write \"lib/**/*.ts\" \"test/**/*.ts\"",
"prepack": "npm run compile",
"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",
"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",
"test:redis-standalone": "nyc mocha --require ts-node/register test/**/*.ts",
"test:redis-cluster": "cross-env REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts",
"test:ioredis-standalone": "cross-env REDIS_LIB=ioredis mocha --require ts-node/register test/**/*.ts",
"test:ioredis-cluster": "cross-env REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts"
"test:ioredis-cluster": "cross-env REDIS_LIB=ioredis REDIS_CLUSTER=1 mocha --require ts-node/register test/**/*.ts",
"test:valkey-standalone": "cross-env VALKEY=1 mocha --require ts-node/register test/**/*.ts"
},
"prettier": {
"endOfLine": "auto"
Expand Down
11 changes: 7 additions & 4 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const lib = process.env.REDIS_LIB || "redis";
console.log(`[INFO] testing in ${mode} mode with ${lib}`);

async function initRedisClient() {
if (process.env.REDIS_CLUSTER === "1") {
if (process.env.REDIS_LIB === "ioredis") {
if (mode === "cluster") {
if (lib === "ioredis") {
return new Cluster([
{
host: "localhost",
Expand Down Expand Up @@ -100,10 +100,13 @@ async function initRedisClient() {
return redisClient;
}
} else {
if (process.env.REDIS_LIB === "ioredis") {
if (lib === "ioredis") {
return new Redis();
} else {
const redisClient = createClient();
const port = process.env.VALKEY === "1" ? 6389 : 6379;
const redisClient = createClient({
url: `redis://localhost:${port}`,
});
await redisClient.connect();

return redisClient;
Expand Down

0 comments on commit 7b54269

Please sign in to comment.