Sha256: 3c79fcd342cc03d63bcf0bbc9006fa86b78a26f125882aa89cb84cb2fd466dc5

Contents?: true

Size: 1.44 KB

Versions: 14

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require 'uri'
require 'cgi'
require 'json'

require 'ci/queue/version'
require 'ci/queue/output_helpers'
require 'ci/queue/circuit_breaker'
require 'ci/queue/configuration'
require 'ci/queue/common'
require 'ci/queue/build_record'
require 'ci/queue/static'
require 'ci/queue/file'
require 'ci/queue/grind'
require 'ci/queue/bisect'

module CI
  module Queue
    extend self

    attr_accessor :shuffler, :requeueable

    module Warnings
      RESERVED_LOST_TEST = :RESERVED_LOST_TEST
    end

    GET_NOW = ::Time.method(:now)
    private_constant :GET_NOW
    def time_now
      # Mocks like freeze_time should be cleaned when ci-queue runs, however,
      # we experienced cases when tests were enqueued with wrong timestamps, so we
      # safeguard Time.now here.
      GET_NOW.call
    end

    def requeueable?(test_result)
      requeueable.nil? || requeueable.call(test_result)
    end

    def shuffle(tests, random)
      if shuffler
        shuffler.call(tests, random)
      else
        tests.sort.shuffle(random: random)
      end
    end

    def from_uri(url, config)
      uri = URI(url)
      implementation = case uri.scheme
      when 'list'
        Static
      when 'file', nil
        File
      when 'redis', 'rediss'
        require 'ci/queue/redis'
        Redis
      else
        raise ArgumentError, "Don't know how to handle #{uri.scheme} URLs"
      end
      implementation.from_uri(uri, config)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ci-queue-0.58.0 lib/ci/queue.rb
ci-queue-0.57.0 lib/ci/queue.rb
ci-queue-0.56.0 lib/ci/queue.rb
ci-queue-0.55.0 lib/ci/queue.rb
ci-queue-0.52.0 lib/ci/queue.rb
ci-queue-0.51.0 lib/ci/queue.rb
ci-queue-0.50.0 lib/ci/queue.rb
ci-queue-0.49.0 lib/ci/queue.rb
ci-queue-0.48.0 lib/ci/queue.rb
ci-queue-0.47.0 lib/ci/queue.rb
ci-queue-0.46.0 lib/ci/queue.rb
ci-queue-0.45.0 lib/ci/queue.rb
ci-queue-0.44.0 lib/ci/queue.rb
ci-queue-0.43.0 lib/ci/queue.rb