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

Update Ruby test application and agent Dockerfile #33

Merged
merged 7 commits into from
Jun 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/ruby/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

source 'https://rubygems.org'

gem 'newrelic_rpm'
gem *['newrelic_rpm', ENV.fetch('AGENT_VERSION', nil)].compact
16 changes: 0 additions & 16 deletions src/ruby/Gemfile.lock

This file was deleted.

10 changes: 5 additions & 5 deletions tests/ruby/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ RUN bundle install

COPY . .

EXPOSE 4567
EXPOSE 9292

#Ensure executable permissions
RUN chmod +x start.sh

CMD ["./start.sh"]
CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "--port", "9292"]
# For local testing, run:
# curl http://0.0.0.0:9292
1 change: 0 additions & 1 deletion tests/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
source 'https://rubygems.org'

gem 'sinatra'
gem 'newrelic_rpm'

gem "rackup", "~> 2.1"
37 changes: 0 additions & 37 deletions tests/ruby/Gemfile.lock

This file was deleted.

8 changes: 2 additions & 6 deletions tests/ruby/app.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# frozen_string_literal: true

require 'sinatra'
require 'newrelic_rpm'

set :bind, '0.0.0.0'
set :port, 4567

get '/' do
return 'no new relic txn' unless NewRelic::Agent::Tracer.current_transaction
status = NewRelic::Agent::Tracer.current_transaction ? 'active' : 'inactive'

'hello, world!'
"Hello, World! New Relic is #{status}"
end
6 changes: 3 additions & 3 deletions tests/ruby/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
image: e2e/test-app-ruby:e2e
imagePullPolicy: Never
ports:
- containerPort: 4567
- containerPort: 9292
env:
- name: NEW_RELIC_APP_NAME
value: k8s-e2e-test-app-ruby
Expand All @@ -40,7 +40,7 @@ metadata:
spec:
type: NodePort
ports:
- port: 4567
targetPort: 4567
- port: 9292
targetPort: 9292
selector:
app: test-app-ruby
4 changes: 3 additions & 1 deletion tests/ruby/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require './app.rb'
require 'bundler'
Bundler.require

require './app.rb'
run Sinatra::Application
10 changes: 0 additions & 10 deletions tests/ruby/start.sh

This file was deleted.

Loading