lib/ci/queue/configuration.rb in ci-queue-0.16.0 vs lib/ci/queue/configuration.rb in ci-queue-0.17.0

- old
+ new

@@ -1,11 +1,13 @@ +# frozen_string_literal: true module CI module Queue class Configuration - attr_accessor :timeout, :build_id, :worker_id, :max_requeues + attr_accessor :timeout, :build_id, :worker_id, :max_requeues, :grind_count, :failure_file attr_accessor :requeue_tolerance, :namespace, :seed, :failing_test, :statsd_endpoint - attr_reader :circuit_breaker + attr_accessor :max_test_duration, :max_test_duration_percentile + attr_reader :circuit_breakers class << self def from_env(env) new( build_id: env['CIRCLE_BUILD_URL'] || env['BUILDKITE_BUILD_ID'] || env['TRAVIS_BUILD_ID'] || env['HEROKU_TEST_RUN_ID'] || env['SEMAPHORE_PIPELINE_ID'], @@ -24,28 +26,40 @@ end end def initialize( timeout: 30, build_id: nil, worker_id: nil, max_requeues: 0, requeue_tolerance: 0, - namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil + namespace: nil, seed: nil, flaky_tests: [], statsd_endpoint: nil, max_consecutive_failures: nil, + grind_count: nil, max_duration: nil, failure_file: nil, max_test_duration: nil, + max_test_duration_percentile: 0.5 ) - @namespace = namespace - @timeout = timeout + @circuit_breakers = [CircuitBreaker::Disabled] @build_id = build_id - @worker_id = worker_id + @failure_file = failure_file + @flaky_tests = flaky_tests + @grind_count = grind_count @max_requeues = max_requeues + @namespace = namespace @requeue_tolerance = requeue_tolerance @seed = seed - @flaky_tests = flaky_tests @statsd_endpoint = statsd_endpoint + @timeout = timeout + @worker_id = worker_id + @max_test_duration = max_test_duration + @max_test_duration_percentile = max_test_duration_percentile + self.max_duration = max_duration self.max_consecutive_failures = max_consecutive_failures end def max_consecutive_failures=(max) - @circuit_breaker = if max - CircuitBreaker.new(max_consecutive_failures: max) - else - CircuitBreaker::Disabled + if max + @circuit_breakers << CircuitBreaker.new(max_consecutive_failures: max) + end + end + + def max_duration=(duration) + if duration + @circuit_breakers << CircuitBreaker::Timeout.new(duration: duration) end end def flaky?(test) @flaky_tests.include?(test.id)