forked from jsirex/nsupdate-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
executable file
·89 lines (74 loc) · 2.15 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env rake
require 'rake'
require 'rspec/core/rake_task'
require 'ci/reporter/rake/rspec'
cookbook_dir = File.expand_path File.dirname(__FILE__)
ENV['BERKSHELF_PATH'] = cookbook_dir + '/.berkshelf'
ENV['CI_REPORTS'] = cookbook_dir + '/reports'
SKELETON_GIT_REPO = 'https://github.com/jsirex/cookbook-skeleton.git'
task default: 'test:quick'
namespace :test do
RSpec::Core::RakeTask.new(:spec => ["ci:setup:rspec"]) do |t|
t.pattern = Dir.glob('test/spec/**/*_spec.rb')
t.rspec_opts = '--color -f d'
end
begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
begin
require 'foodcritic'
task default: [:foodcritic]
FoodCritic::Rake::LintTask.new do |t|
t.options = { fail_tags: %w/correctness services libraries deprecated/ }
end
rescue LoadError
warn 'Foodcritic Is missing ZOMG'
end
begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.fail_on_error = true
end
rescue LoadError
warn 'Rubocop gem not installed, now the code will look like crap!'
end
desc 'Run all of the quick tests.'
task :quick do
Rake::Task['test:rubocop'].invoke
Rake::Task['test:foodcritic'].invoke
Rake::Task['test:spec'].invoke
end
desc 'Run _all_ the tests. Go get a coffee.'
task :complete do
Rake::Task['test:quick'].invoke
Rake::Task['test:kitchen:all'].invoke
end
desc 'Run CI tests'
task :ci do
Rake::Task['test:complete'].invoke
end
end
desc 'Ensure skeleton files are up to date'
task :skeleton do
begin
require 'git'
g = Git.open('.')
remotes = g.remotes.map { |r| r.name }
rname = 'skeleton'
unless remotes.include?(rname)
puts 'Adding skeleton remote to your repository'
g.add_remote(rname, SKELETON_GIT_REPO)
end
# fetch & merge remote
puts 'fetching latest bones'
g.remote(rname).fetch
puts 'merging remote branch'
sh "git merge -X theirs -m 'skeleton cookbook sync' --squash #{rname}/master"
rescue => e
warn 'The skeletons in your closet are unhappy'
puts e.message
end
end