diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b12ffa..504a40c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,12 @@ # CHANGELOG -## v1.3.2 +## v1.4.2 - Update collector argument in the Analytics::API payload #170 - @KatieWright26 +## v1.4.1 +- Add in support to create file with trace data #167 + ## v1.3.1 - Cope with the gem being loaded but not configured when using minitest #165 - @billhorsman diff --git a/Gemfile.lock b/Gemfile.lock index 8bfe8a9..b9a41dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - buildkite-test_collector (1.3.2) + buildkite-test_collector (1.4.2) activesupport (>= 4.2) websocket (~> 1.2) diff --git a/lib/buildkite/test_collector.rb b/lib/buildkite/test_collector.rb index 12fb462..07fc316 100644 --- a/lib/buildkite/test_collector.rb +++ b/lib/buildkite/test_collector.rb @@ -43,14 +43,16 @@ class << self attr_accessor :session attr_accessor :debug_enabled attr_accessor :tracing_enabled + attr_accessor :artifact_path attr_accessor :env end - def self.configure(hook:, token: nil, url: nil, debug_enabled: false, tracing_enabled: true, env: {}) + def self.configure(hook:, token: nil, url: nil, debug_enabled: false, tracing_enabled: true, artifact_path: nil, env: {}) self.api_token = (token || ENV["BUILDKITE_ANALYTICS_TOKEN"])&.strip self.url = url || DEFAULT_URL self.debug_enabled = debug_enabled || !!(ENV["BUILDKITE_ANALYTICS_DEBUG_ENABLED"]) self.tracing_enabled = tracing_enabled + self.artifact_path = artifact_path self.env = env self.hook_into(hook) diff --git a/lib/buildkite/test_collector/library_hooks/rspec.rb b/lib/buildkite/test_collector/library_hooks/rspec.rb index fc385b6..8126100 100644 --- a/lib/buildkite/test_collector/library_hooks/rspec.rb +++ b/lib/buildkite/test_collector/library_hooks/rspec.rb @@ -29,6 +29,18 @@ trace = Buildkite::TestCollector::RSpecPlugin::Trace.new(example, history: tracer.history) Buildkite::TestCollector.uploader.traces[example.id] = trace end + + config.after(:suite) do + if Buildkite::TestCollector.artifact_path + filename = File.join(Buildkite::TestCollector.artifact_path, "buildkite-test-collector-rspec-#{SecureRandom.uuid}.json.gz") + data_set = { results: Buildkite::TestCollector.uploader.traces.values.map(&:as_hash) } + File.open(filename, "wb") do |f| + gz = Zlib::GzipWriter.new(f) + gz.write(data_set.to_json) + gz.close + end + end + end end Buildkite::TestCollector.enable_tracing! diff --git a/lib/buildkite/test_collector/version.rb b/lib/buildkite/test_collector/version.rb index b9131fd..4fa750e 100644 --- a/lib/buildkite/test_collector/version.rb +++ b/lib/buildkite/test_collector/version.rb @@ -2,7 +2,7 @@ module Buildkite module TestCollector - VERSION = "1.3.2" + VERSION = "1.4.2" NAME = "buildkite-test_collector" end end