Skip to content

Instantly share code, notes, and snippets.

@holysugar
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holysugar/9541922 to your computer and use it in GitHub Desktop.
Save holysugar/9541922 to your computer and use it in GitHub Desktop.
Dockerfile 等の変更を検知して自動ビルド→テスト(serverspec); notify は趣味で書き換え
# 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