source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/run_command_formatter_test.rb | Ruby | mit | 235 | main | 2,485 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class RunCommandFormatterTest < Minitest::Test
include ReporterTestHelper
def teardown
Minitest.run_command_formatter = Minitest::Queue::DEFAULT_RUN_COMMAND_FORMATTER
end
def test_default_formatter
result = resul... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/runner_test.rb | Ruby | mit | 235 | main | 309 | # frozen_string_literal: true
require 'minitest/queue/runner'
require 'test_helper'
module Minitest::Queue
class RunnerTest < Minitest::Test
def test_multiple_load_paths
runner = Runner.new(["-Ilib:test", "-Ielse"])
assert_equal("lib:test:else", runner.send(:load_paths))
end
end
end |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/order_reporter_test.rb | Ruby | mit | 235 | main | 1,289 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class OrderReporterTest < Minitest::Test
include ReporterTestHelper
def setup
@reporter = OrderReporter.new(path: log_path)
end
def test_start
@reporter.start
@reporter.report
assert_equal [], File.re... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/lazy_test_discovery_test.rb | Ruby | mit | 235 | main | 2,156 | # frozen_string_literal: true
require 'test_helper'
require 'minitest/queue/lazy_test_discovery'
require 'zlib'
module Minitest::Queue
class LazyTestDiscoveryTest < Minitest::Test
def test_load_error_generates_deterministic_test_id
loader = CI::Queue::FileLoader.new
resolver = CI::Queue::ClassResolve... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/local_requeue_reporter_test.rb | Ruby | mit | 235 | main | 547 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class LocalRequeueReporterTest < Minitest::Test
include ReporterTestHelper
def setup
@reporter = LocalRequeueReporter.new(verbose: true)
end
def test_message_for_requeued_failure_without_backtrace
test = result('... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/build_status_reporter_test.rb | Ruby | mit | 235 | main | 3,166 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class BuildStatusReporterTest < Minitest::Test
include ReporterTestHelper
include QueueHelper
def setup
@redis_url = ENV.fetch('REDIS_URL', 'redis://localhost:6379/0')
@redis = ::Redis.new(url: @redis_url)
@redi... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/test_time_recorder_test.rb | Ruby | mit | 235 | main | 1,260 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class TestTimeRecorderTest < Minitest::Test
def setup
redis_url = ENV.fetch('REDIS_URL', 'redis://localhost:6379/0')
redis = Redis.new(url: redis_url)
redis.flushdb
config ||= CI::Queue::Configuration.new(
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/failure_formatter_test.rb | Ruby | mit | 235 | main | 366 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class FailureFormatterTest < Minitest::Test
include ReporterTestHelper
def test_failure_formatter_to_h_can_be_json_dumped
test = result('test_json', failure: "\xD6".b)
formatter = FailureFormatter.new(test)
asser... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/lazy_entry_resolver_test.rb | Ruby | mit | 235 | main | 1,908 | # frozen_string_literal: true
require 'test_helper'
require 'minitest/queue/lazy_entry_resolver'
module Minitest::Queue
class LazyEntryResolverTest < Minitest::Test
def test_builds_lazy_single_example_for_regular_entry
loader = CI::Queue::FileLoader.new
resolver = CI::Queue::ClassResolver
entry... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/worker_profile_reporter_test.rb | Ruby | mit | 235 | main | 2,149 | # frozen_string_literal: true
require 'test_helper'
require 'stringio'
require 'minitest/queue/worker_profile_reporter'
module Minitest::Queue
class WorkerProfileReporterTest < Minitest::Test
def test_print_summary_is_silent_without_debug_env
profiles = {
'0' => { 'worker_id' => '0', 'mode' => 'laz... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/build_status_recorder_test.rb | Ruby | mit | 235 | main | 7,337 | # frozen_string_literal: true
require 'test_helper'
require 'concurrent/set'
module Minitest::Queue
class BuildStatusRecorderTest < Minitest::Test
include ReporterTestHelper
def setup
@redis_url = ENV.fetch('REDIS_URL', 'redis://localhost:6379/0')
@redis = ::Redis.new(url: @redis_url)
@red... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/lazy_single_example_test.rb | Ruby | mit | 235 | main | 6,620 | # frozen_string_literal: true
require 'test_helper'
module Minitest::Queue
class LazySingleExampleTest < Minitest::Test
def test_run_executes_test
Dir.mktmpdir do |dir|
class_name = "LazyExample#{Process.pid}#{rand(1000)}"
file_path = File.join(dir, "lazy_example_test.rb")
File.writ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/queue/test_time_reporter_test.rb | Ruby | mit | 235 | main | 1,937 | # frozen_string_literal: true
require 'test_helper'
module Minitest
module Queue
class TimeReporterTest < Minitest::Test
include OutputTestHelpers
def test_report_no_offending_tests
build = mock_build({'some test': [0.01, 0.02, 0.2]})
reporter = TestTimeReporter.new(build: build, lim... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/reporters/statsd_reporter_test.rb | Ruby | mit | 235 | main | 1,796 | # frozen_string_literal: true
require 'test_helper'
require 'minitest/reporters/statsd_reporter'
module Minitest::Reporters
class StatsdReporterTest < Minitest::Test
include ReporterTestHelper
class FakeStatsD
attr_reader :increments
def initialize(*)
@increments = {}
end
d... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/test/minitest/reporters/junit_reporter_test.rb | Ruby | mit | 235 | main | 7,983 | # frozen_string_literal: true
require "test_helper"
require "minitest/reporters/junit_reporter"
module Minitest::Reporters
class JUnitReporterTest < Minitest::Test
include ReporterTestHelper
def setup
@reporter = Minitest::Queue::JUnitReporter.new
end
def test_generate_junitxml_for_passing_te... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue.rb | Ruby | mit | 235 | main | 17,543 | # frozen_string_literal: true
require 'shellwords'
require 'minitest'
require 'minitest/reporters'
require 'concurrent/map'
require 'minitest/queue/failure_formatter'
require 'minitest/queue/error_report'
require 'minitest/queue/local_requeue_reporter'
require 'minitest/queue/build_status_recorder'
require 'minitest/q... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/test_data_reporter.rb | Ruby | mit | 235 | main | 892 | # frozen_string_literal: true
require 'minitest/reporters'
require 'fileutils'
require 'json'
require 'minitest/queue/test_data'
module Minitest
module Queue
class TestDataReporter < Minitest::Reporters::BaseReporter
def initialize(report_path: 'log/test_data.json', base_path: nil, namespace: '')
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/junit_reporter.rb | Ruby | mit | 235 | main | 4,959 | # frozen_string_literal: true
require 'minitest/reporters'
require 'rexml/document'
require 'fileutils'
module Minitest
module Queue
class JUnitReporter < Minitest::Reporters::BaseReporter
include ::CI::Queue::OutputHelpers
def initialize(report_path = ENV.fetch("CI_QUEUE_MINITEST_JUNITXML", 'log/j... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/grind_recorder.rb | Ruby | mit | 235 | main | 1,547 | # frozen_string_literal: true
module Minitest
module Queue
class GrindRecorder < Minitest::Reporters::BaseReporter
attr_accessor :test_count
def self.counters
@counters ||= {
'failures' => 0,
'errors' => 0,
'skips' => 0,
'test_count' => 0
}
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/build_status_reporter.rb | Ruby | mit | 235 | main | 8,330 | # frozen_string_literal: true
module Minitest
module Queue
class BuildStatusReporter < Minitest::Reporters::BaseReporter
include ::CI::Queue::OutputHelpers
class JUnitReporter
def initialize(file, error_reports)
@file = file
@error_reports = error_reports
end
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/test_time_recorder.rb | Ruby | mit | 235 | main | 428 | # frozen_string_literal: true
module Minitest
module Queue
class TestTimeRecorder < Minitest::Reporters::BaseReporter
def initialize(build:, **options)
super(options)
@build = build
end
def record(test)
return unless test.passed?
test_duration_in_milliseconds = t... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/runner.rb | Ruby | mit | 235 | main | 29,694 | # frozen_string_literal: true
require 'optparse'
require 'json'
require 'fileutils'
require 'minitest/queue'
require 'ci/queue'
require 'digest/md5'
require 'minitest/reporters/bisect_reporter'
require 'minitest/reporters/statsd_reporter'
require 'minitest/queue/queue_population_strategy'
require 'minitest/queue/worker... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/lazy_test_discovery.rb | Ruby | mit | 235 | main | 5,528 | # frozen_string_literal: true
require 'set'
require 'zlib'
module Minitest
module Queue
class LazyTestDiscovery
def initialize(loader:, resolver:)
@loader = loader
@resolver = resolver
end
def enumerator(files)
Enumerator.new do |yielder|
each_test(files) do ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/worker_profile_reporter.rb | Ruby | mit | 235 | main | 2,778 | # frozen_string_literal: true
module Minitest
module Queue
class WorkerProfileReporter
def initialize(supervisor, out: $stdout)
@supervisor = supervisor
@out = out
end
def print_summary
return unless CI::Queue.debug?
expected = @supervisor.workers_count
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/order_reporter.rb | Ruby | mit | 235 | main | 716 | # frozen_string_literal: true
require 'minitest/reporters'
class Minitest::Queue::OrderReporter < Minitest::Reporters::BaseReporter
def initialize(options = {})
@path = options.delete(:path)
@file = nil
@flush_every = Integer(ENV.fetch('CI_QUEUE_ORDER_FLUSH_EVERY', '50'))
@flush_every = 1 if @flush_e... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/build_status_recorder.rb | Ruby | mit | 235 | main | 2,285 | # frozen_string_literal: true
require 'minitest/reporters'
module Minitest
module Queue
class BuildStatusRecorder < Minitest::Reporters::BaseReporter
COUNTERS = %w(
assertions
errors
failures
skips
requeues
total_time
).freeze
class << self
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/test_time_reporter.rb | Ruby | mit | 235 | main | 1,850 | # frozen_string_literal: true
require 'minitest/reporters'
module Minitest
module Queue
class TestTimeReporter < Minitest::Reporters::BaseReporter
include ::CI::Queue::OutputHelpers
def initialize(build:, limit: nil, percentile: nil, **options)
super(options)
@test_time_hash = build.... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/statsd.rb | Ruby | mit | 235 | main | 2,044 | # frozen_string_literal: true
# Implements a small and limited StatsD implementation to reduce importing unnecessary dependencies because
# we don't want to require on the bundle which would slow down a CI Queue run
require 'socket'
module Minitest
module Queue
class Statsd
attr_reader :addr, :namespace, ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/grind_reporter.rb | Ruby | mit | 235 | main | 1,732 | # frozen_string_literal: true
require 'minitest/reporters'
module Minitest
module Queue
class GrindReporter < Minitest::Reporters::BaseReporter
include ::CI::Queue::OutputHelpers
def initialize(build:, **options)
@build = build
@success = true
super(options)
end
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/lazy_entry_resolver.rb | Ruby | mit | 235 | main | 1,819 | # frozen_string_literal: true
module Minitest
module Queue
class LazyEntryResolver
def initialize(loader:, resolver:)
@loader = loader
@resolver = resolver
end
def call(entry)
parsed = CI::Queue::QueueEntry.parse(entry)
class_name, method_name = parsed.fetch(:te... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/test_data.rb | Ruby | mit | 235 | main | 4,222 | # frozen_string_literal: true
require 'minitest/reporters'
require 'fileutils'
module Minitest
module Queue
class TestData
attr_reader :namespace, :test_index
def initialize(test:, index:, namespace:, base_path:)
@test = test
@base_path = base_path
@namespace = namespace
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/failure_formatter.rb | Ruby | mit | 235 | main | 1,624 | # frozen_string_literal: true
require 'delegate'
require 'ci/queue/output_helpers'
module Minitest
module Queue
class FailureFormatter < SimpleDelegator
include ::CI::Queue::OutputHelpers
def initialize(test)
@test = test
super
end
def to_s
s = +"#{header}\n#{bod... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/local_requeue_reporter.rb | Ruby | mit | 235 | main | 1,621 | # frozen_string_literal: true
require 'ci/queue/output_helpers'
require 'minitest/reporters'
module Minitest
module Queue
class LocalRequeueReporter < Minitest::Reporters::DefaultReporter
include ::CI::Queue::OutputHelpers
attr_accessor :requeues
def initialize(*)
self.requeues = 0
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/error_report.rb | Ruby | mit | 235 | main | 1,595 | # frozen_string_literal: true
module Minitest
module Queue
class ErrorReport
class << self
attr_accessor :coder
def load(payload)
new(coder.load(payload))
end
end
self.coder = Marshal
begin
require 'snappy'
require 'msgpack'
requ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/queue/queue_population_strategy.rb | Ruby | mit | 235 | main | 6,838 | # frozen_string_literal: true
require 'set'
require 'minitest/queue/lazy_entry_resolver'
require 'minitest/queue/lazy_test_discovery'
module Minitest
module Queue
class QueuePopulationStrategy
attr_reader :load_tests_duration, :total_files
def initialize(queue:, queue_config:, argv:, test_files_fil... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/reporters/statsd_reporter.rb | Ruby | mit | 235 | main | 1,246 | # frozen_string_literal: true
require 'minitest/queue'
require 'minitest/queue/statsd'
require 'minitest/reporters'
module Minitest
module Reporters
class StatsdReporter < Minitest::Reporters::BaseReporter
FAILING_INFRASTRUCTURE_THRESHOLD = 10
attr_reader :statsd
def initialize(statsd: Minite... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/minitest/reporters/bisect_reporter.rb | Ruby | mit | 235 | main | 363 | # frozen_string_literal: true
require 'minitest/reporters'
module Minitest
module Reporters
class BisectReporter < BaseReporter
include RelativePosition
def record(test)
super
test_name = "#{test.klass}##{test.name}"
print pad_test(test_name)
puts pad_mark(result(test... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/rspec/queue.rb | Ruby | mit | 235 | main | 15,729 | # frozen_string_literal: true
require 'fileutils'
require 'delegate'
require 'rspec/core'
require 'ci/queue'
require 'rspec/queue/build_status_recorder'
require 'rspec/queue/order_recorder'
require 'rspec/queue/error_report'
module RSpec
module Queue
class << self
def config
@config ||= CI::Queue::... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/rspec/queue/error_report.rb | Ruby | mit | 235 | main | 1,685 | # frozen_string_literal: true
module RSpec
module Queue
class ErrorReport
class << self
attr_accessor :coder
def load(payload)
new(coder.load(payload))
end
end
# Default to Marshal
self.coder = Marshal
# Try to use SnappyPack if available from con... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/rspec/queue/build_status_recorder.rb | Ruby | mit | 235 | main | 1,055 | # frozen_string_literal: true
require 'rspec/queue/failure_formatter'
require 'rspec/queue/error_report'
module RSpec
module Queue
class BuildStatusRecorder
::RSpec::Core::Formatters.register self, :example_passed, :example_failed
class << self
attr_accessor :build
attr_accessor :fai... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/rspec/queue/order_recorder.rb | Ruby | mit | 235 | main | 528 | # frozen_string_literal: true
require 'rspec/core/formatters/base_formatter'
module RSpec
module Queue
class OrderRecorder < ::RSpec::Core::Formatters::BaseFormatter
::RSpec::Core::Formatters.register self, :example_started
def initialize(*)
super
output.sync = true
end
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/rspec/queue/failure_formatter.rb | Ruby | mit | 235 | main | 1,230 | # frozen_string_literal: true
require 'delegate'
require 'ci/queue/output_helpers'
module RSpec
module Queue
class FailureFormatter < SimpleDelegator
include ::CI::Queue::OutputHelpers
def initialize(notification)
@notification = notification
super
end
def to_s
[... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue.rb | Ruby | mit | 235 | main | 2,304 | # 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 ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/version.rb | Ruby | mit | 235 | main | 233 | # frozen_string_literal: true
module CI
module Queue
VERSION = '0.92.0'
DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
end
end |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/queue_entry.rb | Ruby | mit | 235 | main | 1,546 | # frozen_string_literal: true
require 'base64'
require 'json'
module CI
module Queue
module QueueEntry
LOAD_ERROR_PREFIX = '__ciq_load_error__:'.freeze
def self.test_id(entry)
JSON.parse(entry, symbolize_names: true)[:test_id]
end
def self.parse(entry)
JSON.parse(entry,... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/configuration.rb | Ruby | mit | 235 | main | 7,527 | # frozen_string_literal: true
module CI
module Queue
class Configuration
attr_accessor :timeout, :worker_id, :max_requeues, :grind_count, :failure_file, :export_flaky_tests_file
attr_accessor :requeue_tolerance, :namespace, :failing_test, :statsd_endpoint
attr_accessor :max_test_duration, :max_t... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/circuit_breaker.rb | Ruby | mit | 235 | main | 1,537 | # frozen_string_literal: true
module CI
module Queue
module CircuitBreaker
module Disabled
extend self
def report_failure!
end
def report_success!
end
def open?
false
end
def message
''
end
end
class... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/output_helpers.rb | Ruby | mit | 235 | main | 1,375 | # frozen_string_literal: true
module CI
module Queue
module OutputHelpers
private
def step(*args, **kwargs)
ci_provider.step(*args, **kwargs)
end
def reopen_previous_step
ci_provider.reopen_previous_step
end
def close_previous_step
ci_provider.close_p... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/file_loader.rb | Ruby | mit | 235 | main | 2,508 | # frozen_string_literal: true
require 'set'
module CI
module Queue
class FileLoader
attr_reader :load_stats
def initialize
@loaded_files = Set.new
@failed_files = {}
@pid = Process.pid
@forked = false
@load_stats = {}
@loaded_features = nil
end
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/bisect.rb | Ruby | mit | 235 | main | 1,245 | # frozen_string_literal: true
module CI
module Queue
class Bisect
def initialize(path, config)
@tests = ::File.readlines(path).map(&:strip).reject(&:empty?).take_while { |t| t != config.failing_test }
@config = config
end
def size
@tests.size
end
def populat... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/class_resolver.rb | Ruby | mit | 235 | main | 926 | # frozen_string_literal: true
module CI
module Queue
module ClassResolver
def self.resolve(class_name, file_path: nil, loader: nil)
klass = try_direct_lookup(class_name)
return klass if klass
if file_path && loader
loader.load_file(file_path)
klass = try_direct_... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/static.rb | Ruby | mit | 235 | main | 4,736 | # frozen_string_literal: true
require 'concurrent/set'
module CI
module Queue
class Static
include Common
class << self
def from_uri(uri, config)
tests = uri.opaque.split(':').map { |t| CGI.unescape(t) }
new(tests, config)
end
end
TEN_MINUTES = 60 * 1... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/common.rb | Ruby | mit | 235 | main | 779 | # frozen_string_literal: true
module CI
module Queue
module Common
attr_reader :config
# to override in classes including this module
CONNECTION_ERRORS = [].freeze
def distributed?
raise NotImplementedError
end
def retrying?
false
end
def release... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/file.rb | Ruby | mit | 235 | main | 395 | # frozen_string_literal: true
require 'ci/queue/static'
module CI
module Queue
class File < Static
class << self
def from_uri(uri, config)
new(uri.path, config)
end
end
def initialize(path, *args)
io = path == '-' ? STDIN : ::File.open(path)
super(io.e... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/build_record.rb | Ruby | mit | 235 | main | 1,469 | # frozen_string_literal: true
module CI
module Queue
class BuildRecord
attr_reader :error_reports
def initialize(queue)
@queue = queue
@error_reports = {}
@stats = {}
end
def progress
@queue.progress
end
def queue_exhausted?
@queue.exh... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis.rb | Ruby | mit | 235 | main | 724 | # frozen_string_literal: true
gem "redis", "~> 5.0"
require 'redis'
require 'ci/queue/redis/build_record'
require 'ci/queue/redis/base'
require 'ci/queue/redis/worker'
require 'ci/queue/redis/grind_record'
require 'ci/queue/redis/grind'
require 'ci/queue/redis/retry'
require 'ci/queue/redis/supervisor'
require 'ci/que... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/grind.rb | Ruby | mit | 235 | main | 794 | # frozen_string_literal: true
require 'ci/queue/static'
module CI
module Queue
class Grind < Static
class << self
def from_uri(uri, config)
new(uri.path, config)
end
end
# Grind always eagerly loads test files and populates @index via
# Static#populate, so poll ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/grind_supervisor.rb | Ruby | mit | 235 | main | 230 | # frozen_string_literal: true
module CI
module Queue
module Redis
class GrindSupervisor < Supervisor
def build
@build ||= GrindRecord.new(self, redis, config)
end
end
end
end
end |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/grind.rb | Ruby | mit | 235 | main | 301 | # frozen_string_literal: true
module CI
module Queue
module Redis
class Grind < Worker
def build
@build ||= GrindRecord.new(self, redis, config)
end
def supervisor
GrindSupervisor.new(redis_url, config)
end
end
end
end
end |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/monitor.rb | Ruby | mit | 235 | main | 4,514 | #!/usr/bin/env -S ruby --disable-gems
# typed: false
# frozen_string_literal: true
require 'logger'
require 'redis'
require 'json'
module CI
module Queue
module Redis
class Monitor
DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../../redis', __FILE__)
RELEASE_SCRIPTS_ROOT = ::File.expa... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/grind_record.rb | Ruby | mit | 235 | main | 1,682 | # frozen_string_literal: true
module CI
module Queue
module Redis
class GrindRecord
def initialize(queue, redis, config)
@queue = queue
@redis = redis
@config = config
end
def record_error(payload)
redis.pipelined do |pipeline|
pi... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/test_time_record.rb | Ruby | mit | 235 | main | 1,657 | # frozen_string_literal: true
module CI
module Queue
module Redis
class TestTimeRecord < Worker
def record(test_name, duration)
record_test_time(test_name, duration)
record_test_name(test_name)
end
def fetch
fetch_all_test_names.each_with_object({}) do ... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/base.rb | Ruby | mit | 235 | main | 12,095 | # frozen_string_literal: true
module CI
module Queue
module Redis
class Base
include Common
TEN_MINUTES = 60 * 10
CONNECTION_ERRORS = [
::Redis::BaseConnectionError,
::SocketError, # https://github.com/redis/redis-rb/pull/631
].freeze
DEFAULT_TIM... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/build_record.rb | Ruby | mit | 235 | main | 8,202 | # frozen_string_literal: true
module CI
module Queue
module Redis
class BuildRecord
def initialize(queue, redis, config)
@queue = queue
@redis = redis
@config = config
end
def progress
@queue.progress
end
def queue_exhausted?
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/supervisor.rb | Ruby | mit | 235 | main | 2,570 | # frozen_string_literal: true
module CI
module Queue
module Redis
class Supervisor < Base
def master?
false
end
def total
wait_for_master(timeout: config.queue_init_timeout, allow_streaming: true)
redis.get(key('total')).to_i
end
def b... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/worker.rb | Ruby | mit | 235 | main | 15,814 | # frozen_string_literal: true
require 'ci/queue/static'
require 'concurrent/set'
require 'concurrent/map'
module CI
module Queue
module Redis
class << self
attr_accessor :requeue_offset
attr_accessor :max_sleep_time
end
self.requeue_offset = 42
self.max_sleep_time = 2
... |
github | Shopify/ci-queue | https://github.com/Shopify/ci-queue | ruby/lib/ci/queue/redis/retry.rb | Ruby | mit | 235 | main | 1,948 | # frozen_string_literal: true
module CI
module Queue
module Redis
class Retry < Static
def initialize(tests, config, redis:)
@redis = redis
super(tests, config)
end
def build
@build ||= CI::Queue::Redis::BuildRecord.new(self, redis, config)
end
... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | api_struct.gemspec | Ruby | mit | 235 | master | 1,456 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'api_struct/version'
Gem::Specification.new do |spec|
spec.name = 'api_struct'
spec.version = ApiStruct::VERSION
spec.authors = %w[bezrukavyi andy1341 kirillshevch]
spec.email ... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | spec/spec_helper.rb | Ruby | mit | 235 | master | 678 | require 'bundler/setup'
require 'api_struct'
require 'vcr'
require 'webmock/rspec'
require 'ffaker'
Dir[File.expand_path('spec/support/**/*.rb')].each { |file| require file }
WebMock.disable_net_connect!(allow_localhost: true)
VCR.configure do |config|
config.cassette_library_dir = 'spec/fixtures/cassettes'
conf... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | spec/api_struct/client_spec.rb | Ruby | mit | 235 | master | 4,628 | describe ApiStruct::Client do
extend Support::Stub
API_ROOT = 'https://jsonplaceholder.typicode.com'
let(:api_root) { API_ROOT }
stub_api(API_ROOT)
let(:client) { StubClient.new }
class StubClient < ApiStruct::Client
stub_api :posts
def show(id)
get(id)
end
def update(id, params)
... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | spec/api_struct/entity_spec.rb | Ruby | mit | 235 | master | 5,494 | describe ApiStruct::Entity do
extend Support::Stub
stub_api('https://jsonplaceholder.typicode.com')
class StubClient < ApiStruct::Client
stub_api 'posts'
def show(id)
get(id)
end
def index(params = {})
get(json: params)
end
end
class StubNestedEntity < ApiStruct::Entity
... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | spec/support/stub.rb | Ruby | mit | 235 | master | 213 | module Support
module Stub
def stub_api(root, params = {})
ApiStruct::Settings.configure do |config|
config.endpoints = { stub_api: { root: root, params: params } }
end
end
end
end |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct.rb | Ruby | mit | 235 | master | 583 | require 'http'
require 'dry/monads/result'
require 'dry-configurable'
require 'dry/inflector'
require 'json'
require 'hashie'
require_relative 'api_struct/version'
require_relative 'api_struct/settings'
require_relative 'api_struct/concerns/underscore'
require_relative 'api_struct/extensions/api_client'
require_relati... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct/client.rb | Ruby | mit | 235 | master | 2,451 | module ApiStruct
class Client
DEFAULT_HEADERS = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
URL_OPTION_REGEXP = /\/:([a-z_]+)/.freeze
attr_reader :client
def self.method_missing(method_name, *args, &block)
endpoints = Settings.config.endpoints
ret... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct/entity.rb | Ruby | mit | 235 | master | 2,330 | module ApiStruct
class Entity < SimpleDelegator
extend Extensions::DryMonads
extend Extensions::ApiClient
class << self
def entity_attributes
@entity_attributes ||= []
end
def attr_entity(*attrs, &block)
entity_attributes.concat attrs
attrs.each do |attr|
... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct/collection.rb | Ruby | mit | 235 | master | 418 | module ApiStruct
class Collection < SimpleDelegator
attr_reader :collection
def initialize(collection, entity_klass)
raise EntityError, 'Collection must be a Array' unless collection.is_a? Array
@collection = collection.map { |item| entity_klass.convert_to_entity(item) }
__setobj__(@collect... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct/extensions/dry_monads.rb | Ruby | mit | 235 | master | 527 | module ApiStruct
module Extensions
module DryMonads
def from_monad(monad)
monad
.fmap { |v| from_success(v) }.or_fmap { |e| from_failure(e) }.value!
end
def from_success(value)
return Dry::Monads::Success(nil) if value.nil?
value.is_a?(Array) ? collection(valu... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct/extensions/api_client.rb | Ruby | mit | 235 | master | 1,364 | module ApiStruct
module Extensions
module ApiClient
include Concerns::Underscore
REJECTED_METHODS = %i[api_root default_path headers]
attr_reader :clients
def client_service(*services, **options)
@clients ||= {}
services.each { |service| register_service(service, options... |
github | rubygarage/api_struct | https://github.com/rubygarage/api_struct | lib/api_struct/errors/client.rb | Ruby | mit | 235 | master | 867 | module ApiStruct
module Errors
class Client
attr_reader :status, :body, :error
def initialize(response)
if response.is_a?(Hash)
@status = response[:status]
@body = response[:body]
else
@status = response.status
@body = parse_body(response.body.t... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | unsplash.gemspec | Ruby | mit | 235 | master | 1,352 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'unsplash/version'
Gem::Specification.new do |spec|
spec.name = "unsplash"
spec.version = Unsplash::VERSION
spec.authors = ["Aaron Klaassen"]
spec.email = ["aa... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash.rb | Ruby | mit | 235 | master | 530 | require "oauth2"
require "httparty"
require "delegate"
require "unsplash/version"
require "unsplash/configuration"
require "unsplash/errors"
require "unsplash/client"
require "unsplash/connection"
require "unsplash/user"
require "unsplash/photo"
require "unsplash/collection"
require "unsplash/stats"
require "unsplash/... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/errors.rb | Ruby | mit | 235 | master | 310 | module Unsplash # :nodoc:
# Raised when there is an error communicating with Unsplash.
class Error < StandardError; end
# Raise for deprecation errors
class DeprecationError < Error; end
class UnauthorizedError < Error; end
class ForbiddenError < Error; end
class NotFoundError < Error; end
end |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/stats.rb | Ruby | mit | 235 | master | 299 | module Unsplash # :nodoc:
# Retrieve Unsplash stats
class Stats < Client
class << self
# Get a list of statistics regardling Unsplash as a whole.
# @return [Hash] The numbers.
def total
JSON.parse(connection.get("/stats/total").body)
end
end
end
end |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/client.rb | Ruby | mit | 235 | master | 2,036 | module Unsplash # :nodoc:
# Common functionality across Unsplash API objects.
class Client
# Build an Unsplash object with the given attributes.
# @param attrs [Hash]
def initialize(attrs = {})
@attributes = OpenStruct.new(attrs)
add_utm_to_links
end
# (Re)load full object details... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/search.rb | Ruby | mit | 235 | master | 970 | module Unsplash # :nodoc:
# Decorates Array of klass-type objects with total and total_pages attributes
class SearchResult < SimpleDelegator
attr_reader :total, :total_pages
def initialize(decorated, klass)
@total = decorated["total"]
@total_pages = decorated["total_pages"]
list = decor... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/photo.rb | Ruby | mit | 235 | master | 4,946 | module Unsplash # :nodoc:
# Unsplash Photo operations.
class Photo < Client
def initialize(attrs)
super
add_utm_to_urls
end
# Like a photo for the current user.
# @return [Boolean] True if successful. Will raise on error.
def like!
connection.post("/photos/#{id}/like")
... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/connection.rb | Ruby | mit | 235 | master | 6,050 | require 'faraday/multipart'
module Unsplash #:nodoc:
# HTTP connection to and communication with the Unsplash API.
class Connection
include HTTParty
# The version of the API being used if unspecified.
DEFAULT_VERSION = "v1"
# Base URI for the Unsplash API..
DEFAULT_API_BASE_URI = "https:/... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/user.rb | Ruby | mit | 235 | master | 3,022 | module Unsplash # :nodoc:
# Unsplash User operations.
class User < Client
class << self
# Get a user.
# @param username [String] the username of the user to retrieve.
# @return [Unsplash::User] the Unsplash User.
def find(username)
new JSON.parse(connection.get("/users/#{usern... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/configuration.rb | Ruby | mit | 235 | master | 391 | module Unsplash # :nodoc:
class Configuration # :nodoc:
attr_accessor :application_access_key
attr_accessor :application_secret
attr_accessor :application_redirect_uri
attr_accessor :logger
attr_accessor :utm_source
attr_writer :test
def initialize
@test = true
@logger = Log... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | lib/unsplash/collection.rb | Ruby | mit | 235 | master | 5,235 | module Unsplash # :nodoc:
# Unsplash Collection operations.
class Collection < Client
class << self
# Get a specific collection.
# @param id [Integer] The ID of the collection.
# @return [Unsplash::Collection] The requested collection.
def find(id)
Unsplash::Collection.new JSO... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/spec_helper.rb | Ruby | mit | 235 | master | 2,095 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'unsplash'
require 'vcr'
require 'pry'
require 'coveralls'
require 'dotenv'
Coveralls.wear!
Dotenv.load("config.env")
Unsplash.configure do |config|
config.application_access_key = ENV["UNSPLASH_ACCESS_KEY"]
config.application_secret = ENV["UNSPLAS... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/unsplash_spec.rb | Ruby | mit | 235 | master | 843 | require 'spec_helper'
describe Unsplash do
it "has a version number" do
expect(Unsplash::VERSION).not_to be nil
end
it "logs warning response headers" do
response = double(body: "[]", status: 200, headers: { "Warning" => "Watch out!" })
allow(Unsplash::Connection).to receive(:get).and_return(respons... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/lib/collection_spec.rb | Ruby | mit | 235 | master | 5,973 | require "spec_helper"
describe Unsplash::Collection do
let (:collection_id) { 201 }
let (:fake_id) { 987654321 }
describe "#find" do
it "returns a Collection object" do
VCR.use_cassette("collections") do
collection = Unsplash::Collection.find(collection_id)
expect(collection).to be_a... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/lib/connection_spec.rb | Ruby | mit | 235 | master | 3,340 | require "spec_helper"
describe Unsplash::Connection do
let(:connection) { Unsplash::Client.connection }
describe "utm params", utm: true do
before :each do
response = double("response", status: 200, headers: {})
allow(Unsplash::Connection).to receive(:get).and_return(response)
Unsplash.conf... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/lib/user_spec.rb | Ruby | mit | 235 | master | 4,803 | require "spec_helper"
describe Unsplash::User do
let (:regularjoe) { "aaron_is_just_so_handsome" }
let (:photographer) { "lukechesser" }
let (:fake) { "unfortunately_there_is_no_santa" }
describe "#find" do
it "returns as User object" do
VCR.use_cassette("users") do
@user = Unsplash::User.... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/lib/photo_spec.rb | Ruby | mit | 235 | master | 5,812 | require "spec_helper"
describe Unsplash::Photo do
describe "#find" do
let(:photo_id) { "tAKXap853rY" }
let(:fake_id) { "abc123" }
it "returns a Photo object" do
VCR.use_cassette("photos") do
photo = Unsplash::Photo.find(photo_id)
expect(photo).to be_a Unsplash::Photo
end
... |
github | unsplash/unsplash_rb | https://github.com/unsplash/unsplash_rb | spec/lib/stats_spec.rb | Ruby | mit | 235 | master | 296 | require "spec_helper"
describe Unsplash::Stats do
describe "#total" do
it "returns the stats" do
VCR.use_cassette("stats") do
counts = Unsplash::Stats.total
expect(counts).to be_a(Hash)
expect(counts.values).to all be_a(Numeric)
end
end
end
end |
github | delano/rye | https://github.com/delano/rye | rye.gemspec | Ruby | mit | 235 | master | 3,127 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "rye"
s.version = "0.9.13"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_ve... |
github | delano/rye | https://github.com/delano/rye | Rakefile | Ruby | mit | 235 | master | 1,604 | require "rubygems"
require "rake"
require "rake/clean"
require "rdoc/task"
task :default => ["build"]
CLEAN.include [ 'pkg', 'doc', 'rdoc' ]
name = "rye"
key = '/etc/certs/gem-private_key.pem';
$:.unshift File.join(File.dirname(__FILE__), 'lib')
require name
version = Rye::VERSION.to_s
begin
require "jeweler"
Je... |
github | delano/rye | https://github.com/delano/rye | lib/esc.rb | Ruby | mit | 235 | master | 10,628 | # escape.rb - escape/unescape library for several formats
#
# Copyright (C) 2006,2007 Tanaka Akira <akr@fsij.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.