Skip to content

Instantly share code, notes, and snippets.

@aspring
Last active December 20, 2015 19:29
Show Gist options
  • Save aspring/6183936 to your computer and use it in GitHub Desktop.
Save aspring/6183936 to your computer and use it in GitHub Desktop.
A General Guardfile to sit at the head of a Chef Repository. (Caveat: Nearly all of our cookbooks are developed in-house, and all internal cookbooks are prefixed with "devops_", which explains why we limit paths the way we do. We also have an internal cookbook named devops which adds another cog into the mix.)
spec_paths = Dir.glob(File.join("cookbooks", "devops_**", "spec"))
guard :rspec,
:spec_paths => spec_paths,
:cli => "--color --format nested --fail-fast",
all_on_start: false do
# If a spec changes, run it
watch(%r{^cookbooks/devops.*/spec/.+_spec\.rb$})
# If a recipe changes run its spec
watch(%r{^cookbooks/(devops.*)/recipes/(.+)\.rb$}) { |m| "cookbooks/#{m[1]}/spec/#{m[2]}_spec.rb" }
# If spec helper changes run all specs
watch(%r{^cookbooks/(devops.*)/spec/spec_helper\.rb$}) { |m| "cookbooks/#{m[1]}/spec" }
# If any other cookbook paths change, run specs
watch(%r{cookbooks/.+/attributes/.+\.rb$})
watch(%r{cookbooks/.+/providers/.+\.rb$})
watch(%r{cookbooks/.+/resources/.+\.rb$})
watch(%r{cookbooks/.+/templates/.+\.rb$})
watch(%r{cookbooks/.+/metadata\.rb$})
end
guard :foodcritic, :cli => "-I rules", all_on_start: false do
watch(%r{^cookbooks/devops.*/metadata\.rb$})
watch(%r{^cookbooks/devops.*/attributes/.+\.rb$})
watch(%r{^cookbooks/devops.*/providers/.+\.rb$})
watch(%r{^cookbooks/devops.*/recipes/.+\.rb$})
watch(%r{^cookbooks/devops.*/resources/.+\.rb$})
watch(%r{^cookbooks/devops.*/templates/.+\.rb$})
end
guard:bundler do
watch('Gemfile')
end
notification :gntp, :sticky => false, :host => '127.0.0.1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment