1
+ #!/usr/bin/env rake
1
2
# encoding: utf-8
2
3
3
- require 'rake'
4
- require 'rspec/core/rake_task'
4
+ require 'rake/testtask'
5
5
require 'rubocop/rake_task'
6
6
7
7
# Rubocop
@@ -10,37 +10,30 @@ task :rubocop do
10
10
RuboCop ::RakeTask . new
11
11
end
12
12
13
- # Lint the cookbook
14
- desc 'Run linters'
15
- task :run_all_linters => [ :rubocop ] # rubocop:disable Style/HashSyntax
16
- task :default => :run_all_linters # rubocop:disable Style/HashSyntax
13
+ # lint the project
14
+ desc 'Run robocop linter'
15
+ task lint : [ :rubocop ]
17
16
18
- # Serverspec tests
19
- suites = Dir . glob ( '*' ) . select { | entry | File . directory? ( entry ) }
17
+ # run tests
18
+ task default : [ :lint , 'test:check' ]
20
19
21
- class ServerspecTask < RSpec ::Core ::RakeTask
22
- attr_accessor :target
23
-
24
- def spec_command
25
- if target . nil?
26
- puts 'specify either env TARGET_HOST or target_host='
27
- exit 1
28
- end
29
-
30
- cmd = super
31
- "env TARGET_HOST=#{ target } STANDALONE_SPEC=true #{ cmd } --format documentation --no-profile"
20
+ namespace :test do
21
+ # run inspec check to verify that the profile is properly configured
22
+ task :check do
23
+ dir = File . join ( File . dirname ( __FILE__ ) )
24
+ sh ( "bundle exec inspec check #{ dir } " )
32
25
end
33
26
end
34
27
35
- namespace :serverspec do
36
- suites . each do |suite |
37
- desc "Run serverspec suite #{ suite } "
38
- ServerspecTask . new ( suite . to_sym ) do |t |
39
- t . rspec_opts = '--no-color --format html --out report.html' if ENV [ 'format' ] == 'html'
40
- t . rspec_opts = '--no-color --format json --out report.json' if ENV [ 'format' ] == 'json'
41
- t . target = ENV [ 'TARGET_HOST' ] || ENV [ 'target_host' ]
42
- t . ruby_opts = "-I #{ suite } /serverspec"
43
- t . pattern = "#{ suite } /serverspec/*_spec.rb"
44
- end
28
+ # Automatically generate a changelog for this project. Only loaded if
29
+ # the necessary gem is installed.
30
+ # use `rake changelog to=1.2.0`
31
+ begin
32
+ v = ENV [ 'to' ]
33
+ require 'github_changelog_generator/task'
34
+ GitHubChangelogGenerator ::RakeTask . new :changelog do |config |
35
+ config . future_release = v
45
36
end
37
+ rescue LoadError
38
+ puts '>>>>> GitHub Changelog Generator not loaded, omitting tasks'
46
39
end
0 commit comments