Skip to content
Draft
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
59 changes: 53 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,21 @@ jobs:
- name: Set up .NET SDK (via install script)
run: |
# remove any existing install
sudo apt remove dotnet*
sudo apt remove dotnet*
# install key
sudo apt install gpg
wget https://dot.net/v1/dotnet-install.asc
gpg --import dotnet-install.asc
gpg --import dotnet-install.asc
# download and verify
wget https://dot.net/v1/dotnet-install.sh
wget https://dot.net/v1/dotnet-install.sig
gpg --verify dotnet-install.sig dotnet-install.sh
gpg --verify dotnet-install.sig dotnet-install.sh
# run install script
chmod +x dotnet-install.sh
./dotnet-install.sh --channel 10.0
./dotnet-install.sh --channel 10.0
# export env vars
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
dotnet --list-sdks

# the sdk is installed by default, but keep this step for reference
Expand Down Expand Up @@ -646,6 +646,54 @@ jobs:
path: lib/cpp/test/*.xml
retention-days: 3

lib-ruby:
needs: compiler
runs-on: ubuntu-24.04
name: lib-ruby (${{ matrix.ruby-version }}) ${{ matrix.skip-build-ext && 'noext' || '' }}
strategy:
matrix:
ruby-version: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "4.0.0-preview2"]
skip-build-ext: [false]
include:
- ruby-version: "2.7"
skip-build-ext: true

fail-fast: false
env:
SKIP_BUILD_EXT: ${{ matrix.skip-build-ext && '1' || '' }}
steps:
- uses: actions/checkout@v5

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

- name: Run bootstrap
run: ./bootstrap.sh

- name: Run configure
run: |
./configure $(echo $CONFIG_ARGS_FOR_LIBS | sed 's/without-ruby/with-ruby/')

- uses: actions/download-artifact@v6
with:
name: thrift-compiler
path: compiler/cpp

- name: Run thrift-compiler
run: |
chmod a+x compiler/cpp/thrift
compiler/cpp/thrift -version

- name: Run make for ruby
run: make -C lib/rb

- name: Run make check for lib/rb
run: make -C lib/rb check

cross-test:
needs:
- lib-java-kotlin
Expand Down Expand Up @@ -755,4 +803,3 @@ jobs:
name: cross-test-log_${{ matrix.server_lang }}-${{ matrix.client_lang }}
path: test/log/
retention-days: 3

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ project.lock.json
/lib/rb/ext/mkmf.log
/lib/rb/ext/thrift_native.bundle
/lib/rb/ext/thrift_native.so
#/lib/rb/test/
/lib/rb/test/
/lib/rb/thrift-*.gem
/lib/php/src/ext/thrift_protocol/Makefile.*
/lib/php/src/ext/thrift_protocol/build/
Expand Down
2 changes: 1 addition & 1 deletion LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr
<td align=left><a href="https://github.com/apache/thrift/blob/master/lib/rb/README.md">Ruby</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>2.4.0</td><td>2.5.1p57</td>
<!-- Language Levels -------><td>2.7.8</td><td>4.0.0</td>
<!-- Field types -----------><td><img src="/doc/images/cred.png" alt=""/></td>
<!-- Low-Level Transports --><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td>
Expand Down
4 changes: 4 additions & 0 deletions lib/rb/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
source "https://rubygems.org"

gemspec

# Only required for tests with Rack 2.x on Ruby 4.0+
gem 'cgi'
gem 'ostruct'
10 changes: 8 additions & 2 deletions lib/rb/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ PATH
remote: .
specs:
thrift (0.23.0)
logger

GEM
remote: https://rubygems.org/
specs:
binding_of_caller (1.0.1)
debug_inspector (>= 1.2.0)
byebug (11.1.3)
cgi (0.5.0)
coderay (1.1.3)
daemons (1.4.1)
debug_inspector (1.2.0)
diff-lcs (1.6.2)
eventmachine (1.2.7)
logger (1.7.0)
method_source (0.9.2)
ostruct (0.6.3)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand All @@ -27,7 +31,7 @@ GEM
rack (2.2.21)
rack-test (0.8.3)
rack (>= 1.0, < 3)
rake (12.3.3)
rake (13.3.1)
rspec (3.13.2)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand Down Expand Up @@ -57,12 +61,14 @@ PLATFORMS

DEPENDENCIES
bundler (~> 2.2.34)
cgi
ostruct
pry (~> 0.11.3)
pry-byebug (~> 3.6)
pry-stack_explorer (~> 0.4.9.2)
rack (>= 2.2.20)
rack-test (~> 0.8.3)
rake (~> 12.3)
rake (~> 13.3)
rspec (~> 3.7)
srv (~> 1.0)
thin (~> 1.7)
Expand Down
3 changes: 0 additions & 3 deletions lib/rb/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ clean-local:
check-local: all
$(BUNDLER) install
$(BUNDLER) exec rake
$(RUBY) test/TestBinaryProtocol.rb
$(RUBY) test/TestCompactProtocol.rb
$(RUBY) test/TestJsonProtocol.rb

endif

Expand Down
7 changes: 4 additions & 3 deletions lib/rb/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace :'gen-rb' do
dir = File.dirname(__FILE__) + '/benchmark'
sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
end

task :'debug_proto' do
sh "mkdir", "-p", "test/debug_proto"
sh THRIFT, '--gen', 'rb', "-o", "test/debug_proto", "../../test/v0.16/DebugProtoTest.thrift"
Expand All @@ -72,6 +72,7 @@ end
desc "Build the native library"
task :build_ext => :'gen-rb' do
next if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
next if ENV['SKIP_BUILD_EXT'] == '1'
Dir::chdir(File::dirname('ext/extconf.rb')) do
unless sh "ruby #{File::basename('ext/extconf.rb')}"
$stderr.puts "Failed to run extconf"
Expand Down Expand Up @@ -115,6 +116,6 @@ end

CLEAN.include [
'.bundle', 'benchmark/gen-rb', 'coverage', 'ext/*.{o,bundle,so,dll}', 'ext/mkmf.log',
'ext/Makefile', 'ext/conftest.dSYM', 'Gemfile.lock', 'mkmf.log', 'pkg', 'spec/gen-rb',
'test', 'thrift-*.gem'
'ext/Makefile', 'ext/conftest.dSYM', 'ext/thrift_native.bundle.dSYM', 'mkmf.log',
'pkg', 'spec/gen-rb', 'test/debug_proto/gen-rb', 'thrift-*.gem'
]
6 changes: 3 additions & 3 deletions lib/rb/lib/thrift/bytes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ module Bytes
#
# size - The Integer size of the buffer (default: nil) to create
#
# Returns a String with BINARY encoding, filled with null characters
# Returns a String with BINARY encoding, filled with null characters
# if size is greater than zero
def self.empty_byte_buffer(size = nil)
if (size && size > 0)
"\0".force_encoding(Encoding::BINARY) * size
"\0".b * size
else
''.force_encoding(Encoding::BINARY)
"".b
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rb/lib/thrift/protocol/compact_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def read_field_begin

# push the new field onto the field stack so we can keep the deltas going.
@last_field.push(field_id)
["", CompactTypes.get_ttype(type & 0x0f), field_id]
[nil, CompactTypes.get_ttype(type & 0x0f), field_id]
end
end

Expand Down
2 changes: 2 additions & 0 deletions lib/rb/lib/thrift/union.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def write(oprot)
fid = self.name_to_id(@setfield.to_s)

field_info = struct_fields[fid]
raise "set_field is not valid for this union!" unless field_info

type = field_info[:type]
if is_container? type
oprot.write_field_begin(@setfield, type, fid)
Expand Down
145 changes: 0 additions & 145 deletions lib/rb/test/TestBinaryProtocol.rb

This file was deleted.

Loading