Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
299 changes: 299 additions & 0 deletions .github/workflows/release-native-gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
name: Build precompiled native gem

# pull_request: proved its worth catching 3 real bugs pre-merge (missing
# libyaml-0-2, a stale rice/rake-compiler runtime dependency, verifying
# aarch64-linux) - kept permanently, scoped to only the files that
# actually affect this pipeline so it doesn't fire on unrelated PRs (e.g.
# a README typo fix).
# push (master): publishes a fresh build on every commit - see the
# `publish` job's rollout-gate comment below before expecting that to
# actually happen yet.
on:
workflow_dispatch: {}
pull_request:
paths:
- "Rakefile"
- "ext/**"
- "pulsar-client.gemspec"
- ".github/workflows/release-native-gem.yml"
# Every master commit gets a fresh, publishable build (see the `publish`
# job below) - deliberately no `paths:` filter here, unlike pull_request
# above, since "always up to date" means every commit, not just ones
# that touch the build pipeline itself.
push:
branches:
- master

# Least privilege: this workflow only builds, packages and smoke-tests.
# A future publish job should request its own `packages: write` rather than
# widening this.
permissions:
contents: read

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- platform: x86_64-linux
runner: ubuntu-22.04
# GitHub's native arm64-hosted Linux runner (free for public
# repos) - builds natively, no QEMU cross-compilation involved.
- platform: aarch64-linux
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4

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

- name: Install patchelf (used to strip the build host's RUNPATH)
run: sudo apt-get update && sudo apt-get install -y patchelf

- name: Build the precompiled ${{ matrix.platform }} gem
env:
# Set unconditionally (every trigger, not just a real publish on
# push-to-master) so the exact artifact that gets smoke-tested
# below is the same one that (on master) gets published - no
# separate rebuild step that could silently differ from what was
# tested. See Rakefile's build_native_gem.
PULSAR_GEM_BUILD_NUMBER: ${{ github.run_number }}
run: bundle exec rake gem:native:${{ matrix.platform }}

- uses: actions/upload-artifact@v4
with:
name: pulsar-client-${{ matrix.platform }}-gem
path: pkg/*.gem
if-no-files-found: error

# Installs each 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. Each
# platform's smoke-test runs on a matching-arch runner, so Docker pulls
# the right-arch container image and the installed gem's .so runs
# natively there too (no emulation). 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
strategy:
fail-fast: false
matrix:
include:
- platform: x86_64-linux
runner: ubuntu-22.04
image: "ubuntu:22.04"
- platform: x86_64-linux
runner: ubuntu-22.04
image: "ubuntu:24.04"
- platform: aarch64-linux
runner: ubuntu-22.04-arm
image: "ubuntu:22.04"
- platform: aarch64-linux
runner: ubuntu-22.04-arm
image: "ubuntu:24.04"
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: pulsar-client-${{ matrix.platform }}-gem
path: pkg

# Deliberately minimal: curl/ca-certificates for setup-ruby's own
# download, libyaml-0-2 because ruby-builder's prebuilt Ruby needs it
# for psych (YAML) at runtime - present by default on GitHub's full
# hosted runner images, not on a bare ubuntu: container. 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.
# A bare ubuntu: container's apt sources point at Canonical's public
# mirror network directly, not the hosted runner VM's own accelerated
# mirror - archive.ubuntu.com connection timeouts here are a known,
# reproducible flake (seen twice in a row on this exact step), so
# retry apt-get update with backoff instead of failing on the first
# transient hiccup.
- name: Install only what's needed to fetch and run Ruby
run: |
update_ok=false
for attempt in 1 2 3 4 5; do
if apt-get update; then
update_ok=true
break
fi
echo "apt-get update failed (attempt $attempt/5) - retrying after backoff" >&2
sleep $((attempt * 10))
done
$update_ok || { echo "apt-get update failed after 5 attempts" >&2; exit 1; }
apt-get install -y --no-install-recommends curl ca-certificates libyaml-0-2

- 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.
#
# Also deliberately removing the checked-out repo's own lib/ first:
# rspec-core adds a project-relative lib/ to the load path ahead of
# RubyGems' own resolution, so leaving it in place would silently
# `require` the repo's checked-out .rb files instead of the installed
# gem's - defeating the point of smoke-testing the *installed*
# artifact. Staying in the repo root (not cd-ing elsewhere) so
# spec/pulsar/message_spec.rb's `File.read(.../LICENSE)` fixture read
# still resolves.
- name: Run the non-broker spec suite against the installed gem
run: |
gem install rspec --no-document
rm -rf lib
rspec spec/pulsar --exclude-pattern "spec/pulsar/ext_spec.rb"

# ROLLOUT GATE: currently reachable only via workflow_dispatch, so one
# real publish can be triggered and confirmed by hand (the package
# actually appears in GitHub Packages, and a clean environment can
# install it) - confirmed end-to-end on multiple manual runs, including
# the real install_if-based consumer Gemfile resolving the correct
# architecture via a genuine `bundle install` + `Bundler.require`. Now
# live on every master push for continuous publishing.
publish:
needs: [build, smoke-test]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
platform: [x86_64-linux, aarch64-linux]
steps:
- uses: actions/download-artifact@v4
with:
name: pulsar-client-${{ matrix.platform }}-gem
path: pkg

- name: Push to GitHub Packages
env:
GEM_HOST_API_KEY: "Bearer ${{ secrets.GITHUB_TOKEN }}"
run: gem push --host https://rubygems.pkg.github.com/get-bridge pkg/*.gem

# Completes the loop `publish` alone doesn't: a successful `gem push`
# doesn't by itself prove the package is actually fetchable - this
# installs straight from the real registry (not the pkg/*.gem artifact)
# into a clean container, same shape as `smoke-test`, as the actual
# end-to-end proof a consumer's `bundle install`/`gem install` would work.
verify-publish:
needs: publish
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
strategy:
fail-fast: false
matrix:
include:
- platform: x86_64-linux
runner: ubuntu-22.04
- platform: aarch64-linux
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.runner }}
container:
image: ubuntu:22.04
permissions:
packages: read
steps:
# A bare ubuntu: container's apt sources point at Canonical's public
# mirror network directly, not the hosted runner VM's own accelerated
# mirror - archive.ubuntu.com connection timeouts here are a known,
# reproducible flake (seen twice in a row on this exact step), so
# retry apt-get update with backoff instead of failing on the first
# transient hiccup.
- name: Install only what's needed to fetch and run Ruby
run: |
update_ok=false
for attempt in 1 2 3 4 5; do
if apt-get update; then
update_ok=true
break
fi
echo "apt-get update failed (attempt $attempt/5) - retrying after backoff" >&2
sleep $((attempt * 10))
done
$update_ok || { echo "apt-get update failed after 5 attempts" >&2; exit 1; }
apt-get install -y --no-install-recommends curl ca-certificates libyaml-0-2

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

# Plain `gem install --source X` isn't exclusive to X - it also
# consults the default source (rubygems.org), and "pulsar-client" is
# already a real public gem there (the original upstream project).
# That's exactly the scenario the README warns about and tells
# consumers to avoid with Bundler's scoped `source do...end` block -
# so that's what this verifies too, not a plain `gem install`, which
# would (and the first time this ran here, did) resolve the wrong
# gem entirely.
# One step (not split across install / require), to rule out any
# cross-step state difference - this is a verification job, there's
# no benefit to separate named steps here.
#
# This is the *exact* Gemfile the README documents for consumers -
# identical content on both runners, not templated per matrix leg -
# so a pass here proves the self-selecting install_if logic actually
# resolves the correct architecture's gem via a real `bundle install`,
# not just that a pre-selected hardcoded name works. See the README's
# "why it's written this way" for what each piece is protecting
# against (a shared Gemfile.lock across architectures, a real
# non-Linux fallback, and Bundler.require not silently no-op'ing).
- name: Install via Bundler (scoped to GitHub Packages) and use it
run: |
mkdir -p /tmp/verify-install && cd /tmp/verify-install
cat > Gemfile <<'GEMFILE'
source "https://rubygems.pkg.github.com/get-bridge" do
install_if -> { RUBY_PLATFORM.match?(/x86_64-linux/) } do
gem "pulsar-client-x86_64-linux", ">= 2.6.1.pre.beta", require: "pulsar/client"
end
install_if -> { RUBY_PLATFORM.match?(/aarch64-linux/) } do
gem "pulsar-client-aarch64-linux", ">= 2.6.1.pre.beta", require: "pulsar/client"
end
end
GEMFILE
bundle config set https://rubygems.pkg.github.com/get-bridge "x-access-token:${{ secrets.GITHUB_TOKEN }}"
bundle install
echo "--- Gemfile.lock ---"
cat Gemfile.lock
# Bundler.require (not just `bundle exec`/`bundle install`) is
# what actually honors each gem line's `require:` option - this
# is what proves R3's fix works, not just that the gem installs.
bundle exec ruby -e '
require "bundler/setup"
Bundler.require
installed = Gem::Specification.find_all { |s| s.name.start_with?("pulsar-client-") }
puts "INSTALLED (expect matrix platform ${{ matrix.platform }}): #{installed.map(&:full_name).join(%(, ))}"
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"
'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# build artifacts
lib/pulsar/bindings.bundle
lib/pulsar/*.so
*.gem

spec/pulsar/ext/bindings.bundle
Expand Down
Loading
Loading