Sha256: f3988b136005ef531b779d1e585b250f7ca82eb69d0a9d0ef3240db734f6d269

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

module Knapsack
  module Config
    class Env
      class << self
        def report_path
          ENV['KNAPSACK_REPORT_PATH']
        end

        def ci_node_total
          ENV['CI_NODE_TOTAL'] || ENV['CIRCLE_NODE_TOTAL'] || ENV['SEMAPHORE_THREAD_COUNT'] || ENV['BUILDKITE_PARALLEL_JOB_COUNT'] || ENV['SNAP_WORKER_TOTAL'] || 1
        end

        def ci_node_index
          ENV['CI_NODE_INDEX'] || ENV['CIRCLE_NODE_INDEX'] || semaphore_current_thread || ENV['BUILDKITE_PARALLEL_JOB'] || snap_ci_worker_index || 0
        end

        def test_file_pattern
          ENV['KNAPSACK_TEST_FILE_PATTERN']
        end

        def test_dir
          ENV['KNAPSACK_TEST_DIR']
        end

        def log_level
          {
            "debug" => Knapsack::Logger::DEBUG,
            "info"  => Knapsack::Logger::INFO,
            "warn"  => Knapsack::Logger::WARN,
          }[ENV['KNAPSACK_LOG_LEVEL']] || Knapsack::Logger::INFO
        end

        private

        def index_starting_from_one(index)
          index.to_i - 1 if index
        end

        def semaphore_current_thread
          index_starting_from_one(ENV['SEMAPHORE_CURRENT_THREAD'])
        end

        def snap_ci_worker_index
          index_starting_from_one(ENV['SNAP_WORKER_INDEX'])
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
knapsack-1.16.0 lib/knapsack/config/env.rb
knapsack-1.15.0 lib/knapsack/config/env.rb
knapsack-1.14.1 lib/knapsack/config/env.rb
knapsack-1.14.0 lib/knapsack/config/env.rb
knapsack-1.13.3 lib/knapsack/config/env.rb
knapsack-1.13.2 lib/knapsack/config/env.rb
knapsack-1.13.1 lib/knapsack/config/env.rb
knapsack-1.13.0 lib/knapsack/config/env.rb