Class: Simp::Rake::Pupmod::Helpers

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/simp/rake/pupmod/helpers.rb

Overview

Rake tasks for SIMP Puppet modules

Instance Method Summary collapse

Constructor Details

#initialize(base_dir = Dir.pwd) ⇒ Helpers

Returns a new instance of Helpers.


17
18
19
20
21
22
23
24
# File 'lib/simp/rake/pupmod/helpers.rb', line 17

def initialize( base_dir = Dir.pwd )
  @base_dir = base_dir
  Dir[ File.join(File.dirname(__FILE__),'*.rb') ].each do |rake_file|
    next if rake_file == __FILE__
    require rake_file
  end
  define_tasks
end

Instance Method Details

#define_tasksObject


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
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/simp/rake/pupmod/helpers.rb', line 26

def define_tasks
  # These gems aren't always present, for instance
  # on Travis with --without development
  begin
    require 'puppet_blacksmith/rake_tasks'
  rescue LoadError
  end


  # Lint & Syntax exclusions
  exclude_paths = [
    "bundle/**/*",
    "pkg/**/*",
    "dist/**/*",
    "vendor/**/*",
    "spec/**/*",
  ]
  PuppetSyntax.exclude_paths = exclude_paths

  # See: https://github.com/rodjek/puppet-lint/pull/397
  Rake::Task[:lint].clear
  PuppetLint.configuration.ignore_paths = exclude_paths
  PuppetLint::RakeTask.new :lint do |config|
    config.ignore_paths = PuppetLint.configuration.ignore_paths
  end

  Simp::Rake::Fixtures.new( @base_dir )

  Simp::Rake::Pkg.new( @base_dir ) do | t |
    t.clean_list << "#{t.base_dir}/spec/fixtures/hieradata/hiera.yaml"
  end

  Simp::Rake::Beaker.new( @base_dir )

  desc "Run acceptance tests"
  RSpec::Core::RakeTask.new(:acceptance) do |t|
    t.pattern = 'spec/acceptance'
  end

  desc 'Populate CONTRIBUTORS file'
  task :contributors do
    system("git log --format='%aN' | sort -u > CONTRIBUTORS")
  end

  desc 'lint metadata.json'
  task :metadata do
    sh "metadata-json-lint metadata.json"
  end


  desc "Run syntax, lint, and spec tests."
  task :test => [
    :syntax,
    :lint,
    :spec_parallel,
    :metadata,
  ]

  desc "Run parallel spec tests.\nThis will NOT run acceptance tests.\nUse env var `SPEC_clean=yes` to run `:spec_clean` after tests\n"
  task :spec_parallel do
    test_targets = ['spec/classes', 'spec/defines', 'spec/unit', 'spec/functions']
    if ENV['SIMP_PARALLEL_TARGETS']
      test_targets += ENV['SIMP_PARALLEL_TARGETS'].split
    end
    test_targets.delete_if{|dir| !File.directory?(dir)}
    Rake::Task[:spec_prep].invoke
    ParallelTests::CLI.new.run('--type test -t rspec'.split + test_targets)
    if ENV.fetch('SPEC_clean', 'no') == 'yes'
      Rake::Task[:spec_clean].invoke
    end
  end
end