module Heroploy::Commands::Checks

Public Instance Methods

check_branch(branch_name, valid_branch, env_name) click to toggle source
# File lib/heroploy/commands/checks.rb, line 22
def check_branch(branch_name, valid_branch, env_name)
  unless branch_name == valid_branch
    raise "Cannot deploy branch #{branch_name} to #{env_name}"
  end
end
check_config(shared_env, env_config) click to toggle source
# File lib/heroploy/commands/checks.rb, line 34
def check_config(shared_env, env_config)
  merged_keys = shared_env.variables.keys.concat(env_config.variables.keys)
  shared_env.required.each do |key|
    unless merged_keys.include?(key)
      raise "Missing config value for '#{key}'"
    end
  end
end
check_pushed(branch_name) click to toggle source
# File lib/heroploy/commands/checks.rb, line 12
def check_pushed(branch_name)
  unless git_remote_has_branch?('origin', branch_name)
    raise "Branch #{branch_name} doesn't exist in origin"
  end

  if git_remote_behind?('origin', branch_name) then
    raise "Branch #{branch_name} is behind origin/#{branch_name}"
  end
end
check_remote(remote) click to toggle source
# File lib/heroploy/commands/checks.rb, line 6
def check_remote(remote)
  unless git_remote_exists?(remote)
    raise "Could not find remote '#{remote}'"
  end
end
check_staged(remote, branch_name, env_name) click to toggle source
# File lib/heroploy/commands/checks.rb, line 28
def check_staged(remote, branch_name, env_name)
  unless git_staged?(remote, branch_name)
    raise "Changes not yet staged on #{env_name}"
  end
end
check_travis(branch_name, travis_repo_name) click to toggle source
# File lib/heroploy/commands/checks.rb, line 43
def check_travis(branch_name, travis_repo_name)
  travis_repo = Travis::Repository.find(travis_repo_name)
  unless travis_repo.branch(branch_name).green?
    raise "Failing Travis build for branch #{branch_name}"
  end
end