mirror of
https://github.com/dev-sec/linux-baseline
synced 2024-11-26 04:50:21 +00:00
update rake tasks
This commit is contained in:
parent
dc702f3671
commit
018233362d
1 changed files with 12 additions and 32 deletions
44
Rakefile
44
Rakefile
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env rake
|
||||
# encoding: utf-8
|
||||
|
||||
require 'rake'
|
||||
require 'rspec/core/rake_task'
|
||||
require 'rake/testtask'
|
||||
require 'rubocop/rake_task'
|
||||
|
||||
# Rubocop
|
||||
|
@ -10,37 +10,17 @@ task :rubocop do
|
|||
RuboCop::RakeTask.new
|
||||
end
|
||||
|
||||
# Lint the cookbook
|
||||
desc 'Run linters'
|
||||
task :run_all_linters => [:rubocop] # rubocop:disable Style/HashSyntax
|
||||
task :default => :run_all_linters # rubocop:disable Style/HashSyntax
|
||||
# lint the project
|
||||
desc 'Run robocop linter'
|
||||
task lint: [:rubocop]
|
||||
|
||||
# Serverspec tests
|
||||
suites = Dir.glob('*').select { |entry| File.directory?(entry) }
|
||||
# run tests
|
||||
task default: [:lint, 'test:check']
|
||||
|
||||
class ServerspecTask < RSpec::Core::RakeTask
|
||||
attr_accessor :target
|
||||
|
||||
def spec_command
|
||||
if target.nil?
|
||||
puts 'specify either env TARGET_HOST or target_host='
|
||||
exit 1
|
||||
end
|
||||
|
||||
cmd = super
|
||||
"env TARGET_HOST=#{target} STANDALONE_SPEC=true #{cmd} --format documentation --no-profile"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :serverspec do
|
||||
suites.each do |suite|
|
||||
desc "Run serverspec suite #{suite}"
|
||||
ServerspecTask.new(suite.to_sym) do |t|
|
||||
t.rspec_opts = '--no-color --format html --out report.html' if ENV['format'] == 'html'
|
||||
t.rspec_opts = '--no-color --format json --out report.json' if ENV['format'] == 'json'
|
||||
t.target = ENV['TARGET_HOST'] || ENV['target_host']
|
||||
t.ruby_opts = "-I #{suite}/serverspec"
|
||||
t.pattern = "#{suite}/serverspec/*_spec.rb"
|
||||
end
|
||||
namespace :test do
|
||||
# run inspec check to verify that the profile is properly configured
|
||||
task :check do
|
||||
dir = File.join(File.dirname(__FILE__))
|
||||
sh("bundle exec inspec check #{dir}")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue