Skip to content

Replace Docker cluster with cluster_manager.py #474

Replace Docker cluster with cluster_manager.py

Replace Docker cluster with cluster_manager.py #474

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
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:standalone
- 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
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build and install Valkey from source
run: |
echo "Building Valkey 8.0.0 from source..."
git clone https://github.com/valkey-io/valkey.git
cd valkey
git checkout 8.0.0
make BUILD_TLS=yes -j4
sudo make install
echo "Verifying Valkey installation..."
valkey-server --version
- 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: Run cluster tests
run: bundle exec rake test:cluster
timeout-minutes: 25
- name: Upload cluster logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: cluster-logs-${{ matrix.ruby }}
path: valkey-glide/utils/clusters/
retention-days: 7