Skip to content

Instantly share code, notes, and snippets.

@bknowles
Created January 3, 2014 23:15
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bknowles/8248582 to your computer and use it in GitHub Desktop.
Save bknowles/8248582 to your computer and use it in GitHub Desktop.
Git hook to require code passes "knife cookbook test" and foodcritic tests, before uploading.
#!/usr/bin/env ruby
REPO_PATH = `git rev-parse --show-toplevel`.chomp
COMPONENTS_PATH = "#{REPO_PATH}/cookbooks/components"
PROFILES_PATH="#{REPO_PATH}/cookbooks/profiles"
puts "Running knife cookbook test against all cookbooks in #{COMPONENTS_PATH} and #{PROFILES_PATH}"
knife_output = `$(which knife) cookbook test -a -o #{ COMPONENTS_PATH } #{ PROFILES_PATH }`
unless $?.success?
puts knife_output
exit 1
end
puts "Running foodcritic..."
fc_output = `$(which foodcritic) --epic-fail any #{ COMPONENTS_PATH } #{ PROFILES_PATH } -t ~FC003 -t ~FC015`
unless $?.success?
puts fc_output
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment