Last active
August 29, 2015 13:57
-
-
Save holysugar/9541922 to your computer and use it in GitHub Desktop.
Dockerfile 等の変更を検知して自動ビルド→テスト(serverspec); notify は趣味で書き換え
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: ft=ruby | |
# Run me with: | |
# ovservr build.observr | |
# ovservr については https://github.com/kevinburke/observr | |
require 'terminal-notifier-guard' | |
def notify(message, succeeded = true) | |
type = succeeded ? "success" : "failed" | |
system("terminal-notifier-#{type} -message '#{message}' -title 'Docker'") | |
end | |
def build(name) | |
puts name | |
result = system("bundle exec docker build -t #{name} dockerfiles/#{name}") | |
notify("build #{name}", result) | |
result | |
end | |
def spec(name) | |
result = system("bundle exec rspec #{name}") | |
notify("spec #{name}", result) | |
result | |
end | |
def spec_dir(name) | |
result = system("bundle exec rspec spec/#{name}/*_spec.rb") | |
notify("spec #{name}", result) | |
result | |
end | |
def spec_all | |
result = system("bundle exec rake spec") | |
notify("spec all", result) | |
result | |
end | |
watch( 'dockerfiles/(.*)/(.*)' ) {|md| build(md[1]) && spec_dir(md[1]) } | |
watch( 'spec/.*/.*_spec.rb' ) {|md| spec(md[0]) } | |
watch( 'spec/spec_helper.rb' ) {|md| spec_all } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment