Skip to content

226/merge @ f69a6c8e42a006026ed9d420f0576257083f4144 {} #69

226/merge @ f69a6c8e42a006026ed9d420f0576257083f4144 {}

226/merge @ f69a6c8e42a006026ed9d420f0576257083f4144 {} #69

Workflow file for this run

name: CI
run-name: ${{ inputs.name || format('{0} @ {1} {2}', github.ref_name, github.sha, toJson(inputs)) }}
permissions:
contents: read
actions: read
on:
pull_request:
paths:
- lib/**
- test/**
- valkey-glide/ffi/**
- .github/workflows/**
- .github/json_matrices/**
- Gemfile
- Gemfile.lock
- Rakefile
- valkey.gemspec
push:
branches:
- main
- release-*
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
full-matrix:
description: "Run the full matrix"
type: boolean
default: false
run-with-macos:
description: "Include macOS runners"
type: choice
options:
- "false"
- "use-self-hosted"
- "use-github"
default: "false"
name:
description: "Custom run name"
type: string
required: false
workflow_call:
inputs:
run-with-macos:
description: "Include macOS runners"
type: string
default: "false"
concurrency:
group: ruby-${{ github.head_ref || github.ref }}-${{ toJson(inputs) }}
cancel-in-progress: true
jobs:
lint:
name: Rubocop
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Ruby
uses: ruby/setup-ruby@8e41b362d2589a22a44c1cfa214b3c83052c195b # v1
with:
ruby-version: "3.3"
bundler-cache: true
- name: Lint
run: bundle exec rubocop
get-matrices:
name: Get Matrices
runs-on: ubuntu-latest
outputs:
engine-matrix-output: ${{ steps.create-matrices.outputs.engine-matrix-output }}
host-matrix-output: ${{ steps.create-matrices.outputs.host-matrix-output }}
version-matrix-output: ${{ steps.create-matrices.outputs.version-matrix-output }}
steps:
- name: Check out code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Determine full matrix mode
id: full-matrix
env:
EVENT_NAME: ${{ github.event_name }}
FULL_MATRIX_INPUT: ${{ inputs.full-matrix }}
run: |
if [[ "$EVENT_NAME" == "schedule" ]] || \
[[ "$EVENT_NAME" == "workflow_call" ]] || \
[[ "$EVENT_NAME" == "workflow_dispatch" && "$FULL_MATRIX_INPUT" == "true" ]]; then
echo "run-full-matrix=true" >> "$GITHUB_OUTPUT"
else
echo "run-full-matrix=false" >> "$GITHUB_OUTPUT"
fi
- name: Determine macOS runner mode
id: macos-mode
env:
RUN_WITH_MACOS: ${{ inputs.run-with-macos || 'false' }}
RUN_FULL_MATRIX: ${{ steps.full-matrix.outputs.run-full-matrix }}
run: |
if [[ "$RUN_WITH_MACOS" != "false" ]]; then
echo "run-with-macos=$RUN_WITH_MACOS" >> "$GITHUB_OUTPUT"
elif [[ "$RUN_FULL_MATRIX" == "true" ]]; then
echo "run-with-macos=use-github" >> "$GITHUB_OUTPUT"
else
echo "run-with-macos=false" >> "$GITHUB_OUTPUT"
fi
- name: Create test matrices
id: create-matrices
uses: ./.github/workflows/create-test-matrices
with:
language-name: ruby
run-full-matrix: ${{ steps.full-matrix.outputs.run-full-matrix }}
run-with-macos: ${{ steps.macos-mode.outputs.run-with-macos }}
build-native-library:
name: Build Native Library / ${{ matrix.host.NAMED_OS }}-${{ matrix.host.ARCH }}
needs: [get-matrices]
runs-on: ${{ matrix.host.RUNNER }}
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output) }}
exclude:
- host:
TARGET: "x86_64-unknown-linux-musl"
- host:
TARGET: "aarch64-unknown-linux-musl"
steps:
- name: Check out code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
submodules: recursive
# Composite actions from the valkey-glide submodule use relative paths
# (vs reusable workflows which use org/repo/path@ref syntax)
- name: Install Rust
uses: ./valkey-glide/.github/actions/install-rust
with:
target: ${{ matrix.host.TARGET }}
- name: Install protoc
uses: ./valkey-glide/.github/actions/install-protoc
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
valkey-glide/ffi/target/
key: ${{ matrix.host.TARGET }}-cargo-${{ hashFiles('valkey-glide/ffi/Cargo.lock') }}
restore-keys: |
${{ matrix.host.TARGET }}-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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: native-lib-${{ matrix.host.NAMED_OS }}-${{ matrix.host.ARCH }}
path: valkey-glide/ffi/target/release/libglide_ffi.${{ matrix.host.OS == 'macos' && 'dylib' || 'so' }}
if-no-files-found: error
test-ruby:
name: Test / Ruby ${{ matrix.version }} / ${{ matrix.engine.type }} ${{ matrix.engine.version }} / ${{ matrix.host.NAMED_OS }}-${{ matrix.host.ARCH }}
needs: [build-native-library, get-matrices]
runs-on: ${{ matrix.host.RUNNER }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }}
version: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }}
host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output) }}
exclude:
- host:
TARGET: "x86_64-unknown-linux-musl"
- host:
TARGET: "aarch64-unknown-linux-musl"
steps:
- name: Check out code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
submodules: recursive
- name: Download native library
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: native-lib-${{ matrix.host.NAMED_OS }}-${{ matrix.host.ARCH }}
path: valkey-glide/ffi/target/release/
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.11'
- name: Install Valkey engine
uses: ./valkey-glide/.github/actions/install-engine
with:
engine-version: ${{ matrix.engine.version }}
target: ${{ matrix.host.TARGET }}
- name: Start standalone server via cluster_manager.py
run: |
python3 valkey-glide/utils/cluster_manager.py start -r 0 -p 6379 --prefix standalone
echo "Standalone server started on port 6379"
- name: Start TLS server via cluster_manager.py
if: matrix.host.OS != 'macos'
run: |
python3 valkey-glide/utils/cluster_manager.py --tls start -r 0 -p 6380 --prefix tls-standalone
echo "TLS server started on port 6380"
echo "TLS_CERT_DIR=$(pwd)/valkey-glide/utils/tls_crts" >> $GITHUB_ENV
- name: Set up Ruby
uses: ruby/setup-ruby@8e41b362d2589a22a44c1cfa214b3c83052c195b # v1
with:
ruby-version: ${{ matrix.version }}
bundler-cache: true
- name: Run tests
run: bundle exec rake test
env:
SKIP_TLS_TESTS: ${{ matrix.host.OS == 'macos' && 'true' || '' }}
- name: Upload test artifacts
if: always()
continue-on-error: true
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-report-ruby-${{ matrix.version }}-${{ matrix.engine.type }}-${{ matrix.engine.version }}-${{ matrix.host.NAMED_OS }}-${{ matrix.host.ARCH }}
path: |
test/reports/
tmp/test-results/
retention-days: 7
if-no-files-found: ignore
- name: Upload cluster logs on failure
if: failure()
continue-on-error: true
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: cluster-logs-ruby-${{ matrix.version }}-${{ matrix.engine.type }}-${{ matrix.engine.version }}-${{ matrix.host.NAMED_OS }}-${{ matrix.host.ARCH }}
path: valkey-glide/utils/clusters/
retention-days: 7
if-no-files-found: ignore
- name: Stop servers
if: always()
run: |
python3 valkey-glide/utils/cluster_manager.py stop --prefix standalone || true
# Stop TLS server (skip on macOS where TLS setup is unavailable)
if [[ "${{ matrix.host.OS }}" != "macos" ]]; then
python3 valkey-glide/utils/cluster_manager.py --tls stop --prefix tls-standalone || true
fi
module-tests:
name: Module Tests
needs: [build-native-library]
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Check out code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
submodules: recursive
- name: Download native library
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: native-lib-linux-x64
path: valkey-glide/ffi/target/release/
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.11'
- name: Install Valkey engine
uses: ./valkey-glide/.github/actions/install-engine
with:
engine-version: "9.0"
target: x86_64-unknown-linux-gnu
- name: Start module servers via Docker
uses: ./valkey-glide/.github/actions/start-valkey-docker
with:
engine-version: "9.0"
- name: Set up Ruby
uses: ruby/setup-ruby@8e41b362d2589a22a44c1cfa214b3c83052c195b # v1
with:
ruby-version: "3.4"
bundler-cache: true
- name: Run module tests
run: bundle exec ruby -Itest -Ilib test/standalone/commands_test.rb -n '/TestStandalone(Module|Json|VectorSearch)Commands/'
env:
STANDALONE_ENDPOINTS: ${{ env.MODULES_STANDALONE_ENDPOINT }}
- name: Stop containers
if: always()
run: |
docker stop valkey-modules-standalone && docker rm valkey-modules-standalone || true
for port in $(seq 8001 8006); do
docker stop "valkey-modules-cluster-${port}" && docker rm "valkey-modules-cluster-${port}" || true
done
build-and-test-musl:
name: Test musl / ${{ matrix.engine.type }} ${{ matrix.engine.version }}
needs: [get-matrices]
runs-on: ubuntu-24.04
container:
image: ruby:3.3-alpine
options: --user root --privileged
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }}
steps:
- name: Install system dependencies
run: apk add --no-cache build-base python3 openssl openssl-dev git curl bash protobuf-dev linux-headers
- name: Check out code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
submodules: recursive
- name: Install Rust
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh
sh /tmp/rustup-init.sh -y
rm /tmp/rustup-init.sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache Cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
valkey-glide/ffi/target/
key: musl-x64-cargo-${{ hashFiles('valkey-glide/ffi/Cargo.lock') }}
restore-keys: |
musl-x64-cargo-
- name: Build native library (musl)
working-directory: valkey-glide/ffi
shell: bash
env:
GLIDE_NAME: GlideRuby
GLIDE_VERSION: ${{ github.ref_name }}
RUSTFLAGS: "-C target-feature=-crt-static"
run: |
source "$HOME/.cargo/env"
cargo build --release
- name: Build and install Valkey engine
shell: bash
env:
ENGINE_VERSION: ${{ matrix.engine.version }}
run: |
git clone https://github.com/valkey-io/valkey.git valkey-engine
cd valkey-engine
git checkout $ENGINE_VERSION
make BUILD_TLS=yes -j$(nproc)
make install
- name: Install Ruby dependencies
shell: bash
run: bundle install
- name: Start standalone server
shell: bash
run: |
python3 valkey-glide/utils/cluster_manager.py start -r 0 -p 6379 --prefix standalone
echo "Standalone server started on port 6379"
- name: Start TLS server
shell: bash
run: |
python3 valkey-glide/utils/cluster_manager.py --tls start -r 0 -p 6380 --prefix tls-standalone
echo "TLS server started on port 6380"
echo "TLS_CERT_DIR=$(pwd)/valkey-glide/utils/tls_crts" >> $GITHUB_ENV
- name: Start cluster
shell: bash
run: |
python3 valkey-glide/utils/cluster_manager.py start --cluster-mode -r 1 -n 3 --prefix cluster
echo "Cluster started"
- name: Run tests
shell: bash
run: bundle exec rake test
- name: Upload cluster logs on failure
if: failure()
continue-on-error: true
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: cluster-logs-musl-${{ matrix.engine.type }}-${{ matrix.engine.version }}
path: valkey-glide/utils/clusters/
retention-days: 7
if-no-files-found: ignore
- name: Stop servers
if: always()
shell: bash
run: |
python3 valkey-glide/utils/cluster_manager.py stop --prefix standalone || true
python3 valkey-glide/utils/cluster_manager.py --tls stop --prefix tls-standalone || true
python3 valkey-glide/utils/cluster_manager.py stop --prefix cluster || true