Skip to content

Fix setting of library name #476

Fix setting of library name

Fix setting of library name #476

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
lint:
name: Rubocop
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- name: Lint
run: bundle exec rubocop
build-native-library:
name: Build Native Library
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install protoc (protobuf)
uses: arduino/setup-protoc@v3
with:
version: "29.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
valkey-glide/ffi/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('valkey-glide/ffi/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build native library
working-directory: valkey-glide/ffi
env:
GLIDE_NAME: GlideRuby
GLIDE_VERSION: ${{ github.ref_name }}
run: cargo build --release
- name: Upload native library
uses: actions/upload-artifact@v4
with:
name: native-lib-linux-x64
path: valkey-glide/ffi/target/release/libglide_ffi.so
if-no-files-found: error
standalone:
needs: [build-native-library]
runs-on: ubuntu-latest
name: Standalone / Ruby ${{ matrix.ruby }} Valkey ${{ matrix.valkey }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
ruby:
- 3.4
- 3.3
- 3.2
- 3.1
- 3.0
valkey:
- 7.2.10
- 8
- 8.1
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download native library
uses: actions/download-artifact@v4
with:
name: native-lib-linux-x64
path: valkey-glide/ffi/target/release/
- name: Copy modules for testing
run: |
echo "Copying modules for testing..."
mkdir -p test/fixtures
echo "Copying RedisJSON module for JSON commands testing..."
cp .github/files/librejson-v2.8.15.so test/fixtures/redisjson.so
chmod +x test/fixtures/redisjson.so
ls -lh test/fixtures/redisjson.so
echo "Copying RedisBloom module..."
cp .github/files/redisbloom-amd64-v2.6.12.so test/fixtures/redisbloom.so
chmod +x test/fixtures/redisbloom.so
ls -lh test/fixtures/redisbloom.so
echo "Copying RediSearch module for Vector Search commands testing..."
cp .github/files/redisearch-amd64-v2.10.24.so test/fixtures/redisearch.so
chmod +x test/fixtures/redisearch.so
ls -lh test/fixtures/redisearch.so
- name: Generate SSL certificates for testing
run: |
echo "Generating SSL certificates for SSL/TLS testing..."
ruby test/fixtures/ssl/generate_certs.rb
echo "SSL certificates generated:"
ls -lh test/fixtures/ssl/*.pem
- name: Start Valkey with MODULE commands enabled
run: |
echo "Starting Valkey ${{ matrix.valkey }} with MODULE commands enabled..."
docker run -d \
--name valkey-test \
-p 6379:6379 \
-v $(pwd)/test/fixtures:/tmp/modules:ro \
valkey/valkey:${{ matrix.valkey }} \
valkey-server --enable-module-command yes
echo "Waiting for Valkey to be ready..."
for i in {1..30}; do
if docker exec valkey-test valkey-cli ping > /dev/null 2>&1; then
echo "Valkey is ready!"
break
fi
echo "Waiting... ($i/30)"
sleep 1
done
echo "Verifying MODULE commands are enabled..."
docker exec valkey-test valkey-cli CONFIG GET enable-module-command
echo "Verifying module files are accessible..."
docker exec valkey-test ls -lh /tmp/modules/
- name: Start SSL-enabled Valkey on port 6380
run: |
echo "Creating Valkey SSL configuration..."
cat > /tmp/valkey-ssl.conf << 'EOF'
# Disable regular port, use TLS port only
port 0
tls-port 6380
# SSL/TLS certificate files
tls-cert-file /ssl/server-cert.pem
tls-key-file /ssl/server-key.pem
tls-ca-cert-file /ssl/ca-cert.pem
# Don't require client certificates (optional)
tls-auth-clients no
# Allow TLS v1.2 and v1.3
tls-protocols "TLSv1.2 TLSv1.3"
EOF
echo "SSL configuration created:"
cat /tmp/valkey-ssl.conf
echo "Verifying SSL certificate files exist..."
ls -lh $(pwd)/test/fixtures/ssl/*.pem
echo "Starting SSL-enabled Valkey on port 6380..."
docker run -d \
--name valkey-ssl \
-p 6380:6380 \
-v $(pwd)/test/fixtures/ssl:/ssl:ro \
-v /tmp/valkey-ssl.conf:/etc/valkey-ssl.conf:ro \
valkey/valkey:${{ matrix.valkey }} \
valkey-server /etc/valkey-ssl.conf
echo "Waiting for container to start..."
sleep 2
echo "Checking if container is running..."
docker ps -a | grep valkey-ssl || echo "Container not found!"
echo "Checking container logs..."
docker logs valkey-ssl || echo "Could not get logs"
echo "Verifying SSL cert files are accessible inside container..."
docker exec valkey-ssl ls -lh /ssl/ || echo "Cannot access /ssl/ directory"
docker exec valkey-ssl cat /etc/valkey-ssl.conf || echo "Cannot read config file"
echo "Waiting for SSL Valkey to be ready..."
for i in {1..30}; do
if docker exec valkey-ssl valkey-cli --tls --insecure -p 6380 ping > /dev/null 2>&1; then
echo "SSL Valkey is ready!"
break
fi
echo "Waiting... ($i/30)"
sleep 1
done
echo "Verifying SSL connection from host..."
docker exec valkey-ssl valkey-cli --tls --insecure -p 6380 ping || echo "SSL verification failed"
echo "Testing connection from host machine..."
docker run --rm --network host valkey/valkey:${{ matrix.valkey }} valkey-cli --tls --insecure -p 6380 ping || echo "Host connection test failed"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run standalone tests
run: bundle exec rake test:valkey
- name: Stop Valkey containers
if: always()
run: |
docker stop valkey-test && docker rm valkey-test || true
docker stop valkey-ssl && docker rm valkey-ssl || true
cluster:
needs: [build-native-library]
runs-on: ubuntu-latest
name: Cluster / Ruby ${{ matrix.ruby }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
ruby:
- 3.4
- 3.3
- 3.2
- 3.1
- 3.0
services:
valkey-cluster:
image: grokzen/redis-cluster:7.0.15
ports:
- 7000:7000
- 7001:7001
- 7002:7002
- 7003:7003
- 7004:7004
- 7005:7005
options: >-
--health-cmd "redis-cli -p 7000 ping && redis-cli -p 7001 ping && redis-cli -p 7002 ping"
--health-interval 15s
--health-timeout 10s
--health-retries 15
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download native library
uses: actions/download-artifact@v4
with:
name: native-lib-linux-x64
path: valkey-glide/ffi/target/release/
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Configure cluster nodes
run: |
echo "=== Disabling protected mode on all nodes ==="
for port in 7000 7001 7002 7003 7004 7005; do
echo "Configuring port $port..."
docker exec $(docker ps -q | head -n1) redis-cli -p $port config set protected-mode no || echo "Failed to configure port $port"
done
- name: Wait for cluster to be ready
run: |
echo "=== Waiting for Redis cluster to be fully ready ==="
max_attempts=60
attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt/$max_attempts: Checking cluster state..."
# Check if all nodes are responding
all_nodes_up=true
for port in 7000 7001 7002 7003 7004 7005; do
if ! docker exec $(docker ps -q | head -n1) redis-cli -p $port ping > /dev/null 2>&1; then
echo " Node $port is not responding"
all_nodes_up=false
break
fi
done
if [ "$all_nodes_up" = true ]; then
# Check cluster state
cluster_state=$(docker exec $(docker ps -q | head -n1) redis-cli -p 7000 cluster info | grep "cluster_state" | cut -d: -f2 | tr -d '\r')
echo " Cluster state: $cluster_state"
if [ "$cluster_state" = "ok" ]; then
echo "✅ Cluster is ready!"
break
fi
fi
echo " Cluster not ready yet, waiting 5 seconds..."
sleep 5
attempt=$((attempt + 1))
done
if [ $attempt -gt $max_attempts ]; then
echo "❌ Cluster failed to become ready within timeout"
echo "=== Final cluster info ==="
docker exec $(docker ps -q | head -n1) redis-cli -p 7000 cluster info || echo "Failed to get cluster info"
echo "=== Cluster nodes ==="
docker exec $(docker ps -q | head -n1) redis-cli -p 7000 cluster nodes || echo "Failed to get cluster nodes"
exit 1
fi
- name: Run cluster tests
run: bundle exec rake test:cluster
timeout-minutes: 25