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

[SDTEST-1129] extract ciqueue instrumentation #254

Merged
merged 1 commit into from
Nov 19, 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
1 change: 1 addition & 0 deletions lib/datadog/ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def test_optimisation

# Test runners (instrumented automatically when corresponding frameworks are instrumented)
require_relative "ci/contrib/knapsack/integration"
require_relative "ci/contrib/ciqueue/integration"

# Additional test libraries (auto instrumented later on test session start)
require_relative "ci/contrib/selenium/integration"
Expand Down
34 changes: 34 additions & 0 deletions lib/datadog/ci/contrib/ciqueue/integration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require_relative "../integration"
require_relative "patcher"

module Datadog
module CI
module Contrib
module Ciqueue
# ci-queue test runner instrumentation
# https://github.com/Shopify/ci-queue
class Integration < Contrib::Integration
MINIMUM_VERSION = Gem::Version.new("0.9.0")

def version
Gem.loaded_specs["ci-queue"]&.version
end

def loaded?
!defined?(::RSpec::Queue::Runner).nil?
end

def compatible?
super && version >= MINIMUM_VERSION
end

def patcher
Patcher
end
end
end
end
end
end
23 changes: 23 additions & 0 deletions lib/datadog/ci/contrib/ciqueue/patcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require_relative "../patcher"
require_relative "../rspec/runner"

module Datadog
module CI
module Contrib
module Ciqueue
# Patcher enables patching of 'rspec' module.
module Patcher
include Datadog::CI::Contrib::Patcher

module_function

def patch
::RSpec::Queue::Runner.include(Contrib::RSpec::Runner)
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/datadog/ci/contrib/rspec/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Integration < Contrib::Integration
MINIMUM_VERSION = Gem::Version.new("3.0.0")

def dependants
%i[knapsack]
%i[knapsack ciqueue]
end

def version
Expand Down
13 changes: 0 additions & 13 deletions lib/datadog/ci/contrib/rspec/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,10 @@ module Patcher
module_function

def patch
# ci-queue test runner instrumentation
# TODO: to be extracted in the next PR
# https://github.com/Shopify/ci-queue
if ci_queue?
::RSpec::Queue::Runner.include(Runner)
end

# default rspec test runner instrumentation
::RSpec::Core::Runner.include(Runner)

::RSpec::Core::Example.include(Example)
::RSpec::Core::ExampleGroup.include(ExampleGroup)
end

def ci_queue?
!!defined?(::RSpec::Queue::Runner)
end
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions sig/datadog/ci/contrib/ciqueue/integration.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Datadog
module CI
module Contrib
module Ciqueue
class Integration < Contrib::Integration
MINIMUM_VERSION: untyped

def version: () -> untyped

def loaded?: () -> bool

def compatible?: () -> bool

def patcher: () -> singleton(Patcher)
end
end
end
end
end
13 changes: 13 additions & 0 deletions sig/datadog/ci/contrib/ciqueue/patcher.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Datadog
module CI
module Contrib
module Ciqueue
module Patcher
include Datadog::CI::Contrib::Patcher

def self?.patch: () -> void
end
end
end
end
end
Loading