Sha256: 8da62393df347b520c317dc1ef0766569bed2a445252f013695044bde5018920

Contents?: true

Size: 1.33 KB

Versions: 33

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'optparse'

options = {}
OptionParser.new do |opts|
  opts.banner = 'Usage: bin/dev [options] [command]'

  opts.on(
    '-iIMAGE', '--image=IMAGE',
    'Specify Docker image (eg. ruby:latest)'
  ) { |val| options[:image] = val }

  opts.on(
    '-fFRAMEWORKS', '--frameworks=FRAMEWORKS',
    'Specify frameworks to test (eg. rails:master,sinatra)'
  ) { |val| options[:frameworks] = val }

  opts.on(
    '-s', '--skip-build',
    'Skip building image'
  ) { |val| options[:skip_build] = val }
end.parse!

USER_ID_GROUP = %w[u g].map { |f| `id -#{f}`.chomp }.join(':')

RUBY_IMAGE = options.fetch(:image, 'ruby:latest')
FRAMEWORKS = options.fetch(:frameworks, 'rails,sinatra,grape')

IMAGE_PATH_SAFE = RUBY_IMAGE.tr(':', '_')
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|
    puts str
    system str
  end
end

unless options[:skip_build]
  run 'docker-compose build ' \
    " --build-arg RUBY_IMAGE=#{RUBY_IMAGE}" \
    " --build-arg USER_ID_GROUP=#{USER_ID_GROUP}" \
    " --build-arg FRAMEWORKS=#{FRAMEWORKS}" \
    " --build-arg VENDOR_PATH=#{VENDOR_PATH}"
  exit $?.exitstatus unless $?.success?
end

run 'docker-compose run' \
  " -u #{USER_ID_GROUP}" \
  ' --rm' \
  " specs #{ARGV.join}"

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
elastic-apm-4.7.3 bin/dev
elastic-apm-4.7.2 bin/dev
elastic-apm-4.7.1 bin/dev
elastic-apm-4.7.0 bin/dev
elastic-apm-4.6.2 bin/dev
elastic-apm-4.6.1 bin/dev
elastic-apm-4.6.0 bin/dev
elastic-apm-4.5.1 bin/dev
elastic-apm-4.5.0 bin/dev
elastic-apm-4.4.0 bin/dev
elastic-apm-4.3.0 bin/dev
elastic-apm-4.2.0 bin/dev
elastic-apm-4.1.0 bin/dev
elastic-apm-4.0.0 bin/dev
elastic-apm-4.0.0.beta.2 bin/dev
elastic-apm-3.15.1 bin/dev
elastic-apm-4.0.0.beta.1 bin/dev
elastic-apm-3.15.0 bin/dev
elastic-apm-3.14.0 bin/dev
elastic-apm-3.13.0 bin/dev