From 69dc6f714e420e80ec92ffc9c0997f1b6973a3cf Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Mon, 10 Jun 2024 12:08:47 -0700 Subject: [PATCH] Update Ruby test application and agent Dockerfile --- .github/workflows/ruby.yml | 2 +- src/ruby/Dockerfile | 4 +++- src/ruby/Gemfile | 2 +- src/ruby/Gemfile.lock | 16 ---------------- tests/ruby/config.ru | 4 +++- tests/ruby/start.sh | 2 +- 6 files changed, 9 insertions(+), 21 deletions(-) delete mode 100644 src/ruby/Gemfile.lock diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index ae59509..5ce5451 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-latest needs: check-modified-files # run only if files were modified, the workflow was manually invoked, or doing a release - if: needs.check-modified-files.outputs.files-changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' && endsWith(github.ref, '_ruby') + if: needs.check-modified-files.outputs.files-changed == 'true' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && endsWith(github.ref, '_ruby')) steps: - name: Checkout code diff --git a/src/ruby/Dockerfile b/src/ruby/Dockerfile index 73e624b..4100886 100644 --- a/src/ruby/Dockerfile +++ b/src/ruby/Dockerfile @@ -6,6 +6,8 @@ FROM ruby:latest AS build WORKDIR /operator-build +ARG AGENT_VERSION + # Install gems from Gemfile into the `workspace` directory ADD Gemfile . RUN BUNDLE_PATH=workspace bundle install @@ -21,7 +23,7 @@ WORKDIR /operator-build # Copy the result into a new directory called `/instrumentation`. RUN sh -c "find 'workspace/ruby/' -type d -name newrelic_rpm\\* -exec cp -r '{}' /instrumentation \\;" -# Adjust permissions of `instrumentation` director to readable by everyone +# Adjust permissions of `instrumentation` directory to readable by everyone RUN chmod -R go+r /instrumentation # Clean up build artifacts diff --git a/src/ruby/Gemfile b/src/ruby/Gemfile index c62c579..536e899 100644 --- a/src/ruby/Gemfile +++ b/src/ruby/Gemfile @@ -2,4 +2,4 @@ source 'https://rubygems.org' -gem 'newrelic_rpm' \ No newline at end of file +gem *['newrelic_rpm', ENV.fetch('AGENT_VERSION', nil)].compact diff --git a/src/ruby/Gemfile.lock b/src/ruby/Gemfile.lock deleted file mode 100644 index e776432..0000000 --- a/src/ruby/Gemfile.lock +++ /dev/null @@ -1,16 +0,0 @@ -# This file only exists to satisfy FOSSA security scan. It is not used. - -GEM - remote: https://rubygems.org/ - specs: - newrelic_rpm (9.9.0) - -PLATFORMS - ruby - x86_64-darwin-23 - -DEPENDENCIES - newrelic_rpm - -BUNDLED WITH - 2.5.6 diff --git a/tests/ruby/config.ru b/tests/ruby/config.ru index 6980847..7f4d29a 100644 --- a/tests/ruby/config.ru +++ b/tests/ruby/config.ru @@ -1,3 +1,5 @@ -require './app.rb' +require 'bundler' +Bunder.require +require './app.rb' run Sinatra::Application \ No newline at end of file diff --git a/tests/ruby/start.sh b/tests/ruby/start.sh index 7ba4b5d..e3ac76e 100644 --- a/tests/ruby/start.sh +++ b/tests/ruby/start.sh @@ -1,7 +1,7 @@ #!/bin/sh # Start ruby app and provide time to boot Puma -ruby app.rb & sleep 5 +bundle exec rackup & sleep 5 # Hit endponint while true; do