Sha256: bf4218d59ea0bac092e407cd9e242c13afbfbb2e76f67eb827a373ac711497a8

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Datadog
  module CI
    module TestOptimisation
      module SkippablePercentage
        class Base
          attr_reader :failed

          def initialize(verbose: false, spec_path: "spec")
            @verbose = verbose
            @spec_path = spec_path
            @failed = false

            log("Spec path: #{@spec_path}")
            error!("Spec path is not a directory: #{@spec_path}") if !File.directory?(@spec_path)
          end

          def call
            0.0
          end

          private

          def validate_test_optimisation_state!
            unless test_optimisation.enabled
              error!("ITR wasn't enabled, check the environment variables (DD_SERVICE, DD_ENV)")
            end

            if test_optimisation.skippable_tests_fetch_error
              error!("Skippable tests couldn't be fetched, error: #{test_optimisation.skippable_tests_fetch_error}")
            end
          end

          def log(message)
            Datadog.logger.info(message) if @verbose
          end

          def error!(message)
            Datadog.logger.error(message)
            @failed = true
          end

          def test_optimisation
            Datadog.send(:components).test_optimisation
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
datadog-ci-1.13.0 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb
datadog-ci-1.12.0 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb
datadog-ci-1.11.0 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb
datadog-ci-1.10.0 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb
datadog-ci-1.9.0 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb
datadog-ci-1.8.1 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb
datadog-ci-1.8.0 lib/datadog/ci/test_optimisation/skippable_percentage/base.rb