Skip to content

Commit

Permalink
Merge branch 'tonycthsu/lib-injection-package-pipeline' into robertom…
Browse files Browse the repository at this point in the history
…onteromiguel/add_onboarding_tests
  • Loading branch information
TonyCTHsu committed Feb 23, 2024
2 parents e9aa3db + 0c5880b commit ef6be2e
Show file tree
Hide file tree
Showing 601 changed files with 7,838 additions and 1,961 deletions.
66 changes: 30 additions & 36 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ include:
- local: ".gitlab/benchmarks.yml"
- local: ".gitlab/onboarding_tests.yml"

# -----------------------------------------------------
# Reliability Environment configuration
# -----------------------------------------------------

variables:
RUBY_PACKAGE_VERSION:
description: "The version of the gem to build the rpm/deb package"
DOWNSTREAM_BRANCH:
value: "master"
description: "Run a specific datadog-reliability-env branch downstream"
RUBY_CUSTOM_IMAGE_BASE: $DOCKER_REGISTRY/ci/dd-trace-rb/custom_ruby

default:
tags: [ "runner:main", "size:large" ]
tags: ["runner:main", "size:large"]

.build-image-base:
stage: manual-images
Expand All @@ -38,7 +32,7 @@ default:
parallel:
matrix:
# ADD NEW RUBIES HERE
- RUBY_VERSION: [ '3.2.2', '3.1.4', '3.0.6', '2.7.8' ]
- RUBY_VERSION: ["3.2.2", "3.1.4", "3.0.6", "2.7.8"]
script:
- >
docker build
Expand All @@ -48,35 +42,34 @@ default:
- docker push --all-tags $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE

build-image-amd64:
extends: .build-image-base
tags: [ "runner:docker" ]
variables:
ARCHITECTURE: amd64
extends: .build-image-base
tags: ["runner:docker"]
variables:
ARCHITECTURE: amd64

build-image-arm64:
extends: .build-image-base
tags: [ "runner:docker-arm", "platform:arm64"]
variables:
ARCHITECTURE: arm64
extends: .build-image-base
tags: ["runner:docker-arm", "platform:arm64"]
variables:
ARCHITECTURE: arm64

promote-image:
stage: manual-images
when: manual
tags: [ "runner:docker" ]
tags: ["runner:docker"]
image: $DOCKER_REGISTRY/docker:20.10.13
parallel:
matrix:
# ADD NEW RUBIES HERE
- RUBY_VERSION: [ '3.2.2', '3.1.4', '3.0.6', '2.7.8' ]
ARCHITECTURE: [ 'amd64', 'arm64' ]
- RUBY_VERSION: ["3.2.2", "3.1.4", "3.0.6", "2.7.8"]
ARCHITECTURE: ["amd64", "arm64"]
script:
- docker pull $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:$CI_PIPELINE_ID
- docker tag $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:$CI_PIPELINE_ID $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:current
- docker push $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-$ARCHITECTURE:current

build-gem:
# TODO: Replace with the correct image for the ruby version
image: $RUBY_CUSTOM_IMAGE_BASE/3.2.2-amd64:current
image: $DOCKER_REGISTRY/images/mirror/ruby:3.2.2
stage: package
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
Expand All @@ -89,14 +82,15 @@ build-gem:
allow_failure: true
script:
- if [ -z "$CI_COMMIT_TAG"]; then .gitlab/patch_gem_version.sh; fi # if not release, patch the version
- bundle install && bundle exec rake build # .gem is created under pkg/
- bundle install && bundle exec rake build
- mkdir -p tmp && ruby -Ilib -rddtrace/version -e 'puts Gem::Version.new(DDTrace::VERSION::STRING).to_s' >> tmp/version.txt
artifacts:
paths:
- pkg
- tmp
- lib/ddtrace/version.rb

.install-version-dependent-gems:
.install-dependencies:
parallel:
matrix:
- RUBY_VERSION: ["2.7.8", "3.0.6", "3.1.4", "3.2.2"]
Expand All @@ -106,28 +100,28 @@ build-gem:
script:
- export RUBY_PACKAGE_VERSION=$(cat tmp/version.txt)
- export DDTRACE_GEM_LOCATION=$(readlink -f pkg/ddtrace-*.gem)
- if [ -z "$CI_COMMIT_TAG"]; then .gitlab/patch_gem_version.sh; fi # if not release, patch the version
- ruby .gitlab/install_ddtrace_deps.rb
artifacts:
paths:
- pkg
- tmp
- lib/ddtrace/version.rb

install-version-dependent-gems-amd64:
extends: .install-version-dependent-gems
install-dependencies-amd64:
extends: .install-dependencies
image: $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-amd64:current
tags: [ "runner:main" ]
tags: ["runner:main"]

install-version-dependent-gems-arm64:
extends: .install-version-dependent-gems
install-dependencies-arm64:
extends: .install-dependencies
image: $RUBY_CUSTOM_IMAGE_BASE/$RUBY_VERSION-arm64:current
tags: [ "arch:arm64" ]
tags: ["arch:arm64"]

package-amd64:
extends: .package
needs:
- build-gem
- install-version-dependent-gems-amd64
- install-dependencies-amd64
script:
- ls ../pkg
- cp ../lib-injection/host_inject.rb ../tmp
Expand All @@ -138,7 +132,7 @@ package-arm64:
extends: .package-arm
needs:
- build-gem
- install-version-dependent-gems-arm64
- install-dependencies-arm64
script:
- ls ../pkg
- cp ../lib-injection/host_inject.rb ../tmp
Expand Down Expand Up @@ -192,9 +186,9 @@ deploy_to_reliability_env:
deploy_to_docker_registries:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
- if: "$POPULATE_CACHE"
when: never
- if: '$CI_COMMIT_TAG =~ /^v.*/'
- if: "$CI_COMMIT_TAG =~ /^v.*/"
when: delayed
start_in: 1 day
- when: manual
Expand All @@ -211,9 +205,9 @@ deploy_to_docker_registries:
deploy_latest_tag_to_docker_registries:
stage: deploy
rules:
- if: '$POPULATE_CACHE'
- if: "$POPULATE_CACHE"
when: never
- if: '$CI_COMMIT_TAG =~ /^v.*/'
- if: "$CI_COMMIT_TAG =~ /^v.*/"
when: delayed
start_in: 1 day
- when: manual
Expand Down
13 changes: 2 additions & 11 deletions .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ only-profiling:
# better accuracy, mode.
DD_PROFILING_NO_SIGNALS_WORKAROUND_ENABLED: "false"

only-profiling-timeline:
only-profiling-gc:
extends: .benchmarks
variables:
DD_BENCHMARKS_CONFIGURATION: only-profiling
DD_PROFILING_ENABLED: "true"
DD_PROFILING_NO_SIGNALS_WORKAROUND_ENABLED: "false"
DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED: "true"
DD_PROFILING_FORCE_ENABLE_GC: "true"

profiling-and-tracing:
extends: .benchmarks
Expand Down Expand Up @@ -110,15 +110,6 @@ profiling-and-tracing-and-appsec:
DD_PROFILING_ENABLED: "true"
DD_PROFILING_NO_SIGNALS_WORKAROUND_ENABLED: "false"

profiling-and-tracing-and-appsec-timeline:
extends: .benchmarks
variables:
DD_BENCHMARKS_CONFIGURATION: profiling-and-tracing-and-appsec
DD_APPSEC_ENABLED: "true"
DD_PROFILING_ENABLED: "true"
DD_PROFILING_NO_SIGNALS_WORKAROUND_ENABLED: "false"
DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED: "true"

candidate-tracer-appsec-with-api-security:
extends: .benchmarks
variables:
Expand Down
58 changes: 29 additions & 29 deletions .gitlab/install_ddtrace_deps.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require "open3"
require "rubygems"
require "bundler"
require "fileutils"
require "pathname"
require 'open3'
require 'rubygems'
require 'bundler'
require 'fileutils'
require 'pathname'

ruby_api_version = Gem.ruby_api_version

current_path = Pathname.new(FileUtils.pwd)

tmp_path = current_path.join("tmp")
tmp_path = current_path.join('tmp')

versioned_path = tmp_path.join(ruby_api_version)

Expand All @@ -21,59 +21,59 @@
file.write("gem 'ddtrace', '#{ENV.fetch('RUBY_PACKAGE_VERSION')}', path: '#{current_path}'")
end

STDOUT.puts '=== Reading Gemfile ==='
File.foreach(gemfile_file_path) { |x| STDOUT.puts x }
STDOUT.puts "=== Reading Gemfile ===\n"
$stdout.puts '=== Reading Gemfile ==='
File.foreach(gemfile_file_path) { |x| $stdout.puts x }
$stdout.puts "=== Reading Gemfile ===\n"

STDOUT.puts "=== bundle lock ==="
output, status = Open3.capture2e({ "BUNDLE_GEMFILE" => gemfile_file_path.to_s }, "bundle lock")
STDOUT.puts output
STDOUT.puts "=== bundle lock ===\n"
$stdout.puts '=== bundle lock ==='
output, status = Open3.capture2e({ 'BUNDLE_GEMFILE' => gemfile_file_path.to_s }, 'bundle lock')
$stdout.puts output
$stdout.puts "=== bundle lock ===\n"

exit 1 unless status.success?

lock_file_path = versioned_path.join("Gemfile.lock")
lock_file_path = versioned_path.join('Gemfile.lock')

STDOUT.puts '=== Reading Lockfile ==='
File.foreach(lock_file_path) { |x| STDOUT.puts x }
STDOUT.puts "=== Reading Lockfile ===\n"
$stdout.puts '=== Reading Lockfile ==='
File.foreach(lock_file_path) { |x| $stdout.puts x }
$stdout.puts "=== Reading Lockfile ===\n"

lock_file_parser = Bundler::LockfileParser.new(Bundler.read_file(lock_file_path))

gem_version_mapping = lock_file_parser.specs.each_with_object({}) do |spec, hash|
hash[spec.name] = spec.version.to_s
end

STDOUT.puts gem_version_mapping
$stdout.puts gem_version_mapping

gem_version_mapping.each do |gem, version|
env = {}

gem_install_cmd = "gem install #{gem} "\
"--version #{version} "\
"--no-document "\
"--ignore-dependencies "
'--no-document '\
'--ignore-dependencies '

case gem
when "ffi"
when 'ffi'
gem_install_cmd << "--install-dir #{versioned_path} "
# Install `ffi` gem with its built-in `libffi` native extension instead of using system's `libffi`
gem_install_cmd << "-- --disable-system-libffi "
when "ddtrace"
gem_install_cmd << '-- --disable-system-libffi '
when 'ddtrace'
# Install `ddtrace` gem locally without its profiling native extension
env["DD_PROFILING_NO_EXTENSION"] = "true"
env['DD_PROFILING_NO_EXTENSION'] = 'true'
gem_install_cmd =
"gem install --local #{ENV.fetch('DDTRACE_GEM_LOCATION')} "\
"--no-document "\
"--ignore-dependencies "\
'--no-document '\
'--ignore-dependencies '\
"--install-dir #{versioned_path} "
else
gem_install_cmd << "--install-dir #{versioned_path} "
end

STDOUT.puts "Execute: #{gem_install_cmd}"
$stdout.puts "Execute: #{gem_install_cmd}"
output, status = Open3.capture2e(env, gem_install_cmd)
STDOUT.puts output
$stdout.puts output

if status.success?
next
Expand All @@ -82,7 +82,7 @@
end
end

FileUtils.cd(versioned_path.join("extensions/#{Gem::Platform.local.to_s}"), verbose: true) do
FileUtils.cd(versioned_path.join("extensions/#{Gem::Platform.local}"), verbose: true) do
# Symlink those directories to be utilized by Ruby compiled with shared libraries
FileUtils.ln_sf Gem.extension_api_version, ruby_api_version
end
12 changes: 11 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TEST_METADATA = {
'' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
},
'profiling:main' => {
'opentelemetry' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ❌ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ❌ jruby',
'' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
},
'profiling:ractors' => {
Expand Down Expand Up @@ -261,6 +262,9 @@ TEST_METADATA = {
'redis-4' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby',
'redis-5' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
},
'routetest' => {
'multi-rack-app' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
},
'appsec:rack' => {
# Non-deprecated form of Regexp.new does not backport to Rack 1.x, see: https://github.com/rack/rack/pull/1998
'rack-1' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ❌ 3.3 / ✅ jruby',
Expand Down Expand Up @@ -343,7 +347,7 @@ namespace :spec do
task all: [:main, :benchmark,
:rails, :railsredis, :railsredis_activesupport, :railsactivejob,
:elasticsearch, :http, :redis, :sidekiq, :sinatra, :hanami, :hanami_autoinstrument,
:profiling]
:profiling, :routetest]

desc '' # "Explicitly hiding from `rake -T`"
RSpec::Core::RakeTask.new(:main) do |t, args|
Expand Down Expand Up @@ -378,6 +382,12 @@ namespace :spec do
t.rspec_opts = args.to_a.join(' ')
end

desc '' # "Explicitly hiding from `rake -T`"
RSpec::Core::RakeTask.new(:routetest) do |t, args|
t.pattern = 'spec/datadog/tracing/contrib/http_route_spec.rb'
t.rspec_opts = args.to_a.join(' ')
end

desc '' # "Explicitly hiding from `rake -T`"
RSpec::Core::RakeTask.new(:railsredis) do |t, args|
t.pattern = 'spec/datadog/tracing/contrib/rails/**/*redis*_spec.rb'
Expand Down
2 changes: 1 addition & 1 deletion Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ target :ddtrace do
ignore 'lib/datadog/core/configuration/option_definition_set.rb'
ignore 'lib/datadog/core/configuration/options.rb'
ignore 'lib/datadog/core/configuration/settings.rb'
ignore 'lib/datadog/core/diagnostics/environment_logger.rb'
ignore 'lib/datadog/core/diagnostics/health.rb'
ignore 'lib/datadog/core/encoding.rb'
ignore 'lib/datadog/core/environment/container.rb'
Expand Down Expand Up @@ -621,6 +620,7 @@ target :ddtrace do
library 'base64'
library 'digest'
library 'zlib'
library 'time'

repo_path 'vendor/rbs'
library 'cucumber'
Expand Down
8 changes: 8 additions & 0 deletions appraisal/jruby-9.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,11 @@
appraise 'core-old' do
gem 'dogstatsd-ruby', '~> 4'
end

appraise 'multi-rack-app' do
gem 'sinatra'
gem 'rack-contrib'
gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'grape'
gem 'rails', '~> 5.2.1'
end
8 changes: 8 additions & 0 deletions appraisal/jruby-9.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,11 @@
appraise 'core-old' do
gem 'dogstatsd-ruby', '~> 4'
end

appraise 'multi-rack-app' do
gem 'sinatra', '>= 3'
gem 'rack-contrib'
gem 'rack-test' # Dev dependencies for testing rack-based code
gem 'grape'
gem 'rails', '~> 5.2.1'
end
Loading

0 comments on commit ef6be2e

Please sign in to comment.