Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
Update various root files
Browse files Browse the repository at this point in the history
  • Loading branch information
bflad committed Apr 8, 2014
1 parent 7c7bbb6 commit d48be32
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 33 deletions.
39 changes: 34 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
# Berkshelf
Berksfile.lock
/cookbooks

# Bundler
.bundle
.cache
bin/
Gemfile.lock

# Chef
metadata.json
tmp/

# Editors
*~
*#
.#*
\#*#
.*.sw[a-z]
*.sublime-project
*.sublime-workspace
*.un~

# OS files
.DS_Store

# rbenv
.ruby-version

# Test Kitchen
.kitchen/
.kitchen.local.yml

# Vagrant
.vagrant
Berksfile.lock
Gemfile.lock
\#*#
tmp/

# vagrant-cache
.cache
7 changes: 6 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
AllCops:
Excludes:
Include:
- Berksfile
- Gemfile
- Guardfile
- Rakefile
Exclude:
- test/**
- vendor/**
- ruby/**
Expand Down
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: ruby
bundler_args: --without integration
rvm:
- 1.9.3
bundler_args: --without development
before_script:
- bundle exec berks install
script:
# - bundle exec knife cookbook test -a -o .
- bundle exec foodcritic -f any .
- bundle exec rubocop
script:
- bundle exec rake travis
14 changes: 14 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

# rubocop:disable RegexpLiteral
guard 'kitchen' do
watch(%r{test/.+})
watch(%r{^recipes/(.+)\.rb$})
watch(%r{^attributes/(.+)\.rb$})
watch(%r{^files/(.+)})
watch(%r{^templates/(.+)})
watch(%r{^providers/(.+)\.rb})
watch(%r{^resources/(.+)\.rb})
end
# rubocop:enable RegexpLiteral
74 changes: 52 additions & 22 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,64 @@
#!/usr/bin/env rake

task :default => 'foodcritic'
# Style tests. Rubocop and Foodcritic
namespace :style do
begin
require 'rubocop/rake_task'
desc 'Run Ruby style checks'
Rubocop::RakeTask.new(:ruby)
rescue LoadError
puts '>>>>> Rubocop gem not loaded, omitting tasks' unless ENV['CI']
end

desc "Runs foodcritic linter"
task :foodcritic do
Rake::Task[:prepare_sandbox].execute
begin
require 'foodcritic'

if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
sh "foodcritic -f any #{sandbox_path}"
else
puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any']
}
end
rescue LoadError
puts '>>>>> foodcritic gem not loaded, omitting tasks' unless ENV['CI']
end
end

desc "Runs knife cookbook test"
task :knife do
Rake::Task[:prepare_sandbox].execute

sh "bundle exec knife cookbook test cookbook -c test/.chef/knife.rb -o #{sandbox_path}/../"
end
desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']

task :prepare_sandbox do
files = %w{*.md *.rb attributes definitions libraries files providers recipes resources templates}
# Integration tests. Kitchen.ci
namespace :integration do
begin
require 'kitchen/rake_tasks'

rm_rf sandbox_path
mkdir_p sandbox_path
cp_r Dir.glob("{#{files.join(',')}}"), sandbox_path
desc 'Run kitchen integration tests'
Kitchen::RakeTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
end

private
def sandbox_path
File.join(File.dirname(__FILE__), %w(tmp cookbooks cookbook))
# Unit tests with rspec/chefspec
namespace :unit do
begin
require 'rspec/core/rake_task'
desc 'Run unit tests with RSpec/ChefSpec'
RSpec::Core::RakeTask.new(:rspec) do |t|
t.rspec_opts = [].tap do |a|
a.push('--color')
a.push('--format progress')
end.join(' ')
end
rescue LoadError
puts '>>>>> rspec gem not loaded, omitting tasks' unless ENV['CI']
end
end

task unit: ['unit:rspec']

desc 'Run all tests on Travis'
task travis: %w(style unit)

# Default
task default: ['style', 'unit', 'integration:kitchen:all']

0 comments on commit d48be32

Please sign in to comment.