Skip to content

Commit

Permalink
add command line interface for this gem
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Oct 10, 2024
1 parent 9bbc5ec commit a5234ee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions datadog-ci.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/DataDog/datadog-ci-rb"
spec.license = "BSD-3-Clause"

spec.bindir = "exe"
spec.executables = ["ddcirb"]

spec.metadata["allowed_push_host"] = "https://rubygems.org"
spec.metadata["changelog_uri"] = "https://github.com/DataDog/datadog-ci-rb/blob/main/CHANGELOG.md"
spec.metadata["homepage_uri"] = spec.homepage
Expand All @@ -36,6 +39,7 @@ Gem::Specification.new do |spec|
README.md
ext/**/*
lib/**/*
exe/**/*
]].select { |fn| File.file?(fn) } # We don't want directories, only files
.reject { |fn| fn.end_with?(".so", ".bundle") } # Exclude local native binary artifacts

Expand Down
28 changes: 28 additions & 0 deletions exe/ddcirb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby

require "rspec/core"
require "datadog/ci"

Datadog.configure do |c|
c.ci.enabled = true
c.ci.itr_enabled = true
c.ci.discard_traces = true
c.ci.instrument :rspec, dry_run_enabled: true
c.tracing.enabled = true
end

rspec_cli_options = %w[
--dry-run
spec
]

options = ::RSpec::Core::ConfigurationOptions.new(rspec_cli_options)
devnull = File.new("/dev/null", "w")
exit_code = ::RSpec::Core::Runner.new(options).run(devnull, devnull)

if exit_code != 0
Datadog.logger.error("RSpec dry-run failed with exit code #{exit_code}")
end

test_optimisation = Datadog.send(:components).test_optimisation
print((test_optimisation.skipped_tests_count.to_f / test_optimisation.total_tests_count).floor(2))

0 comments on commit a5234ee

Please sign in to comment.