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

Add script for testing rubygem published package in alpine and debian. #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions package-testing/ruby-sdk-relay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Ruby SDK Testing

This directory contains scripts for testing the Ruby SDK in various environments.

### Test Ruby Gems Installation

Verifies that the Ruby SDK can be installed from RubyGems in a variety of environments.

The `test-rubygems-install.sh` script builds Docker images for Alpine and Debian and runs the test script inside each container.

You should see output like the following if the tests pass:

```
Successfully installed eppo-server-sdk-3.3.0-aarch64-linux
1 gem installed
Installed version: 3.3.0
✅ Installation successful in debian environment
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ruby:3.3-alpine

# Install bash
RUN apk add --no-cache bash

# Create a test user
RUN adduser -D testuser

# Copy script and set permissions while still root
COPY test-gem.sh /home/testuser/
RUN chmod +x /home/testuser/test-gem.sh && \
chown testuser:testuser /home/testuser/test-gem.sh

# Switch to test user
USER testuser
WORKDIR /home/testuser

CMD ["bash", "/home/testuser/test-gem.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ruby:3.3-slim-bullseye

# Create a test user
RUN useradd -m testuser

# Copy script and set permissions while still root
COPY test-gem.sh /home/testuser/
RUN chmod +x /home/testuser/test-gem.sh && \
chown testuser:testuser /home/testuser/test-gem.sh

# Switch to test user
USER testuser
WORKDIR /home/testuser

CMD ["bash", "/home/testuser/test-gem.sh"]
5 changes: 5 additions & 0 deletions package-testing/ruby-sdk-relay/published-versions/test-gem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Install the gem and verify it works
gem install eppo-server-sdk
ruby -r eppo_client -e 'puts "Installed version: #{EppoClient::VERSION}"'
57 changes: 57 additions & 0 deletions package-testing/ruby-sdk-relay/test-rubygems-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

# Default environment if none specified
ENV=${1:-"all"}

# Constants
DOCKERFILE_FORMAT="Dockerfile.rubygems"
DOCKER_TAG_PREFIX="rubygems-test"
TEST_DIRECTORY="published-versions"

# Ensure we're in the correct directory
cd "$(dirname "$0")"

# Ensure test script exists
if [ ! -f "$TEST_DIRECTORY/test-gem.sh" ]; then
echo "Error: $TEST_DIRECTORY/test-gem.sh not found"
exit 1
fi

# Function to test in specific environment
test_environment() {
local env=$1
echo "Testing installation in $env environment..."

# Build from the published-versions directory where both Dockerfile and test-gem.sh are located
docker build -t "$DOCKER_TAG_PREFIX-$env" -f "$TEST_DIRECTORY/$DOCKERFILE_FORMAT.$env" "$TEST_DIRECTORY"
docker run --rm "$DOCKER_TAG_PREFIX-$env"

local result=$?
if [ $result -eq 0 ]; then
echo "✅ Installation successful in $env environment"
else
echo "❌ Installation failed in $env environment"
fi
return $result
}

# Run tests based on environment parameter
case $ENV in
"alpine")
test_environment "alpine"
;;
"debian")
test_environment "debian"
;;
"all")
failed=0
test_environment "alpine" || failed=1
test_environment "debian" || failed=1
exit $failed
;;
*)
echo "Unsupported environment: $ENV"
echo "Supported environments: alpine, debian, all"
exit 1
;;
esac