Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0d747dd
build: add a precompiled x86_64-linux platform gem task
claude Nov 30, 2026
9d3b4d0
ci: add a manual workflow to build and smoke-test the native gem
claude Nov 30, 2026
e6e5592
ci: temporarily also trigger on pull_request to test this workflow on…
claude Nov 30, 2026
1462d3c
ci: install libyaml-0-2 in the smoke-test containers
claude Nov 30, 2026
acb091e
build: drop rice/rake-compiler from the precompiled gem's dependencies
claude Nov 30, 2026
3a0e2eb
build+ci: add aarch64-linux as a second precompiled platform
claude Nov 30, 2026
133fe42
ci: keep pull_request trigger permanently, scoped to relevant paths
claude Nov 30, 2026
b032ed7
build: pin+verify libpulsar checksums, strip stale RUNPATH, pin Ruby ABI
claude Nov 30, 2026
a114581
ci: fix smoke-test to actually test the installed gem, add permissions
claude Nov 30, 2026
aaa6f3d
docs: fix version requirement and remove-fallback claim in README
claude Nov 30, 2026
dbe4019
build: clean up vendored/compiled .so files, gitignore them too
claude Nov 30, 2026
7247c60
build: support a CI-supplied build number for continuous publish vers…
claude Nov 30, 2026
760de86
ci: add continuous publish on master, gated behind workflow_dispatch …
claude Nov 30, 2026
e8318cf
docs: self-contained guide for consuming the precompiled gem
claude Nov 30, 2026
091ddfc
build: make each platform's published version unique per run
claude Nov 30, 2026
4dfc4b6
ci: verify the published gem actually installs from the real registry
claude Nov 30, 2026
b4adcff
ci: fix verify-publish to use the scoped Bundler source, not plain ge…
claude Nov 30, 2026
884fdef
ci: merge verify-publish's install/require steps, add Gemfile.lock di…
claude Nov 30, 2026
38c626f
ci: add a temporary diagnostic job for the GitHub Packages platform i…
claude Dec 1, 2026
b0763f5
build: publish per-architecture gems under separate names
claude Dec 1, 2026
96ceced
ci: update verify-publish for per-arch gem names, drop diagnose-registry
claude Dec 1, 2026
187358e
docs: document per-architecture gem names, one Gemfile block for both
claude Dec 1, 2026
b99508a
docs: fix the Gemfile pattern - install_if, real fallback, require: o…
claude Dec 1, 2026
fa4080a
ci: verify-publish now uses the exact install_if Gemfile from the README
claude Dec 1, 2026
5cefa63
ci: flip publish to run automatically on push to master
claude Dec 1, 2026
a16a7d5
ci: fix verify-publish being unreachable after the publish rollout flip
claude Dec 1, 2026
557b619
ci: retry apt-get update with backoff in container jobs
claude Dec 1, 2026
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
92 changes: 92 additions & 0 deletions .github/workflows/release-native-gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build precompiled native gem

# workflow_dispatch needs this file merged to the default branch before
# GitHub will let it be triggered, so pull_request is here temporarily too:
# it runs even for a workflow file that only exists on the PR's branch,
# which is what lets this get a real CI run on PR #6 before anything
# merges. Remove the pull_request trigger (or keep it, if it proves useful
# as permanent per-PR coverage) once that run is verified.
on:
workflow_dispatch: {}
pull_request: {}
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved

jobs:
build-x86_64-linux:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4.13"
bundler-cache: true

- name: Build the precompiled x86_64-linux gem
run: bundle exec rake gem:native:x86_64-linux

- uses: actions/upload-artifact@v4
with:
name: pulsar-client-x86_64-linux-gem
path: pkg/*.gem
if-no-files-found: error

# Installs the gem built above into a genuinely clean container - no
# libpulsar, no C++ toolchain - and runs the non-broker specs against it,
# to prove the *shipped artifact* works, not just the build tree. Runs
# against both 22.04 (what we build on) and 24.04, as real evidence for
# the "newer glibc is backwards-compatible" forward-compat claim before
# also informally relying on it for 26.04.
smoke-test:
needs: build-x86_64-linux
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
image: ["ubuntu:22.04", "ubuntu:24.04"]
container:
image: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: pulsar-client-x86_64-linux-gem
path: pkg

# Deliberately minimal: curl/ca-certificates only, for setup-ruby's
# own download. No build-essential, no gcc, no libpulsar - if the gem
# needed any of those to install or load, this step (or the ones
# after it) would fail.
- name: Install only what's needed to fetch Ruby
run: |
apt-get update
apt-get install -y --no-install-recommends curl ca-certificates

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4.13"

- name: Install the precompiled gem (no Gemfile/bundler involved)
run: gem install pkg/*.gem --local --no-document

- name: Require it and construct a client
run: |
ruby -e '
require "pulsar/client"
puts "VERSION=#{Pulsar::Client::VERSION}"
cfg = Pulsar::ClientConfiguration.new
client = Pulsar::Client.new("pulsar://localhost:6650", cfg)
client.close
puts "Client constructed and closed OK"
'

# Deliberately not `bundle install`: the Gemfile's `gemspec` directive
# would try to build pulsar-client from the checked-out source, which
# is exactly what this container has no compiler for. Install rspec
# directly instead, and run it against the already gem-installed
# (precompiled) pulsar-client from the previous step.
- name: Run the non-broker spec suite against the installed gem
run: |
gem install rspec --no-document
installed_lib=$(ruby -e 'puts Gem::Specification.find_by_name("pulsar-client").lib_dirs_glob')
rspec -I"$installed_lib" spec/pulsar --exclude-pattern "spec/pulsar/ext_spec.rb"
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**[This project is no longer under active development. It has been archived]**

# Apache Pulsar Ruby client

## Installation
Expand Down Expand Up @@ -27,6 +25,30 @@ Note #2: This is a pre-release version of this Gem. You will need the
`--pre` flag to `gem install` to install it manually, and must include
the `.pre` suffix in the Gemfile to install it via Bundler.

### Precompiled gem (x86_64-linux)

For `x86_64-linux` (Ubuntu 22.04 and newer - glibc's backwards compatibility
means a build against 22.04's glibc also runs on 24.04/26.04), a
precompiled gem is available via GitHub Packages, with `libpulsar.so`
vendored in. Installing it needs no C++ toolchain and no system `libpulsar`
(Note #1 above doesn't apply to this variant).

Add the package registry as a gem source and depend on the gem as usual:

```ruby
# Gemfile
source "https://rubygems.pkg.github.com/get-bridge" do
gem "pulsar-client", "~> 2.6.1.pre"
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
end
```

Installing from this source requires GitHub Packages credentials (a
`~/.gem/credentials` entry or `BUNDLE_RUBYGEMS__PKG__GITHUB__COM` env var
with a token that has `read:packages` access to this repository).

Any other platform (macOS, `aarch64-linux`, older/newer Ruby) falls back to
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
the source gem and the from-source instructions below.

## Usage

Setup and basic `consumer.receive` example:
Expand Down
64 changes: 64 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "rspec/core/rake_task"
require "rake/extensiontask"
require "fileutils"
require "tmpdir"

RSpec::Core::RakeTask.new(:spec)

Expand All @@ -8,3 +10,65 @@ task :default => [:compile, :spec]
Rake::ExtensionTask.new "bindings" do |ext|
ext.lib_dir = "lib/pulsar"
end

# The Apache Pulsar C++ client version precompiled platform gems vendor.
# Bump this, re-run the native gem tasks below, and re-verify to upgrade.
PULSAR_CPP_VERSION = "4.2.0"

# platform name => Apache release archive's per-arch deb directory name.
# Add "aarch64-linux" => "deb-arm64" here once that platform is verified.
NATIVE_GEM_PLATFORMS = {
"x86_64-linux" => "deb-x86_64"
}.freeze

namespace :gem do
namespace :native do
NATIVE_GEM_PLATFORMS.each do |platform, deb_dir|
desc "Build a precompiled #{platform} gem with libpulsar.so vendored in"
task platform do
build_native_gem(platform, deb_dir)
end
end
end
end

# Builds a precompiled platform gem for the given rubygems platform string,
# vendoring libpulsar.so (fetched from Apache's release archive for the
# given deb_dir, e.g. "deb-x86_64") so the gem needs no system libpulsar or
# C++ toolchain to install. See ext/bindings/extconf.rb's -rpath,$ORIGIN
# flag, which is what lets the vendored .so be found at runtime.
def build_native_gem(platform, deb_dir)
base_url = "https://archive.apache.org/dist/pulsar/pulsar-client-cpp-#{PULSAR_CPP_VERSION}/#{deb_dir}"

Dir.mktmpdir("pulsar-native-gem-#{platform}") do |tmp|
runtime_deb = File.join(tmp, "apache-pulsar-client.deb")
dev_deb = File.join(tmp, "apache-pulsar-client-dev.deb")
sh "curl -sSL -o #{runtime_deb} #{base_url}/apache-pulsar-client.deb"
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
sh "curl -sSL -o #{dev_deb} #{base_url}/apache-pulsar-client-dev.deb"

extracted = File.join(tmp, "extracted")
FileUtils.mkdir_p(extracted)
sh "dpkg-deb -x #{runtime_deb} #{extracted}"
sh "dpkg-deb -x #{dev_deb} #{extracted}"

Rake::Task["clean"].invoke
Rake::Task["clobber"].invoke
sh "bundle exec rake compile -- --with-pulsar-dir=#{File.join(extracted, 'usr')}"
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved

vendored_lib = File.join("lib", "pulsar", "libpulsar.so")
FileUtils.cp(File.join(extracted, "usr", "lib", "libpulsar.so"), vendored_lib)
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
compiled_ext = File.join("lib", "pulsar", "bindings.so")
raise "#{compiled_ext} missing after compile" unless File.exist?(compiled_ext)

spec = Gem::Specification.load("pulsar-client.gemspec").dup
spec.platform = Gem::Platform.new(platform)
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
spec.extensions = []
Comment thread
gmiklos-ltg marked this conversation as resolved.
Resolved
spec.files += [vendored_lib, compiled_ext]

FileUtils.mkdir_p("pkg")
Gem::Package.build(spec)
FileUtils.mv("#{spec.full_name}.gem", File.join("pkg", "#{spec.full_name}.gem"))

puts "Built pkg/#{spec.full_name}.gem"
end
end
10 changes: 10 additions & 0 deletions ext/bindings/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@

$CXXFLAGS += ' -std=c++17 ' unless $CXXFLAGS.include?('-std=')

# Lets a libpulsar.so placed next to bindings.so (e.g. a vendored copy
# bundled into a precompiled platform gem, see Rakefile's native_gem task)
# be found at runtime without needing libpulsar installed system-wide.
# Harmless for a normal from-source build: it's just an extra search path
# that resolves to nothing if there's no libpulsar.so there. $$ORIGIN
# survives Makefile variable expansion as $ORIGIN, then must reach the
# linker un-expanded by the shell - single-quoted so the shell doesn't try
# to expand it as an env var.
$LDFLAGS << %q{ -Wl,-rpath,'$$ORIGIN'}

create_makefile('pulsar/bindings')
Loading