From 5fdc5674e3ed6085f33aab1302600e39c197f005 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 09:35:44 -0700 Subject: [PATCH 1/8] Add e2e test Dockerized Ruby app, k8s setup, CI testing --- .github/workflows/ruby.yml | 154 ++++++++++++++++++ tests/ruby/Dockerfile | 18 ++ tests/ruby/Gemfile | 8 + tests/ruby/Gemfile.lock | 37 +++++ tests/ruby/app.rb | 13 ++ tests/ruby/chart/.helmignore | 23 +++ tests/ruby/chart/Chart.yaml | 6 + tests/ruby/chart/templates/deployment.yaml | 46 ++++++ .../ruby/chart/templates/instrumentation.yaml | 11 ++ tests/ruby/chart/values.yaml | 1 + tests/ruby/config.ru | 3 + tests/ruby/start.sh | 10 ++ tests/ruby/test-specs.yml | 15 ++ 13 files changed, 345 insertions(+) create mode 100644 .github/workflows/ruby.yml create mode 100644 tests/ruby/Dockerfile create mode 100644 tests/ruby/Gemfile create mode 100644 tests/ruby/Gemfile.lock create mode 100644 tests/ruby/app.rb create mode 100644 tests/ruby/chart/.helmignore create mode 100644 tests/ruby/chart/Chart.yaml create mode 100644 tests/ruby/chart/templates/deployment.yaml create mode 100644 tests/ruby/chart/templates/instrumentation.yaml create mode 100644 tests/ruby/chart/values.yaml create mode 100644 tests/ruby/config.ru create mode 100644 tests/ruby/start.sh create mode 100644 tests/ruby/test-specs.yml diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..e16731e --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,154 @@ +# Copyright 2010 New Relic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--- +name: Ruby Agent CI + +on: + pull_request: + paths: + - 'src/ruby/**' + - '.github/workflows/ruby.yml' + push: + paths: + - 'ruby/**' + - '.github/workflows/ruby.yml' + branches: + - main + # Do not run when a tag is created. + tags-ignore: + - "**" + release: + types: + - published + workflow_dispatch: + +env: + INITCONTAINER_LANGUAGE: ruby + K8S_OPERATOR_IMAGE_TAG: edge + +jobs: + check-modified-files: + name: Check whether any Ruby-related files were modified, skip the test job if not + uses: ./.github/workflows/check-modified-files.yml + secrets: inherit + permissions: + contents: read + with: + agent-language: ruby + + test: + runs-on: ubuntu-latest + needs: check-modified-files + # run only if Ruby-related files were modified + if: needs.check-modified-files.outputs.files-changed == 'true' + + steps: + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 + with: + persist-credentials: false + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # 3.3.0 + + - name: Start minikube + uses: medyagh/setup-minikube@317d92317e473a10540357f1f4b2878b80ee7b95 # 0.0.16 + + - name: Deploy cert-manager to minikube + run: | + helm repo add jetstack https://charts.jetstack.io --force-update + helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.14.5 --set installCRDs=true + sleep 5 + kubectl wait --for=condition=Ready -n cert-manager --all pods + + - name: Deploy New Relic k8s-agents-operator to minikube + run: | + helm repo add k8s-agents-operator https://newrelic.github.io/k8s-agents-operator + helm upgrade --install k8s-agents-operator k8s-agents-operator/k8s-agents-operator \ + --namespace=default \ + --set=licenseKey=${{ secrets.NEW_RELIC_LICENSE_KEY }} \ + --set=controllerManager.manager.image.tag=${{ env.K8S_OPERATOR_IMAGE_TAG }} + sleep 5 + kubectl wait --for=condition=Ready -n default --all pods + + - name: Build init container + run: | + minikube image build -t e2e/newrelic-${{ env.INITCONTAINER_LANGUAGE }}-init:e2e src/${{ env.INITCONTAINER_LANGUAGE }}/ + + - name: Build test app container + run: | + minikube image build -t e2e/test-app-${{ env.INITCONTAINER_LANGUAGE }}:e2e tests/${{ env.INITCONTAINER_LANGUAGE }}/ + + - name: Run e2e-test + uses: newrelic/newrelic-integration-e2e-action@a97ced80a4841c8c6261d1f9dca6706b1d89acb1 # 1.11.0 + with: + retry_seconds: 60 + retry_attempts: 5 + agent_enabled: false + spec_path: tests/${{ env.INITCONTAINER_LANGUAGE }}/test-specs.yml + account_id: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} + api_key: ${{ secrets.NEW_RELIC_API_KEY }} + license_key: ${{ secrets.NEW_RELIC_LICENSE_KEY }} + + # publish: + # if: github.event_name == 'release' && endsWith(github.ref, '_python') + # runs-on: ubuntu-latest + # needs: + # - test + + # steps: + # - name: Checkout code + # uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 + # with: + # persist-credentials: false + # fetch-depth: 0 + + # - name: Extract Agent Version + # id: version + # run: | + # agent_version=${{ github.ref_name }} # Use tag name + # agent_version=${agent_version##v} # Remove v prefix + # agent_version=${agent_version%%_${{ env.INITCONTAINER_LANGUAGE }}} # Remove language suffix + # echo "agent_version=${agent_version}" | tee -a "$GITHUB_OUTPUT" + + # - name: Set up Docker Buildx + # id: buildx + # uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # 3.3.0 + + # - name: Generate Docker metadata (tags and labels) + # id: meta + # uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 + # with: + # images: newrelic/newrelic-${{ env.INITCONTAINER_LANGUAGE }}-init + # tags: | + # type=raw,value=${{ steps.version.outputs.agent_version }} + # type=raw,value=latest + + # - name: Login to Docker Hub Container Registry + # uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # 3.1.0 + # with: + # username: ${{ github.repository_owner }} + # password: ${{ secrets.DOCKER_TOKEN }} + + # - name: Build and publish init container image + # uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # 5.3.0 + # with: + # push: true + # context: src/${{ env.INITCONTAINER_LANGUAGE }}/ + # platforms: linux/amd64,linux/arm64,linux/arm + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + # build-args: | + # AGENT_VERSION=${{ steps.version.outputs.agent_version }} diff --git a/tests/ruby/Dockerfile b/tests/ruby/Dockerfile new file mode 100644 index 0000000..484326d --- /dev/null +++ b/tests/ruby/Dockerfile @@ -0,0 +1,18 @@ +FROM ruby:latest + +WORKDIR /app + +RUN apt-get update -qq && apt-get install -y nodejs postgresql-client + +COPY Gemfile ./ + +RUN bundle install + +COPY . . + +EXPOSE 4567 + +#Ensure executable permissions +RUN chmod +x start.sh + +CMD ["./start.sh"] diff --git a/tests/ruby/Gemfile b/tests/ruby/Gemfile new file mode 100644 index 0000000..bc5caff --- /dev/null +++ b/tests/ruby/Gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gem 'sinatra' +gem 'newrelic_rpm' + +gem "rackup", "~> 2.1" diff --git a/tests/ruby/Gemfile.lock b/tests/ruby/Gemfile.lock new file mode 100644 index 0000000..8b13e7c --- /dev/null +++ b/tests/ruby/Gemfile.lock @@ -0,0 +1,37 @@ +GEM + remote: https://rubygems.org/ + specs: + base64 (0.2.0) + mustermann (3.0.0) + ruby2_keywords (~> 0.0.1) + newrelic_rpm (9.10.0) + rack (3.0.11) + rack-protection (4.0.0) + base64 (>= 0.1.0) + rack (>= 3.0.0, < 4) + rack-session (2.0.0) + rack (>= 3.0.0) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + ruby2_keywords (0.0.5) + sinatra (4.0.0) + mustermann (~> 3.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.0.0) + rack-session (>= 2.0.0, < 3) + tilt (~> 2.0) + tilt (2.3.0) + webrick (1.8.1) + +PLATFORMS + ruby + x86_64-darwin-23 + +DEPENDENCIES + newrelic_rpm + rackup (~> 2.1) + sinatra + +BUNDLED WITH + 2.5.6 diff --git a/tests/ruby/app.rb b/tests/ruby/app.rb new file mode 100644 index 0000000..464c628 --- /dev/null +++ b/tests/ruby/app.rb @@ -0,0 +1,13 @@ +# 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 + + 'hello, world!' +end diff --git a/tests/ruby/chart/.helmignore b/tests/ruby/chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/tests/ruby/chart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tests/ruby/chart/Chart.yaml b/tests/ruby/chart/Chart.yaml new file mode 100644 index 0000000..1557c91 --- /dev/null +++ b/tests/ruby/chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: test-app-ruby +description: A Helm chart for Kubernetes +type: application +version: 1.0.0 +appVersion: "1.0.0" diff --git a/tests/ruby/chart/templates/deployment.yaml b/tests/ruby/chart/templates/deployment.yaml new file mode 100644 index 0000000..43e4624 --- /dev/null +++ b/tests/ruby/chart/templates/deployment.yaml @@ -0,0 +1,46 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-app-ruby +spec: + selector: + matchLabels: + app: test-app-ruby + replicas: 1 + template: + metadata: + labels: + app: test-app-ruby + annotations: + instrumentation.newrelic.com/inject-ruby: "true" + spec: + containers: + - name: test-app-ruby + image: e2e/test-app-ruby:e2e + imagePullPolicy: Never + ports: + - containerPort: 4567 + env: + - name: NEW_RELIC_APP_NAME + value: k8s-e2e-test-app-ruby + # used by the e2e Github action + - name: NEW_RELIC_LABELS + value: 'testKey:{{ .Values.scenarioTag | default "NOTSET" }}' + - name: NEW_RELIC_LOG_LEVEL + value: info + # set the host to staging if using a staging license key + - name: NEW_RELIC_HOST + value: staging-collector.newrelic.com +--- +apiVersion: v1 +kind: Service +metadata: + name: test-app-ruby-service +spec: + type: NodePort + ports: + - port: 4567 + targetPort: 4567 + selector: + app: test-app-ruby diff --git a/tests/ruby/chart/templates/instrumentation.yaml b/tests/ruby/chart/templates/instrumentation.yaml new file mode 100644 index 0000000..3e5bd01 --- /dev/null +++ b/tests/ruby/chart/templates/instrumentation.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: newrelic.com/v1alpha1 +kind: Instrumentation +metadata: + labels: + app.kubernetes.io/name: instrumentation + app.kubernetes.io/created-by: newrelic-agent-operator + name: newrelic-instrumentation +spec: + ruby: + image: e2e/newrelic-ruby-init:e2e diff --git a/tests/ruby/chart/values.yaml b/tests/ruby/chart/values.yaml new file mode 100644 index 0000000..44eb261 --- /dev/null +++ b/tests/ruby/chart/values.yaml @@ -0,0 +1 @@ +scenarioTag: "" \ No newline at end of file diff --git a/tests/ruby/config.ru b/tests/ruby/config.ru new file mode 100644 index 0000000..6980847 --- /dev/null +++ b/tests/ruby/config.ru @@ -0,0 +1,3 @@ +require './app.rb' + +run Sinatra::Application \ No newline at end of file diff --git a/tests/ruby/start.sh b/tests/ruby/start.sh new file mode 100644 index 0000000..1f64dc5 --- /dev/null +++ b/tests/ruby/start.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Start ruby app and provide time to boot Puma +ruby app.rb & sleep 5 + +# Make requests +while true; do + curl http://0.0.0.0:4567 + sleep 3 +done diff --git a/tests/ruby/test-specs.yml b/tests/ruby/test-specs.yml new file mode 100644 index 0000000..d373e4a --- /dev/null +++ b/tests/ruby/test-specs.yml @@ -0,0 +1,15 @@ +description: End-to-end tests for ruby initcontainer +custom_test_key: tags.testKey +scenarios: + - description: This scenario will verify that a transaction is reported by the test app after a curl request + before: + - helm install test-ruby ./chart/ --set=scenarioTag="${SCENARIO_TAG}" -n default + - sleep 5 + - kubectl wait --for=condition=Ready -n default --all pods + - curl --fail-with-body $(minikube service test-app-ruby-service --url -n default)/ + tests: + nrqls: + - query: SELECT latest(duration) AS duration FROM Transaction WHERE appName = 'k8s-e2e-test-app-ruby' + expected_results: + - key: "duration" + lowerBoundedValue: 0.0 From b6209370f29e08179f1be90a979efff06f453c5a Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 09:46:11 -0700 Subject: [PATCH 2/8] Let CI handle making requests --- tests/ruby/start.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ruby/start.sh b/tests/ruby/start.sh index 1f64dc5..95bb847 100644 --- a/tests/ruby/start.sh +++ b/tests/ruby/start.sh @@ -3,8 +3,8 @@ # Start ruby app and provide time to boot Puma ruby app.rb & sleep 5 -# Make requests -while true; do - curl http://0.0.0.0:4567 - sleep 3 -done +# Make requests - for local testing +# while true; do +# curl http://0.0.0.0:4567 +# sleep 3 +# done From 5bed82804939f9c6bd2514bad9f2b7d65ba39056 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 11:42:57 -0700 Subject: [PATCH 3/8] Update script --- .github/workflows/ruby.yml | 9 +++++++-- tests/ruby/start.sh | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e16731e..41c44af 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -33,6 +33,10 @@ on: - published workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: INITCONTAINER_LANGUAGE: ruby K8S_OPERATOR_IMAGE_TAG: edge @@ -48,10 +52,11 @@ jobs: agent-language: ruby test: + name: Run Ruby init container tests runs-on: ubuntu-latest needs: check-modified-files - # run only if Ruby-related files were modified - if: needs.check-modified-files.outputs.files-changed == 'true' + # run only if files were modified or the workflow was manually invoked + if: needs.check-modified-files.outputs.files-changed == 'true' || github.event_name == 'workflow_dispatch' steps: - name: Checkout code diff --git a/tests/ruby/start.sh b/tests/ruby/start.sh index 95bb847..1f64dc5 100644 --- a/tests/ruby/start.sh +++ b/tests/ruby/start.sh @@ -3,8 +3,8 @@ # Start ruby app and provide time to boot Puma ruby app.rb & sleep 5 -# Make requests - for local testing -# while true; do -# curl http://0.0.0.0:4567 -# sleep 3 -# done +# Make requests +while true; do + curl http://0.0.0.0:4567 + sleep 3 +done From 737f265a0788cb55fda784fc3c3ad2673ee99589 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 11:53:15 -0700 Subject: [PATCH 4/8] Add logs --- tests/ruby/chart/templates/deployment.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ruby/chart/templates/deployment.yaml b/tests/ruby/chart/templates/deployment.yaml index 43e4624..3a7b84e 100644 --- a/tests/ruby/chart/templates/deployment.yaml +++ b/tests/ruby/chart/templates/deployment.yaml @@ -28,10 +28,13 @@ spec: - name: NEW_RELIC_LABELS value: 'testKey:{{ .Values.scenarioTag | default "NOTSET" }}' - name: NEW_RELIC_LOG_LEVEL - value: info + value: debug # set the host to staging if using a staging license key - name: NEW_RELIC_HOST value: staging-collector.newrelic.com + - name: NEW_RELIC_LOG_FILE_PATH + value: STDOUT + --- apiVersion: v1 kind: Service From 23a303d7bdd9a51b0ca8ace57e9d613f99c2c75d Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 12:05:36 -0700 Subject: [PATCH 5/8] Remove staging --- tests/ruby/chart/templates/deployment.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ruby/chart/templates/deployment.yaml b/tests/ruby/chart/templates/deployment.yaml index 3a7b84e..6128670 100644 --- a/tests/ruby/chart/templates/deployment.yaml +++ b/tests/ruby/chart/templates/deployment.yaml @@ -26,14 +26,14 @@ spec: value: k8s-e2e-test-app-ruby # used by the e2e Github action - name: NEW_RELIC_LABELS - value: 'testKey:{{ .Values.scenarioTag | default "NOTSET" }}' + value: "testKey:{{ .Values.scenarioTag | default "NOTSET" }}" - name: NEW_RELIC_LOG_LEVEL - value: debug + value: info # set the host to staging if using a staging license key - - name: NEW_RELIC_HOST - value: staging-collector.newrelic.com - - name: NEW_RELIC_LOG_FILE_PATH - value: STDOUT + # - name: NEW_RELIC_HOST + # value: staging-collector.newrelic.com + # - name: NEW_RELIC_LOG_FILE_PATH + # value: STDOUT --- apiVersion: v1 From 2afefe11a55180ea33b1b54ec12ea1963f432f30 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 13:43:33 -0700 Subject: [PATCH 6/8] Add publish workflow --- .github/workflows/ruby.yml | 99 +++++++++++++++++++------------------- tests/ruby/start.sh | 10 ++-- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 41c44af..87e3769 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -107,53 +107,52 @@ jobs: api_key: ${{ secrets.NEW_RELIC_API_KEY }} license_key: ${{ secrets.NEW_RELIC_LICENSE_KEY }} - # publish: - # if: github.event_name == 'release' && endsWith(github.ref, '_python') - # runs-on: ubuntu-latest - # needs: - # - test - - # steps: - # - name: Checkout code - # uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 - # with: - # persist-credentials: false - # fetch-depth: 0 - - # - name: Extract Agent Version - # id: version - # run: | - # agent_version=${{ github.ref_name }} # Use tag name - # agent_version=${agent_version##v} # Remove v prefix - # agent_version=${agent_version%%_${{ env.INITCONTAINER_LANGUAGE }}} # Remove language suffix - # echo "agent_version=${agent_version}" | tee -a "$GITHUB_OUTPUT" - - # - name: Set up Docker Buildx - # id: buildx - # uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # 3.3.0 - - # - name: Generate Docker metadata (tags and labels) - # id: meta - # uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 - # with: - # images: newrelic/newrelic-${{ env.INITCONTAINER_LANGUAGE }}-init - # tags: | - # type=raw,value=${{ steps.version.outputs.agent_version }} - # type=raw,value=latest - - # - name: Login to Docker Hub Container Registry - # uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # 3.1.0 - # with: - # username: ${{ github.repository_owner }} - # password: ${{ secrets.DOCKER_TOKEN }} - - # - name: Build and publish init container image - # uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # 5.3.0 - # with: - # push: true - # context: src/${{ env.INITCONTAINER_LANGUAGE }}/ - # platforms: linux/amd64,linux/arm64,linux/arm - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - # build-args: | - # AGENT_VERSION=${{ steps.version.outputs.agent_version }} + publish: + if: github.event_name == 'release' && endsWith(github.ref, '_ruby') + runs-on: ubuntu-latest + needs: + - test + + steps: + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 + with: + persist-credentials: false + + - name: Extract Agent Version + id: version + run: | + agent_version=${{ github.ref_name }} # Use tag name + agent_version=${agent_version##v} # Remove v prefix + agent_version=${agent_version%%_${{ env.INITCONTAINER_LANGUAGE }}} # Remove language suffix + echo "agent_version=${agent_version}" | tee -a "$GITHUB_OUTPUT" + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # 3.3.0 + + - name: Generate Docker metadata (tags and labels) + id: meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 + with: + images: newrelic/newrelic-${{ env.INITCONTAINER_LANGUAGE }}-init + tags: | + type=raw,value=${{ steps.version.outputs.agent_version }} + type=raw,value=latest + + - name: Login to Docker Hub Container Registry + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # 3.1.0 + with: + username: ${{ github.repository_owner }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and publish init container image + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # 5.3.0 + with: + push: true + context: src/${{ env.INITCONTAINER_LANGUAGE }}/ + platforms: linux/amd64,linux/arm64,linux/arm + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + AGENT_VERSION=${{ steps.version.outputs.agent_version }} diff --git a/tests/ruby/start.sh b/tests/ruby/start.sh index 1f64dc5..7ecd33d 100644 --- a/tests/ruby/start.sh +++ b/tests/ruby/start.sh @@ -3,8 +3,8 @@ # Start ruby app and provide time to boot Puma ruby app.rb & sleep 5 -# Make requests -while true; do - curl http://0.0.0.0:4567 - sleep 3 -done +# For local testing - hit endpoint +# while true; do +# curl http://0.0.0.0:4567 +# sleep 3 +# done From 99ab3ac5370f5980cdffb9c74523b0a324ecbc35 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 13:55:38 -0700 Subject: [PATCH 7/8] Hit endpoint --- tests/ruby/start.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ruby/start.sh b/tests/ruby/start.sh index 7ecd33d..7ba4b5d 100644 --- a/tests/ruby/start.sh +++ b/tests/ruby/start.sh @@ -3,8 +3,8 @@ # Start ruby app and provide time to boot Puma ruby app.rb & sleep 5 -# For local testing - hit endpoint -# while true; do -# curl http://0.0.0.0:4567 -# sleep 3 -# done +# Hit endponint +while true; do + curl http://0.0.0.0:4567 + sleep 3 +done From eee82fc111c6b284d32e6fb043c57e1f065b9e02 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Wed, 5 Jun 2024 14:38:12 -0700 Subject: [PATCH 8/8] Update test yml --- .github/workflows/ruby.yml | 8 ++++---- tests/ruby/Dockerfile | 2 -- tests/ruby/chart/templates/deployment.yaml | 3 --- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 87e3769..ae59509 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -50,13 +50,13 @@ jobs: contents: read with: agent-language: ruby - + test: name: Run Ruby init container tests runs-on: ubuntu-latest needs: check-modified-files - # run only if files were modified or the workflow was manually invoked - if: needs.check-modified-files.outputs.files-changed == 'true' || github.event_name == 'workflow_dispatch' + # 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') steps: - name: Checkout code @@ -70,7 +70,7 @@ jobs: - name: Start minikube uses: medyagh/setup-minikube@317d92317e473a10540357f1f4b2878b80ee7b95 # 0.0.16 - + - name: Deploy cert-manager to minikube run: | helm repo add jetstack https://charts.jetstack.io --force-update diff --git a/tests/ruby/Dockerfile b/tests/ruby/Dockerfile index 484326d..785f543 100644 --- a/tests/ruby/Dockerfile +++ b/tests/ruby/Dockerfile @@ -2,8 +2,6 @@ FROM ruby:latest WORKDIR /app -RUN apt-get update -qq && apt-get install -y nodejs postgresql-client - COPY Gemfile ./ RUN bundle install diff --git a/tests/ruby/chart/templates/deployment.yaml b/tests/ruby/chart/templates/deployment.yaml index 6128670..d1294f6 100644 --- a/tests/ruby/chart/templates/deployment.yaml +++ b/tests/ruby/chart/templates/deployment.yaml @@ -32,9 +32,6 @@ spec: # set the host to staging if using a staging license key # - name: NEW_RELIC_HOST # value: staging-collector.newrelic.com - # - name: NEW_RELIC_LOG_FILE_PATH - # value: STDOUT - --- apiVersion: v1 kind: Service