Files
zeekay ff0a1c53a3 ci: add build+test workflow; fix macOS native-ext build + modernize dev deps
Adds .github/workflows/ci.yml: ubuntu-latest, ruby/setup-ruby@v1 on Ruby 3.3,
installs the linked C++ runtime (libcapnp, the upstream serialization dep — not
a ZAP brand surface), then `rake compile` + `rake spec`.

Build/test fixes required to get green:
- ext/zap/extconf.rb: on macOS, pin the active SDK via `xcrun --show-sdk-path`.
  Homebrew/rbenv Rubies carry no sysroot in RbConfig and mkmf omits -isysroot,
  so clang could not find <stdio.h>/<iostream> and every probe + the real build
  failed. No-op on Linux/CI and when a sysroot is already set.
- zap.gemspec / Rakefile: rspec ~> 2.14 cannot load on modern Ruby/Rake
  (RakeTask hits the removed Rake#last_comment); bump to rspec ~> 3.13. Bump
  rake-compiler ~> 0.9 -> ~> 1.2 to match.

The native extension links upstream libcapnp; capnp:: C++ calls and capnp/kj
includes are that library's real API and are intentionally retained. No
ZAP-facing identifier references capnp.

Local (Ruby 3.3.11, libcapnp 1.4.0): `bundle exec rake compile` + `rake spec`
green — 5 examples, 0 failures.
2026-06-20 21:32:10 -07:00

54 lines
1.3 KiB
Ruby

$LOAD_PATH.unshift File.expand_path('lib', __dir__)
require 'zap/version'
GEMSPEC = Gem::Specification.load('zap.gemspec')
require 'rubygems/package_task'
Gem::PackageTask.new(GEMSPEC) do |pkg|
end
gem 'rake-compiler', '~> 1.2'
require 'rake/extensiontask'
Rake::ExtensionTask.new('zap', GEMSPEC) do |ext|
ext.ext_dir = 'ext/zap'
ext.lib_dir = 'lib/zap'
ext.source_pattern = "*.{cc,h}"
end
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError, NoMethodError => e
desc 'Run RSpec code examples'
task :spec do
abort "rspec is unavailable on this Ruby (#{e.class}: #{e.message}). " \
"Install a compatible rspec and re-run, or run the examples directly."
end
end
task :default => [:compile, :spec]
Rake::Task["clean"].clear
desc "Clean build artifacts"
task :clean do
rm_r "tmp" rescue nil
rm_r "pkg" rescue nil
rm "lib/zap/zap.bundle" rescue nil
end
desc "Tag commit, push to repo, then push to RubyGems"
task :release => [:clean, :compile, :spec, :gem] do
tag = "v#{Zap::VERSION}"
sh "git tag #{tag}"
sh "git push origin #{tag}"
sh "gem push pkg/zap-#{Zap::VERSION}.gem"
end
desc "Open an irb console"
task :console do
$: << File.expand_path("../lib", __FILE__)
require 'irb'
require 'zap'
ARGV.clear
IRB.start
end