-
-
Save nshenry03/7761275 to your computer and use it in GitHub Desktop.
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
# encoding: utf-8 | |
require 'bundler' | |
require 'bundler/setup' | |
require 'thor/foodcritic' | |
require 'berkshelf/thor' | |
begin | |
require 'kitchen/thor_tasks' | |
Kitchen::ThorTasks.new | |
rescue LoadError | |
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] | |
end | |
class Cookbook < Thor | |
include Thor::Actions | |
require 'mixlib/shellout' | |
desc 'foodcritic', 'run foodcritic' | |
def foodcritic | |
f = Mixlib::ShellOut.new('foodcritic .') | |
f.run_command | |
raise "Foodcritic failed: " + f.stderr if f.exitstatus > 0 | |
end | |
desc 'syntax', 'check syntax' | |
def syntax | |
s = Mixlib::ShellOut.new("knife cookbook test -o .. #{File.basename(Dir.pwd)}") | |
s.run_command | |
raise "Syntax check failed: " + s.stderr if s.exitstatus > 0 | |
end | |
require 'tailor/cli' | |
desc "style", "check style" | |
def style | |
::Tailor::Logger.log = false | |
tailor = ::Tailor::CLI.new [] | |
tailor.execute! | |
end | |
desc 'test', 'Run all the tests' | |
def test | |
syntax | |
foodcritic | |
lint | |
invoke 'kitchen:all' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment