Skip to content

[Content Addressable] Update gem build flags to include --content-addressable when building a singe Ruby ABI gem - #9906

Open
OughtPuts wants to merge 1 commit into
ruby:masterfrom
Shopify:ho/gem-build-content-addressable-flag
Open

OughtPuts wants to merge 1 commit into
ruby:masterfrom
Shopify:ho/gem-build-content-addressable-flag

Conversation

@OughtPuts

@OughtPuts OughtPuts commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

#9899

TLDR

Removes the responsibility of building a content addressable gem out of the --ruby-abi X.Y flag and into a new separate flag, --content-addressable.

Description

This PR:

  • Adds a --content-addressable flag option to BuildCommand
  • Maintains the --ruby-abi option in BuildCommand but this command is now only responsible for setting a ruby ABI at build time (instead of in the spec). All help text is rewritten to reflect this.
  • ruby_abi is no longer passed through to Gem::Package.build - the final argument is now a boolean representing whether or not --content-addressable is provided.
  • We still validate the platform, ruby version and rubygems version, but now only when --content-addressable is passed.
  • the ruby_abi_compatible? method in Gem::ContentAddress is now no longer used (we use Gem::ContentAddress.eligible? instead so this has been removed).
  • Other Gem::Package.build callsites were adjusted, e.g. builders.rb and helper.rb.

Tests

Relevant functionality tests:

  • Tests added / updated in clean_spec, content_addressable_spec, test_gem_commands_build_command, test_gem_content_address, test_gem_package.

Other test updates:

  • Changed the spec gate from >= 4.1.0.dev to >= 4.1.0.a to align with the production minimum.
  • Skip content-addressable integration specs on prerelease Rubies because their temporary test gems require the format ~> X.Y.0, which Ruby versions such as 4.1.0.dev do not satisfy, preventing the tests from reaching their intended assertions.
  • Removed Dir[File.join(@tempdir, "platformed_gem-2-*.gem")].first from test_content_addressable_produces_deterministic_content_address as this was hiding a small bug. We should return the relevant Dir from the lamda from the build each time and not take the first matching directory of the set.

Top Hatting:

The below has passed successfully for me locally ✅

  1. From a local gem directory (but specifying the rubygems changes present on this branch) Build a gem using the content addressable flag e.g. gem build --content-addressable. Confirm a content addressable gem is built e.g. ca_test-1.0.0-1234abcd.gem.

  2. Build a gem using the content addressable flag AND the ruby-abi flag because required_ruby_version is not present in the spec e.g. gem build --content-addressable --ruby-abi 4.0. Confirm a content addressable gem is built e.g. ca_test-2.0.0-1234abcd.gem. Confirm that the Ruby ABI version has been correctly set in the spec.

  3. Build a standard gem without either flag e.g. gem build. Confirm that a gem is built e.g. ca_test-3.0.0.gem

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

Could you check the CI failure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants