Skip to content

Add pure ruby platform gem variant for rspec-trunk-flaky-tests#1060

Merged
trunk-io[bot] merged 5 commits intomainfrom
claude/add-ruby-platform-support-WVW92
Apr 9, 2026
Merged

Add pure ruby platform gem variant for rspec-trunk-flaky-tests#1060
trunk-io[bot] merged 5 commits intomainfrom
claude/add-ruby-platform-support-WVW92

Conversation

@dfrankland
Copy link
Copy Markdown
Member

@dfrankland dfrankland commented Apr 9, 2026

Summary

Adds a pure ruby platform gem variant so users with PLATFORMS ruby in their Gemfile.lock can resolve the dependency without manually adding every CI platform.

The ruby gem is a lightweight fallback — it contains only the Ruby lib files (no native extension, no Rust source, no rb_sys dependency). On supported platforms, bundler automatically prefers the precompiled native gem. If the ruby variant is loaded on a platform without a native gem, it raises a clear error:

Could not load the native extension for rspec_trunk_flaky_tests.

You are likely installing the pure ruby variant of this gem, which does not
include a precompiled native extension. To fix this, add your platform to
your Gemfile.lock:

    bundle lock --add-platform x86_64-linux    # Standard Linux
    ...

Why not compile from source?

The Rust native extension depends on monorepo-local path crates (context, test_report) that aren't available to end users, so source compilation would always fail.

Changes

  • lib/rspec_trunk_flaky_tests.rb — Catch LoadError from missing native extension and raise a helpful message with platform instructions
  • Rakefileruby_gem task builds a gem with no extensions, no native source, no rb_sys dep — just lib/**/*.rb
  • release_ruby_gem.yml — Add ruby to the cross-gem matrix with conditional steps to build and validate the ruby variant
  • Gemfile.lock — Add ruby to PLATFORMS

Test plan

  • Validated locally: ruby gem has platform=ruby, no extensions, no .rs files, no rb_sys dep
  • Validated locally: gem only contains lib/rspec_trunk_flaky_tests.rb and lib/trunk_spec_helper.rb
  • CI: cross-gem matrix builds all 5 variants (4 native + ruby)
  • CI: validation step confirms ruby gem structure
  • Verify gem push publishes all variants

https://claude.ai/code/session_01NmPAFvW2QgLBjsocytoVLD

Users with `PLATFORMS ruby` in their Gemfile.lock cannot install the gem
because only platform-specific precompiled variants are published. This
adds a ruby platform fallback that compiles the native extension from
source on install.

Changes:
- Rakefile: add `ruby_gem` task to build the pure ruby platform gem
- release_ruby_gem.yml: add `ruby-gem` job to build and publish the
  ruby variant alongside the cross-compiled platform gems
- Gemfile.lock: add `ruby` to PLATFORMS

https://claude.ai/code/session_01NmPAFvW2QgLBjsocytoVLD
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Apr 9, 2026

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

Verifies the built gem has platform=ruby, includes the extconf.rb
extension for source compilation, and contains the expected Rust
source files, Cargo.toml, and Ruby lib files.

https://claude.ai/code/session_01NmPAFvW2QgLBjsocytoVLD
@dfrankland dfrankland changed the title Add pure Ruby gem build to release workflow Add pure ruby platform gem variant for rspec-trunk-flaky-tests Apr 9, 2026
claude added 2 commits April 9, 2026 20:14
Move the ruby platform gem build from a separate job into the existing
cross-gem matrix as another platform entry. Uses conditionals to skip
cross-compilation steps for ruby and run gem build + validation instead.
Eliminates duplicated version update steps.

https://claude.ai/code/session_01NmPAFvW2QgLBjsocytoVLD
The ruby platform gem cannot compile from source because the Rust
extension depends on monorepo-local path crates. Instead, ship a
ruby variant that only contains lib/*.rb with no extensions or native
source. If loaded on a platform without a precompiled native gem, it
raises a clear error explaining how to add the correct platform:

    bundle lock --add-platform x86_64-linux

This unblocks users who have `PLATFORMS ruby` in their Gemfile.lock —
bundler can resolve the dependency, and on supported platforms it will
always prefer the precompiled native gem.

https://claude.ai/code/session_01NmPAFvW2QgLBjsocytoVLD
@trunk-staging-io
Copy link
Copy Markdown

trunk-staging-io Bot commented Apr 9, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@dfrankland dfrankland requested a review from TylerJang27 April 9, 2026 20:24
@jjb
Copy link
Copy Markdown
Contributor

jjb commented Apr 9, 2026

If the ruby variant is loaded on a platform without a native gem, it raises a clear error

"To fix this, add your platform to your Gemfile.lock"

Do these two contradict one another - won't the error only be raised if an install is happening on an unsupported platform, and in that case there is nothing the user can do?

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.96%. Comparing base (8d7ab32) to head (5fb5a62).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1060      +/-   ##
==========================================
+ Coverage   81.70%   81.96%   +0.26%     
==========================================
  Files          69       69              
  Lines       14878    14878              
==========================================
+ Hits        12156    12195      +39     
+ Misses       2722     2683      -39     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The previous message told users to add their platform, which doesn't
help if they're on an unsupported platform. Updated to explain that the
ruby gem is a placeholder for Gemfile.lock resolution, distinguish
between the "supported platform but wrong variant selected" case and
the "unsupported platform" case, and point to the issue tracker.

https://claude.ai/code/session_01NmPAFvW2QgLBjsocytoVLD
@dfrankland
Copy link
Copy Markdown
Member Author

@jjb yeah, that was a bad message. I've updated to be more specific, and I'm happy to change it if there's something you think would make it clearer. Thanks for reviewing!

@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Apr 9, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Copy link
Copy Markdown
Collaborator

@TylerJang27 TylerJang27 left a comment

Choose a reason for hiding this comment

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

LGTM. Next step is testing a beta release

@trunk-io trunk-io Bot merged commit 94c6bc0 into main Apr 9, 2026
25 checks passed
@jjb
Copy link
Copy Markdown
Contributor

jjb commented Apr 9, 2026

🎉

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants