Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Ruby updates: 0.5.0 packaging + package arm64 + change fallback package strategy #39

Merged
Merged
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
8 changes: 4 additions & 4 deletions Cargo.lock

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

38 changes: 26 additions & 12 deletions ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ RSpec::Core::RakeTask.new(:spec)

LIB_GITHUB_RELEASES = {
# This should match the version in the version.rb file
"0.3.0" => [
"0.5.0" => [
{
file: "libddprof-aarch64-alpine-linux-musl.tar.gz",
sha256: "121857f371fed5252654e6eebcb214c6d3a5b089c7e3340e41ab2089df0b9a25",
ruby_platform: "aarch64-linux-musl"
},
{
file: "libddprof-aarch64-unknown-linux-gnu.tar.gz",
sha256: "ab4cd1fc9bc3975775bd2ff2122ac0b475533d504965b931d377cca122f7b0b3",
ruby_platform: "aarch64-linux"
},
{
file: "libddprof-x86_64-alpine-linux-musl.tar.gz",
sha256: "854609c1acc86f6653f539b3fe8780ad1e60d8738f85efdb3b1aa0054e75a217",
sha256: "1675e6402973548ca22da0832babe33d0d4ec739ff9979a600677722fd46ff2f",
ruby_platform: "x86_64-linux-musl"
},
{
file: "libddprof-x86_64-unknown-linux-gnu.tar.gz",
sha256: "d9c64567e7ef5f957581dd81892b144b81e1f52fdf5671430c7af0b039b48929",
sha256: "2db92e2ad87005a043e415fd62079af1f1df3642be9bed3ade840c5533a61063",
ruby_platform: "x86_64-linux"
}
]
Expand Down Expand Up @@ -81,12 +91,18 @@ task package: [
gemspec = eval(File.read("libddprof.gemspec"), nil, "libddprof.gemspec") # standard:disable Security/Eval
FileUtils.mkdir_p("pkg")

# Fallback package without binaries
Helpers.package_for(gemspec, ruby_platform: nil, files: [])
# Fallback package with all binaries
# This package will get used by (1) platforms that have no matching `ruby_platform` or (2) that have set
# "BUNDLE_FORCE_RUBY_PLATFORM" (or its equivalent via code) to avoid precompiled gems.
# In a previous version of libddprof, this package had no binaries, but that could mean that we broke customers in case (2).
# For customers in case (1), this package is a no-op, and dd-trace-rb will correctly detect and warn that
# there are no valid binaries for the platform.
Helpers.package_for(gemspec, ruby_platform: nil, files: Helpers.files_for("x86_64-linux", "x86_64-linux-musl", "aarch64-linux", "aarch64-linux-musl"))

# We include both glibc and musl variants in the same binary gem to avoid the issues
# documented in https://github.com/rubygems/rubygems/issues/3174
Helpers.package_for(gemspec, ruby_platform: "x86_64-linux", files: Helpers.files_for("x86_64-linux", "x86_64-linux-musl"))
Helpers.package_for(gemspec, ruby_platform: "aarch64-linux", files: Helpers.files_for("aarch64-linux", "aarch64-linux-musl"))

# Experimental macOS package, not published to rubygems.org at the moment
if ENV["LIBDDPROF_PACKAGE_MACOS"] == "true"
Expand All @@ -103,6 +119,7 @@ task push_to_rubygems: [

system("gem push pkg/libddprof-#{Libddprof::VERSION}.gem")
system("gem push pkg/libddprof-#{Libddprof::VERSION}-x86_64-linux.gem")
system("gem push pkg/libddprof-#{Libddprof::VERSION}-aarch64-linux.gem")

system("gem signout") # leave no credentials behind
end
Expand Down Expand Up @@ -142,16 +159,13 @@ module Helpers
version: Libddprof::LIB_VERSION,
excluded_files: [
"ddprof_ffi.pc", # we use the ddprof_ffi_with_rpath.pc variant
"libddprof_ffi.a", "ddprof_ffi-static.pc" # We don't use the static library
"libddprof_ffi.a", "ddprof_ffi-static.pc", # We don't use the static library
"libddprof_ffi.so.debug", # We don't include debug info
"DDProfConfig.cmake" # We don't compile using cmake
]
)
files = []

excluded_files_from_packaging = [
*excluded_files,
"DDProfConfig.cmake" # We don't compile using cmake
]

each_github_release_variant(version: version) do |ruby_platform:, target_directory:, target_file:, **_|
next unless included_platforms.include?(ruby_platform)

Expand All @@ -161,7 +175,7 @@ module Helpers
Dir.glob("#{target_directory}/**/*")
.select { |path| File.file?(path) }
.reject { |path| path == downloaded_release_tarball }
.reject { |path| excluded_files_from_packaging.include?(File.basename(path)) }
.reject { |path| excluded_files.include?(File.basename(path)) }
end

files
Expand Down
9 changes: 2 additions & 7 deletions ruby/lib/libddprof.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
require_relative "libddprof/version"

module Libddprof
# Does this libddprof release include any binaries?
def self.binaries?
available_binaries.any?
end

# This should only be used for debugging/logging
def self.available_binaries
File.directory?(vendor_directory) ? (Dir.entries(vendor_directory) - [".", ".."]) : []
end

def self.pkgconfig_folder
def self.pkgconfig_folder(pkgconfig_file_name = "ddprof_ffi_with_rpath.pc")
current_platform = Gem::Platform.local.to_s

return unless available_binaries.include?(current_platform)

pkgconfig_file = Dir.glob("#{vendor_directory}/#{current_platform}/**/ddprof_ffi.pc").first
pkgconfig_file = Dir.glob("#{vendor_directory}/#{current_platform}/**/#{pkgconfig_file_name}").first

return unless pkgconfig_file

Expand Down
6 changes: 3 additions & 3 deletions ruby/lib/libddprof/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

module Libddprof
# Current libddprof version
LIB_VERSION = "0.3.0"
LIB_VERSION = "0.5.0"

GEM_MAJOR_VERSION = "2"
GEM_MAJOR_VERSION = "1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're going from 2.0.beta1 down to 1.0 in this commit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but! :)

The actual version for release is (from line 16):

VERSION = "#{LIB_VERSION}.#{GEM_MAJOR_VERSION}.#{GEM_MINOR_VERSION}#{GEM_PRERELEASE_VERSION}"

Aka we're going from 0.3.0.2.0.beta1 to 0.5.0.1.0 so it's not as insane as it appears :)

GEM_MINOR_VERSION = "0"
GEM_PRERELEASE_VERSION = ".beta1" # remember to include dot prefix, if needed!
GEM_PRERELEASE_VERSION = "" # remember to include dot prefix, if needed!
private_constant :GEM_MAJOR_VERSION, :GEM_MINOR_VERSION, :GEM_PRERELEASE_VERSION

# The gem version scheme is lib_version.gem_major.gem_minor[.prerelease].
Expand Down
1 change: 1 addition & 0 deletions ruby/libddprof.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
.reject do |f|
[".rspec", ".standard.yml", "Rakefile", "docker-compose.yml", "gems.rb", "README.md"].include?(f)
end
.reject { |f| f.end_with?(".tar.gz") }
end
spec.require_paths = ["lib"]
end
14 changes: 1 addition & 13 deletions ruby/spec/libddprof_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
end

context "when no binaries are available in the vendor directory" do
describe ".binaries?" do
it { expect(Libddprof.binaries?).to be false }
end

describe ".available_binaries" do
it { expect(Libddprof.available_binaries).to be_empty }
end
Expand All @@ -47,10 +43,6 @@
context "when vendor directory does not exist" do
let(:temporary_directory) { "does/not/exist" }

describe ".binaries?" do
it { expect(Libddprof.binaries?).to be false }
end

describe ".available_binaries" do
it { expect(Libddprof.available_binaries).to be_empty }
end
Expand All @@ -66,10 +58,6 @@
Dir.mkdir("#{temporary_directory}/mipsel-linux")
end

describe ".binaries?" do
it { expect(Libddprof.binaries?).to be true }
end

describe ".available_binaries" do
it { expect(Libddprof.available_binaries).to contain_exactly("386-freedos", "mipsel-linux") }
end
Expand All @@ -79,7 +67,7 @@

before do
FileUtils.mkdir_p(pkgconfig_folder)
File.open("#{pkgconfig_folder}/ddprof_ffi.pc", "w") {}
File.open("#{pkgconfig_folder}/ddprof_ffi_with_rpath.pc", "w") {}
end

describe ".pkgconfig_folder" do
Expand Down