Sha256: 7c4a0c2294dcfee4a2eac39dd6f8210cb0cade538adf0df6f0c962987f4e3093

Contents?: true

Size: 982 Bytes

Versions: 4

Compression:

Stored size: 982 Bytes

Contents

require_relative "./base"
require "yaml"
require "active_support/core_ext/enumerable"

module ManageIQ::CrossRepo
  class Runner
    class Github < Base
      CONFIG_FILE = ".github/workflows/ci.yaml".freeze

      def self.available?
        File.exist?(CONFIG_FILE)
      end

      private

      def ci_config
        github_config = YAML.load_file(CONFIG_FILE)

        steps = github_config["jobs"]["ci"]["steps"]
        steps_by_name = steps.index_by { |step| step["name"] }

        language = steps.any? { |s| s["uses"] == "ruby/setup-ruby@v1" } ? "ruby" : "node_js"

        result = {"language" => language}

        result["before_install"] = steps_by_name["Set up system"]["run"] if steps_by_name["Set up system"]
        result["before_script"]  = steps_by_name["Prepare tests"]["run"] if steps_by_name["Prepare tests"]
        result["script"]         = steps_by_name["Run tests"]["run"]     if steps_by_name["Run tests"]

        result
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
manageiq-cross_repo-2.3.0 lib/manageiq/cross_repo/runner/github.rb
manageiq-cross_repo-2.2.0 lib/manageiq/cross_repo/runner/github.rb
manageiq-cross_repo-2.1.0 lib/manageiq/cross_repo/runner/github.rb
manageiq-cross_repo-2.0.0 lib/manageiq/cross_repo/runner/github.rb