Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ruby): Enable ruby-sdk to be cross compiled ahead of time #42

Merged
merged 33 commits into from
Oct 16, 2024

Conversation

felipecsl
Copy link
Member

@felipecsl felipecsl commented Oct 11, 2024

Description

This will allow us to, at gem build time, precompile the ruby-sdk gem to all supported environments, so users don't need to have cargo installed to install the gem, skipping the whole "Building native extensions. This could take a while..." annoyance

Testing

We support ruby versions 3.0 and above

cd ruby-sdk
bundle install
bundle exec rb-sys-dock -p <platform> --ruby-versions 3.3,3.2,3.1,3.0 --build

Also added Github action to cross compile as part of CI. We can add an upload step after, that part is still TBD

References

@felipecsl felipecsl changed the title fix(ruby): Enable rust-sdk to be cross compiled ahead of time fix(ruby): Enable ruby-sdk to be cross compiled ahead of time Oct 11, 2024
@felipecsl felipecsl marked this pull request as ready for review October 11, 2024 23:01
@felipecsl
Copy link
Member Author

I got almost all of the main architectures working, except for arm64-darwin (that one has proven more challenging), however I doubt that anyone out there is running the ruby eppo sdk in prod on apple silicon :) I think we could get away with leaving that one aside for now and ship this as is. we can upload all individual binaries to rubygems and that should remove the need from users to have cargo installed at gem install time.

Copy link
Collaborator

@rasendubi rasendubi left a comment

Choose a reason for hiding this comment

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

Awesome work!

How pre-built gems flow into ruby publish workflow?

.github/workflows/ci.yml Outdated Show resolved Hide resolved
ruby-sdk/ext/eppo_client/extconf.rb Outdated Show resolved Hide resolved
ruby-sdk/ext/eppo_client/Cargo.toml Outdated Show resolved Hide resolved
.github/workflows/ruby-cross-compile.yml Outdated Show resolved Hide resolved
.github/workflows/ruby-cross-compile.yml Outdated Show resolved Hide resolved
Copy link
Member

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

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

Thanks a ton for picking this up; appreciate your attention to all the major details and pragmatic approach to not get sucked into the arm64 architecture.

Could you give a quick push to seeing if the linked example works and if not push ahead with the platform for now.

🚀 🚀 🚀

.github/workflows/ruby-cross-compile.yml Outdated Show resolved Hide resolved
@rasendubi
Copy link
Collaborator

rasendubi commented Oct 16, 2024

oh, another caveat is that it tries to build the gems with eppo_core from crates.io. So it fails when eppo_core in worktree has bumped version (or any changes)

@rasendubi
Copy link
Collaborator

So... Let's approach it in two steps:

  1. I've opened chore(core): add "vendored" feature flag to eppo_core #45 for changes in eppo_core. Let's merge them and release new eppo_core, so we can test this PR against released version.
  2. After the core is released, we can continue working on workflow changes for Ruby (this PR). Unfortunately, we shall push all native gem compilation so it only happens during Ruby's release job (because in PR we want to test against local eppo_core, not the released version). I expect this to be fine because there's usually very little changes that would affect vendoring/cross-compilation and we have Python CI that builds very similarly.

@felipecsl
Copy link
Member Author

Awesome work!

How pre-built gems flow into ruby publish workflow?

I'm gonna look into that next. There's a way to set up a workflow that publishes the gems for each platform after they are built. I'll look into that in a follow up PR if that's OK for you guys

Copy link
Collaborator

@rasendubi rasendubi left a comment

Choose a reason for hiding this comment

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

Looks good and I'm glad it's passing for macOS as well now. Need to disable cross_gems for PRs/main before merging though

.github/workflows/ruby.yml Outdated Show resolved Hide resolved
Copy link
Member

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

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

Approving but please extract cross_gems into own action that is triggered on Release before merging.

@felipecsl
Copy link
Member Author

cool, taking care of that now

@felipecsl felipecsl merged commit 5d98d29 into main Oct 16, 2024
23 checks passed
@felipecsl felipecsl deleted the felipecsl--ruby-cross-compile branch October 16, 2024 22:37
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.

3 participants