Sha256: 48a86bf26929f4394e80c887267488df4eabe0babd34f9fb94f445899521d83b

Contents?: true

Size: 999 Bytes

Versions: 13

Compression:

Stored size: 999 Bytes

Contents

require "forwardable"

class Bard::CLI < Thor
  class CI
    def initialize project_name, branch, local: false
      @project_name = project_name
      @branch = branch
      @local = !!local
    end

    attr_reader :project_name, :branch, :runner

    def sha
      @sha ||= `git rev-parse #{branch}`.chomp
    end

    def runner
      @runner ||= choose_runner_class.new(project_name, branch, sha)
    end

    extend Forwardable
    delegate [:run, :exists?, :console, :last_response, :status] => :runner

    def local?
      @local
    end

    def github_actions?
      File.exist?(".github/workflows/ci.yml")
    end

    def jenkins?
      !local? && !github_actions?
    end

    private

    def choose_runner_class
      if local?
        require_relative "./ci/local"
        Local
      elsif github_actions?
        require_relative "./ci/github_actions"
        GithubActions
      elsif jenkins?
        require_relative "./ci/jenkins"
        Jenkins
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bard-0.68.0 lib/bard/ci.rb
bard-0.67.0 lib/bard/ci.rb
bard-0.66.0 lib/bard/ci.rb
bard-0.65.0 lib/bard/ci.rb
bard-0.64.1 lib/bard/ci.rb
bard-0.64.0 lib/bard/ci.rb
bard-0.63.0 lib/bard/ci.rb
bard-0.62.2 lib/bard/ci.rb
bard-0.62.1 lib/bard/ci.rb
bard-0.62.0 lib/bard/ci.rb
bard-0.61.0 lib/bard/ci.rb
bard-0.60.0 lib/bard/ci.rb
bard-0.59.3 lib/bard/ci.rb