Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Ruby binding #1032

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .devcontainer/bindings-ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye

# Install libclang
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libclang-dev\
&& apt-get clean && rm -rf /var/lib/apt/lists/*
21 changes: 21 additions & 0 deletions .devcontainer/bindings-ruby/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "Rust with Ruby",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/ruby:1": {
"version": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
"Shopify.ruby-lsp"
]
}
},
"onCreateCommand": "pwd; cd bindings/ruby; bundle install"
}
Copy link
Author

@kuboon kuboon Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.devcontainer/bindings-ruby files are for ruby users (like me) to easily join contributing.
You can add .devcontainer/bindings-python etc.
https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#devcontainerjson

66 changes: 66 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Ruby

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main

env:
working-directory: bindings/ruby

jobs:
configure-strategy:
runs-on: ubuntu-latest
outputs:
ruby-versions: ${{ steps.gen-matrix.outputs.ruby-versions }}
steps:
- id: gen-matrix
run: |
if [ ${{ github.event_name }} == "pull_request" ]; then
echo "ruby-versions=[\"3.4\"]" >> $GITHUB_OUTPUT
else
echo "ruby-versions=[\"3.1\",\"3.2\",\"3.3\",\"3.4\"]" >> $GITHUB_OUTPUT
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fi

test:
needs: configure-strategy
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
ruby-version: ${{ fromJson(needs.configure-strategy.outputs.ruby-versions) }}
runs-on: ${{ matrix.os }}

defaults:
run:
working-directory: ${{ env.working-directory }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@stable

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Install dependencies
run: bundle install

- name: compile
run: rake compile

- name: Run test
run: rake test

127 changes: 127 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"bindings/go",
"bindings/java",
"bindings/python",
"bindings/ruby",
"bindings/rust",
"bindings/wasm",
"cli",
Expand Down
23 changes: 23 additions & 0 deletions bindings/ruby/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Rust build artifacts
/target
**/*.rs.bk

# Ruby build artifacts
*.gem
*.rbc
.bundle
.config
coverage/
InstalledFiles
lib/bundler/man/
pkg/
rdoc/
tmp/

# OS generated files
.DS_Store
*.swp
*~
.project
.idea
.vscode
3 changes: 3 additions & 0 deletions bindings/ruby/.standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# For available configuration options, see:
# https://github.com/standardrb/standard
ruby_version: 3.4
18 changes: 18 additions & 0 deletions bindings/ruby/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "ruby-limbo"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[lib]
name = "limbo"
path = "ext/limbo/src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
magnus = "0.7"
limbo_core = { workspace = true, features = ["io_uring"] }
thiserror = "2.0.9"
tokio = { version = "1.29.1", features = ["full"] }
11 changes: 11 additions & 0 deletions bindings/ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "https://rubygems.org"

gemspec

group :development, :test do
gem "minitest", "~> 5.16"
gem "rake", "~> 13.0"
gem "rake-compiler", "~> 1.2.0"
gem "rb_sys", "~> 0.9.63"
gem "standard", "~> 1.3"
end
Loading
Loading