Adds hooks to MRSK. Currently just two hooks, pre-build and post-push. We could break the build and push into two separate commands if we found the need for post-build and/or pre-push hooks. Hooks are stored in `.mrsk/hooks`. Running `mrsk init` will now create that folder and add sample hook scripts. Hooks returning non-zero exit codes will abort the current command. Further potential work here: - We could replace the audit broadcast command with a post-deploy/post-rollback hook or similar - Maybe provide pre-command/post-command hooks that run after every mrsk invocation - Also look for hooks in `~/.mrsk/hooks`
31 lines
879 B
Ruby
31 lines
879 B
Ruby
require "test_helper"
|
|
|
|
class CliTestCase < ActiveSupport::TestCase
|
|
setup do
|
|
ENV["VERSION"] = "999"
|
|
ENV["RAILS_MASTER_KEY"] = "123"
|
|
ENV["MYSQL_ROOT_PASSWORD"] = "secret123"
|
|
Object.send(:remove_const, :MRSK)
|
|
Object.const_set(:MRSK, Mrsk::Commander.new)
|
|
end
|
|
|
|
teardown do
|
|
ENV.delete("RAILS_MASTER_KEY")
|
|
ENV.delete("MYSQL_ROOT_PASSWORD")
|
|
ENV.delete("VERSION")
|
|
end
|
|
|
|
private
|
|
def fail_hook(hook)
|
|
@executions = []
|
|
Mrsk::Commands::Hook.any_instance.stubs(:hook_exists?).returns(true)
|
|
|
|
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
|
|
.with { |*args| @executions << args; args != [".mrsk/hooks/#{hook}"] }
|
|
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
|
|
.with { |*args| args.first == ".mrsk/hooks/#{hook}" }
|
|
.raises(SSHKit::Command::Failed.new("failed"))
|
|
end
|
|
|
|
end
|