Created
January 3, 2014 23:15
-
-
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.
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
#!/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