|
| 1 | +#!/usr/bin/env rake |
| 2 | + |
| 3 | +# Style tests. Rubocop and Foodcritic |
| 4 | +namespace :style do |
| 5 | + begin |
| 6 | + require 'rubocop/rake_task' |
| 7 | + desc 'Run Ruby style checks' |
| 8 | + RuboCop::RakeTask.new(:ruby) |
| 9 | + rescue LoadError |
| 10 | + puts '>>>>> Rubocop gem not loaded, omitting tasks' unless ENV['CI'] |
| 11 | + end |
| 12 | + |
| 13 | + begin |
| 14 | + require 'foodcritic' |
| 15 | + |
| 16 | + desc 'Run Chef style checks' |
| 17 | + FoodCritic::Rake::LintTask.new(:chef) do |t| |
| 18 | + t.options = { |
| 19 | + fail_tags: ['any'] |
| 20 | + } |
| 21 | + end |
| 22 | + rescue LoadError |
| 23 | + puts '>>>>> foodcritic gem not loaded, omitting tasks' unless ENV['CI'] |
| 24 | + end |
| 25 | +end |
| 26 | + |
| 27 | +desc 'Run all style checks' |
| 28 | +task style: ['style:chef', 'style:ruby'] |
| 29 | + |
| 30 | +namespace :unit do |
| 31 | + begin |
| 32 | + require 'rspec/core/rake_task' |
| 33 | + desc 'Runs specs with chefspec.' |
| 34 | + RSpec::Core::RakeTask.new(:rspec) |
| 35 | + rescue LoadError |
| 36 | + puts '>>>>> chefspec gem not loaded, omitting tasks' unless ENV['CI'] |
| 37 | + end |
| 38 | +end |
| 39 | + |
| 40 | +desc 'Run all unit tests' |
| 41 | +task unit: ['unit:rspec'] |
| 42 | + |
| 43 | +# Integration tests. Kitchen.ci |
| 44 | +namespace :integration do |
| 45 | + begin |
| 46 | + require 'kitchen/rake_tasks' |
| 47 | + |
| 48 | + desc 'Run kitchen integration tests' |
| 49 | + Kitchen::RakeTasks.new |
| 50 | + rescue LoadError |
| 51 | + puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] |
| 52 | + end |
| 53 | +end |
| 54 | + |
| 55 | +desc 'Run all tests on Travis' |
| 56 | +task travis: ['style', 'unit'] |
| 57 | + |
| 58 | +# Default |
| 59 | +# task default: ['unit', 'style', 'integration:kitchen:all'] |
| 60 | +task default: ['unit', 'style', 'integration:kitchen:all'] |
0 commit comments