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): eppo_client shared lib should be under lib/eppo_client #62

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

felipecsl
Copy link
Member

@felipecsl felipecsl commented Oct 30, 2024

Description

In environments for which we don't have prebuilt binaries of the shared eppo client lib, it's built upon running gem install, however the resulting file was being placed in the wrong directory.

We want it under lib/eppo_client/ instead, so that require_relative 'eppo_client' works at https://github.com/Eppo-exp/rust-sdk/blob/main/ruby-sdk/lib/eppo_client/client.rb#L13

Testing

Tested with a docker container.
Dockerfile:

# Use the official Ruby 4.3 image as a base
FROM ruby:3.3

# Set working directory in container
WORKDIR /app

RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    curl \
    clang \
    libclang-dev \
    && rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Copy your Gemfile and Gemfile.lock to install dependencies
COPY Gemfile Gemfile.lock ./

RUN bundle config force_ruby_platform true

# Install gems with Bundler
RUN bundle install

# Copy your test script into the container
COPY test_script.rb /app/test_script.rb


# Make test_script.rb executable (if necessary)
RUN chmod +x /app/test_script.rb

# Set the default command to run the test script
CMD ["bundle", "exec", "ruby", "/app/test_script.rb"]

Gemfile

source 'https://rubygems.org'

gem 'eppo-server-sdk', git: 'https://github.com/Eppo-exp/rust-sdk.git', ref: '776f7a3eba98be668bd7a34bd7070aed9c74d6e4', glob: 'ruby-sdk/*.gemspec'

test_script.rb

require 'eppo_client'

def hello_eppo
  EppoClient.init(EppoClient::Config.new('placeholder-api-key'))

  EppoClient::Client.instance.get_string_assignment('a', 'b', {}, 'fallback')

  puts "hooray"
end

if __FILE__ == $0
  hello_eppo
end
$ docker build -t ruby_gem_test .
$ docker run --rm ruby_gem_test                                                                                                                                                                                                                                                                     /usr/local/bundle/bundler/gems/rust-sdk-776f7a3eba98/ruby-sdk/lib/eppo_client.rb:3: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.
[2024-10-30T22:28:02Z DEBUG eppo] fetching new configuration
[2024-10-30T22:28:02Z WARN  eppo] evaluating a flag before Eppo configuration has been fetched flag_key=a subject_key=b
[2024-10-30T22:28:02Z DEBUG eppo] fetching UFC flags configuration
hooray
image

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.

Great testing section, thank you

@felipecsl felipecsl merged commit 6013f7a into main Oct 31, 2024
25 checks passed
@felipecsl felipecsl deleted the felipecs--ruby-install-location branch October 31, 2024 15:52
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