From 37b8092a9e59ce0f41a5fe27a54dd0d86d7b1c7e Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 30 Nov 2020 13:30:00 +0000 Subject: [PATCH 01/25] [CI] Enable multibranch pipeline --- .ci/Jenkinsfile | 80 ++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++ Dockerfile | 1 + Gemfile | 1 + Gemfile.lock | 5 +++ docker/entrypoint.sh | 22 ++++++++++-- spec/spec_helper.rb | 1 + 7 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .ci/Jenkinsfile diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile new file mode 100644 index 0000000..d4db21b --- /dev/null +++ b/.ci/Jenkinsfile @@ -0,0 +1,80 @@ +#!/usr/bin/env groovy +@Library('apm@current') _ + +pipeline { + agent { label 'linux && immutable' } + environment { + REPO = 'ecs-logging-ruby' + BASE_DIR = "src/github.com/elastic/${env.REPO}" + PIPELINE_LOG_LEVEL = 'INFO' + NOTIFY_TO = credentials('notify-to') + JOB_GCS_BUCKET = credentials('gcs-bucket') + } + options { + timeout(time: 2, unit: 'HOURS') + buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30')) + timestamps() + ansiColor('xterm') + disableResume() + durabilityHint('PERFORMANCE_OPTIMIZED') + rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) + quietPeriod(10) + } + triggers { + issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*') + } + stages { + stage('Checkout') { + options { skipDefaultCheckout() } + steps { + pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) + deleteDir() + gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) + stash allowEmpty: true, name: 'source', useDefaultExcludes: false + } + } + stage('Tests') { + failFast false + matrix { + agent { label 'linux && docker && ubuntu-18.04 && immutable' } + options { skipDefaultCheckout() } + axes { + axis { + name 'RUBY_VERSION' + values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1' + } + axis { + name 'FRAMEWORK' + values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'rails-4.2', 'sinatra-2.0', 'sinatra-1.4' + } + } + stages { + stage('Tests') { + steps { + withGithubNotify(context: "Tests-${RUBY_VERSION}-${FRAMEWORK}") { + deleteDir() + unstash 'source' + withEnv(["HOME=${env.WORKSPACE}", "PATH=${env.PATH}:${env.WORKSPACE}/bin"]) { + dir("${BASE_DIR}"){ + dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}") + sh("bin/dev -i${RUBY_VERSION} -f${FRAMEWORK}") + } + } + } + post { + always { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: "**/spec/junit-reports/**/ruby-agent-junit.xml") + } + } + } + } + } + } + } + } + post { + cleanup { + notifyBuildResult() + } + } +} diff --git a/.gitignore b/.gitignore index 1694fee..f4b6c73 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ # rspec failure tracking .rspec_status /vendor + +# junit reports folder +spec/junit-reports diff --git a/Dockerfile b/Dockerfile index 3626a63..e49310e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH ENV FRAMEWORKS $FRAMEWORKS +ENV RUBY_IMAGE $RUBY_IMAGE RUN mkdir -p $VENDOR_PATH \ && chown -R $USER_ID_GROUP $VENDOR_PATH diff --git a/Gemfile b/Gemfile index b06134e..91beafa 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ gemspec gem "rake" gem "rspec" +gem 'yarjuf' gem "rack-test", require: nil gem "sinatra", require: nil diff --git a/Gemfile.lock b/Gemfile.lock index 88a8f6c..8c29edd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,6 +6,7 @@ PATH GEM remote: https://rubygems.org/ specs: + builder (3.2.4) diff-lcs (1.4.4) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) @@ -35,6 +36,9 @@ GEM rack-protection (= 2.1.0) tilt (~> 2.0) tilt (2.0.10) + yarjuf (2.0.0) + builder + rspec (~> 3) PLATFORMS ruby @@ -45,6 +49,7 @@ DEPENDENCIES rake rspec sinatra + yarjuf BUNDLED WITH 2.1.4 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index c840803..f700466 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,17 +1,35 @@ #!/bin/bash set -x +runRspec(){ + local case=${1:-""} + local bn=${case} + + if [ -n "${case}" ]; then + bn="$(basename "${case}")/" + fi + if [ -n "${RUBY_VERSION}" ]; then + bn="$RUBY_VERSION-$bn" + fi + if [ -n "${FRAMEWORKS}" ]; then + bn="$FRAMEWORKS-$bn" + fi + bundle exec rspec \ + -f progress \ + -r yarjuf -f JUnit -o "spec/junit-reports/${bn}ruby-agent-junit.xml" ${case} +} + bundle check || (rm Gemfile.lock && bundle) # If first arg is a spec path, run spec(s) if [[ $1 == spec/* ]]; then - bundle exec rspec $@ + runRspec $@ exit $? fi # If no arguments, run all specs if [[ $# == 0 ]]; then - bundle exec rspec + runRspec exit $? fi diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce7e6c6..c16f3c4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,6 +22,7 @@ Bundler.require :default, :test require "ecs_logging" +require 'yarjuf' RSpec.configure do |config| config.example_status_persistence_file_path = ".rspec_status" From c3779ff1c6af8511202fe0065be45cdc36045bd1 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 30 Nov 2020 14:49:58 +0000 Subject: [PATCH 02/25] Add docker env variables --- .ci/Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index d4db21b..88fca2e 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -6,6 +6,8 @@ pipeline { environment { REPO = 'ecs-logging-ruby' BASE_DIR = "src/github.com/elastic/${env.REPO}" + DOCKER_REGISTRY = 'docker.elastic.co' + DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod' PIPELINE_LOG_LEVEL = 'INFO' NOTIFY_TO = credentials('notify-to') JOB_GCS_BUCKET = credentials('gcs-bucket') From fe75ce0370b2190d5319dda73209ecb395c83746 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 30 Nov 2020 16:17:20 +0000 Subject: [PATCH 03/25] Install rbenv --- .ci/Jenkinsfile | 12 +++++++----- .ci/install-rbenv.sh | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100755 .ci/install-rbenv.sh diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 88fca2e..5f6fb1b 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -11,6 +11,9 @@ pipeline { PIPELINE_LOG_LEVEL = 'INFO' NOTIFY_TO = credentials('notify-to') JOB_GCS_BUCKET = credentials('gcs-bucket') + VERSION = '2.7.2' + HOME = "${WORKSPACE}" + PATH = "${WORKSPACE}/.rbenv/bin:${WORKSPACE}/.rbenv/versions/${VERSION}/bin:${PATH}" } options { timeout(time: 2, unit: 'HOURS') @@ -56,11 +59,10 @@ pipeline { withGithubNotify(context: "Tests-${RUBY_VERSION}-${FRAMEWORK}") { deleteDir() unstash 'source' - withEnv(["HOME=${env.WORKSPACE}", "PATH=${env.PATH}:${env.WORKSPACE}/bin"]) { - dir("${BASE_DIR}"){ - dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}") - sh("bin/dev -i${RUBY_VERSION} -f${FRAMEWORK}") - } + dir("${BASE_DIR}"){ + dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}") + sh(label: 'install rbenv', script: '.ci/install-rbenv.sh "${VERSION}"') + sh("bin/dev -i${RUBY_VERSION} -f${FRAMEWORK}") } } post { diff --git a/.ci/install-rbenv.sh b/.ci/install-rbenv.sh new file mode 100755 index 0000000..e555f63 --- /dev/null +++ b/.ci/install-rbenv.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +VERSION=${1:2.7.2} +export PATH="$HOME/.rbenv/bin:$PATH" +git clone https://github.com/rbenv/rbenv.git ~/.rbenv +git clone git@github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildCloning into '/var/lib/jenkins/.rbenv/plugins/ruby-build'... +eval "$(rbenv init -)" +rbenv install "${VERSION}" From 5b30cb3206105508d987dd310e178fbdc8ee3129 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 30 Nov 2020 17:12:18 +0000 Subject: [PATCH 04/25] Fix scripts --- .ci/install-rbenv.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/install-rbenv.sh b/.ci/install-rbenv.sh index e555f63..5e4bfe4 100755 --- a/.ci/install-rbenv.sh +++ b/.ci/install-rbenv.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -VERSION=${1:2.7.2} +VERSION=${1:-"2.7.2"} export PATH="$HOME/.rbenv/bin:$PATH" git clone https://github.com/rbenv/rbenv.git ~/.rbenv -git clone git@github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildCloning into '/var/lib/jenkins/.rbenv/plugins/ruby-build'... +git clone git@github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildCloning eval "$(rbenv init -)" rbenv install "${VERSION}" From 6484ac8e134839392c0622547ceda01caa196212 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 30 Nov 2020 17:42:10 +0000 Subject: [PATCH 05/25] Fix wrong post location --- .ci/Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 5f6fb1b..4db7546 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -65,10 +65,10 @@ pipeline { sh("bin/dev -i${RUBY_VERSION} -f${FRAMEWORK}") } } - post { - always { - junit(allowEmptyResults: true, keepLongStdio: true, testResults: "**/spec/junit-reports/**/ruby-agent-junit.xml") - } + } + post { + always { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/spec/junit-reports/**/*-junit.xml") } } } From 6a989f69c5fec9e6aae1909ac1cb534a5313d8cd Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 09:24:37 +0000 Subject: [PATCH 06/25] Return errorlevel --- bin/dev | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/dev b/bin/dev index 3d8055b..4e350d2 100755 --- a/bin/dev +++ b/bin/dev @@ -52,4 +52,5 @@ run 'docker-compose run' \ " -u #{USER_ID_GROUP}" \ ' --rm' \ " specs #{ARGV.join}" +exit $?.exitstatus unless $?.success? From fbb406e8809b79701454dfec09c5199eeefb5682 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 09:25:56 +0000 Subject: [PATCH 07/25] Debug what's going on in the CI container --- docker/entrypoint.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index f700466..4576c2b 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -21,6 +21,12 @@ runRspec(){ bundle check || (rm Gemfile.lock && bundle) +# For debugging purposes +ls -ltra /vendor +find /vendor -type f -ls +whoami +groups + # If first arg is a spec path, run spec(s) if [[ $1 == spec/* ]]; then runRspec $@ From 53cdc3c6bfe45407c63feed6b4afc0826c91adb3 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 09:41:43 +0000 Subject: [PATCH 08/25] Fix variable name to match the correct one --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9848f99..eabc4f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,11 +18,11 @@ services: - ./vendor:/vendor tmpfs: - /tmp:exec,mode=1777 - user: ${USER_ID} + user: ${USER_ID_GROUP} ruby_rspec: image: apm-agent-ruby:${RUBY_VERSION} - user: ${USER_ID} + user: ${USER_ID_GROUP} volumes: vendor: From df94cc9dde1b65a06e57cf86eb3a79354b88f2ea Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 09:57:07 +0000 Subject: [PATCH 09/25] Use bin/dev to pass the user --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index eabc4f0..727f657 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,11 +18,9 @@ services: - ./vendor:/vendor tmpfs: - /tmp:exec,mode=1777 - user: ${USER_ID_GROUP} ruby_rspec: image: apm-agent-ruby:${RUBY_VERSION} - user: ${USER_ID_GROUP} volumes: vendor: From 75e0a74bb2265ecf5e6e484616cac0126d886301 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 10:10:53 +0000 Subject: [PATCH 10/25] Revert "Use bin/dev to pass the user" This reverts commit df94cc9dde1b65a06e57cf86eb3a79354b88f2ea. --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 727f657..eabc4f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,9 +18,11 @@ services: - ./vendor:/vendor tmpfs: - /tmp:exec,mode=1777 + user: ${USER_ID_GROUP} ruby_rspec: image: apm-agent-ruby:${RUBY_VERSION} + user: ${USER_ID_GROUP} volumes: vendor: From 3ec4ac212bf2c3c0290a937f179f95b3ce5b8b60 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 10:11:17 +0000 Subject: [PATCH 11/25] Revert "Fix variable name to match the correct one" This reverts commit 53cdc3c6bfe45407c63feed6b4afc0826c91adb3. --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index eabc4f0..9848f99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,11 +18,11 @@ services: - ./vendor:/vendor tmpfs: - /tmp:exec,mode=1777 - user: ${USER_ID_GROUP} + user: ${USER_ID} ruby_rspec: image: apm-agent-ruby:${RUBY_VERSION} - user: ${USER_ID_GROUP} + user: ${USER_ID} volumes: vendor: From 262b7edf4da63382a4be530245436f446ac386d9 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 10:14:14 +0000 Subject: [PATCH 12/25] Pass the user variable --- bin/dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/dev b/bin/dev index 4e350d2..578fb25 100755 --- a/bin/dev +++ b/bin/dev @@ -48,8 +48,8 @@ unless options[:skip_build] exit $?.exitstatus unless $?.success? end -run 'docker-compose run' \ - " -u #{USER_ID_GROUP}" \ +run "USER_ID=#{USER_ID_GROUP}" \ + ' docker-compose run' \ ' --rm' \ " specs #{ARGV.join}" exit $?.exitstatus unless $?.success? From ac8bea037feb353cdf6ed4b058dd715fa17c331a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 10:46:37 +0000 Subject: [PATCH 13/25] Force user-id --- bin/dev | 5 ++--- docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/dev b/bin/dev index 578fb25..833ce36 100755 --- a/bin/dev +++ b/bin/dev @@ -33,7 +33,7 @@ IMAGE_NAME = "apm-agent-ruby:#{IMAGE_PATH_SAFE}" VENDOR_PATH = "/vendor/#{IMAGE_PATH_SAFE}" def run(cmd) - "IMAGE_NAME=#{IMAGE_NAME} #{cmd}".tap do |str| + "IMAGE_NAME=#{IMAGE_NAME} USER_ID_GROUP=#{USER_ID_GROUP} #{cmd}".tap do |str| puts str system str end @@ -48,8 +48,7 @@ unless options[:skip_build] exit $?.exitstatus unless $?.success? end -run "USER_ID=#{USER_ID_GROUP}" \ - ' docker-compose run' \ +run 'docker-compose run' \ ' --rm' \ " specs #{ARGV.join}" exit $?.exitstatus unless $?.success? diff --git a/docker-compose.yml b/docker-compose.yml index 9848f99..eabc4f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,11 +18,11 @@ services: - ./vendor:/vendor tmpfs: - /tmp:exec,mode=1777 - user: ${USER_ID} + user: ${USER_ID_GROUP} ruby_rspec: image: apm-agent-ruby:${RUBY_VERSION} - user: ${USER_ID} + user: ${USER_ID_GROUP} volumes: vendor: From b1c6a83f8d211bc2f500b9479405d13f848c3af8 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 11:10:14 +0000 Subject: [PATCH 14/25] Trying something else --- Dockerfile | 4 ++-- docker/entrypoint.sh | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e49310e..4277b20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,8 @@ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH ENV FRAMEWORKS $FRAMEWORKS ENV RUBY_IMAGE $RUBY_IMAGE -RUN mkdir -p $VENDOR_PATH \ - && chown -R $USER_ID_GROUP $VENDOR_PATH +RUN mkdir -p $GEM_HOME \ + && chown -R $USER_ID_GROUP $GEM_HOME USER $USER_ID_GROUP diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4576c2b..23f3738 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -19,14 +19,15 @@ runRspec(){ -r yarjuf -f JUnit -o "spec/junit-reports/${bn}ruby-agent-junit.xml" ${case} } -bundle check || (rm Gemfile.lock && bundle) - # For debugging purposes -ls -ltra /vendor -find /vendor -type f -ls +ls -ltra ${GEM_HOME} +find ${GEM_HOME} -type f -ls whoami groups + +bundle check || (rm Gemfile.lock && bundle) + # If first arg is a spec path, run spec(s) if [[ $1 == spec/* ]]; then runRspec $@ From 56ec9f90c6607220b87b7761ac7ea613ffcb9825 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 11:10:50 +0000 Subject: [PATCH 15/25] Simplify pipeline --- .ci/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 4db7546..1335566 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -46,11 +46,11 @@ pipeline { axes { axis { name 'RUBY_VERSION' - values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1' + values 'ruby:2.7' //, 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1' } axis { name 'FRAMEWORK' - values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'rails-4.2', 'sinatra-2.0', 'sinatra-1.4' + values 'rails-6.0'//, 'rails-5.2', 'rails-5.1', 'rails-4.2', 'sinatra-2.0', 'sinatra-1.4' } } stages { From 0d34bb07e5dadf412805edb4becc23163699bfae Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 11:11:50 +0000 Subject: [PATCH 16/25] use user instead chown --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4277b20..0b2e694 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,10 +24,8 @@ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH ENV FRAMEWORKS $FRAMEWORKS ENV RUBY_IMAGE $RUBY_IMAGE -RUN mkdir -p $GEM_HOME \ - && chown -R $USER_ID_GROUP $GEM_HOME - USER $USER_ID_GROUP +RUN mkdir -p $GEM_HOME # Upgrade RubyGems and install required Bundler version RUN gem update --system && \ From c40849f5a2ed543c57f0223b43b4fff65604bb43 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 11:21:10 +0000 Subject: [PATCH 17/25] Revert "use user instead chown" This reverts commit 0d34bb07e5dadf412805edb4becc23163699bfae. --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0b2e694..4277b20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,10 @@ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH ENV FRAMEWORKS $FRAMEWORKS ENV RUBY_IMAGE $RUBY_IMAGE +RUN mkdir -p $GEM_HOME \ + && chown -R $USER_ID_GROUP $GEM_HOME + USER $USER_ID_GROUP -RUN mkdir -p $GEM_HOME # Upgrade RubyGems and install required Bundler version RUN gem update --system && \ From 56f275ec126b990270c66462e2853cf3fe1f4b7e Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 11:26:19 +0000 Subject: [PATCH 18/25] more debug --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4277b20..1c9727b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,9 +24,9 @@ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH ENV FRAMEWORKS $FRAMEWORKS ENV RUBY_IMAGE $RUBY_IMAGE -RUN mkdir -p $GEM_HOME \ - && chown -R $USER_ID_GROUP $GEM_HOME - +RUN mkdir -p $VENDOR_PATH \ + && chown -R $USER_ID_GROUP $VENDOR_PATH +RUN ls -ltrah $VENDOR_PATH USER $USER_ID_GROUP # Upgrade RubyGems and install required Bundler version From 48dd355eb9e2fe5eb937a5d7962155e0414ccf69 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 12:05:48 +0000 Subject: [PATCH 19/25] Add something else --- docker/entrypoint.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 23f3738..bd0eab8 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -20,10 +20,8 @@ runRspec(){ } # For debugging purposes -ls -ltra ${GEM_HOME} -find ${GEM_HOME} -type f -ls -whoami -groups +ls -ltra /vendor || true +find /vendor -type f -ls || true bundle check || (rm Gemfile.lock && bundle) From fd097979d19ca7cfa2f2e716a0b274bb2239acb3 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 12:35:48 +0000 Subject: [PATCH 20/25] Chown for the vendor top level folder --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c9727b..a5e0853 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,7 @@ ENV FRAMEWORKS $FRAMEWORKS ENV RUBY_IMAGE $RUBY_IMAGE RUN mkdir -p $VENDOR_PATH \ - && chown -R $USER_ID_GROUP $VENDOR_PATH -RUN ls -ltrah $VENDOR_PATH + && chown -R $USER_ID_GROUP /vendor USER $USER_ID_GROUP # Upgrade RubyGems and install required Bundler version From 1593726fea1bd55d7446f02123347e4a1400230f Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 12:48:53 +0000 Subject: [PATCH 21/25] Avoid caching and volume mounting since it does not work when running a docker container --- Dockerfile | 5 +++-- docker-compose.yml | 1 - docker/entrypoint.sh | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index a5e0853..c06868e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,9 @@ ENV PATH=/app/bin:$BUNDLE_BIN:$PATH ENV FRAMEWORKS $FRAMEWORKS ENV RUBY_IMAGE $RUBY_IMAGE -RUN mkdir -p $VENDOR_PATH \ - && chown -R $USER_ID_GROUP /vendor +# Copy cached folder to speed up docker containers +COPY vendor /vendor +RUN chown -R $USER_ID_GROUP /vendor USER $USER_ID_GROUP # Upgrade RubyGems and install required Bundler version diff --git a/docker-compose.yml b/docker-compose.yml index eabc4f0..f070656 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,6 @@ services: tty: true volumes: - .:/app:cached - - ./vendor:/vendor tmpfs: - /tmp:exec,mode=1777 user: ${USER_ID_GROUP} diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index bd0eab8..f700466 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -19,11 +19,6 @@ runRspec(){ -r yarjuf -f JUnit -o "spec/junit-reports/${bn}ruby-agent-junit.xml" ${case} } -# For debugging purposes -ls -ltra /vendor || true -find /vendor -type f -ls || true - - bundle check || (rm Gemfile.lock && bundle) # If first arg is a spec path, run spec(s) From 2af90984acca3b227d42e9702087a02133c56d2e Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 13:17:20 +0000 Subject: [PATCH 22/25] Add vendor to help with the caching --- vendor/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 vendor/.gitkeep diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 0000000..e69de29 From b3e3dba75103f1cc989c5d043adc245f82ffa284 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 13:35:06 +0000 Subject: [PATCH 23/25] Revert "Simplify pipeline" This reverts commit 56ec9f90c6607220b87b7761ac7ea613ffcb9825. --- .ci/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 1335566..4db7546 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -46,11 +46,11 @@ pipeline { axes { axis { name 'RUBY_VERSION' - values 'ruby:2.7' //, 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1' + values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1' } axis { name 'FRAMEWORK' - values 'rails-6.0'//, 'rails-5.2', 'rails-5.1', 'rails-4.2', 'sinatra-2.0', 'sinatra-1.4' + values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'rails-4.2', 'sinatra-2.0', 'sinatra-1.4' } } stages { From dfda5c9e61c2ac6f8263e013dba644ea9bfcd40b Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 1 Dec 2020 13:36:45 +0000 Subject: [PATCH 24/25] Add CI badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 985ba89..f6c0603 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Jenkins](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-ruby/ecs-logging-ruby-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-ruby/job/ecs-logging-ruby-mbp/job/master/) # ecs-logging-ruby This set of libraries allows you to transform your application logs to structured logs that comply with the [Elastic Common Schema (ECS)](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html). From 4a0b1a3f858c70c7b9a027ba3e5282eeba8ec26c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 2 Dec 2020 09:30:39 +0000 Subject: [PATCH 25/25] Apply suggestions from code review Co-authored-by: Mikkel Malmberg --- .ci/Jenkinsfile | 2 +- bin/dev | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 4db7546..8b1296a 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -50,7 +50,7 @@ pipeline { } axis { name 'FRAMEWORK' - values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'rails-4.2', 'sinatra-2.0', 'sinatra-1.4' + values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'sinatra-2.0' } } stages { diff --git a/bin/dev b/bin/dev index 833ce36..c76ee0f 100755 --- a/bin/dev +++ b/bin/dev @@ -51,5 +51,5 @@ end run 'docker-compose run' \ ' --rm' \ " specs #{ARGV.join}" -exit $?.exitstatus unless $?.success? +exit $?.exitstatus unless $?.success?