summaryrefslogtreecommitdiffstats
path: root/Rakefile
blob: f6ffd8ffe38fa32acb22f28e6fd3664c7912aadd (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Rakefile for Puppet -*- ruby -*-

$: << File.expand_path('lib')

require './lib/puppet.rb'
require 'rake'
require 'rake/packagetask'
require 'rake/gempackagetask'

FILES = FileList[
    '[A-Z]*',
    'install.rb',
    'bin/**/*',
    'sbin/**/*',
    'lib/**/*',
    'conf/**/*',
    'man/**/*',
    'examples/**/*',
    'ext/**/*',
    'test/**/*',
    'spec/**/*'
]

task :default do
    sh %{rake -T}
end

spec = Gem::Specification.new do |spec|
    spec.platform = Gem::Platform::RUBY
    spec.name = 'puppet'
    spec.files = FILES.to_a
    spec.version = Puppet::PUPPETVERSION
    spec.summary = 'Puppet, an automated configuration management tool'
    spec.author = 'Reductive Labs'
    spec.email = 'puppet@reductivelabs.com'
    spec.homepage = 'http://reductivelabs.com'
    spec.rubyforge_project = 'puppet'
    spec.has_rdoc = true
    spec.rdoc_options <<
        '--title' <<  'Puppet - Configuration Management' <<
        '--main' << 'README' <<
        '--line-numbers'
end

Rake::PackageTask.new("puppet", Puppet::PUPPETVERSION) do |pkg|
    pkg.package_dir = 'pkg'
    pkg.need_tar_gz = true
    pkg.package_files = FILES.to_a
end

Rake::GemPackageTask.new(spec) do |pkg|
end

task :tracdocs do
    require 'puppet'
    require 'puppet/util/reference'
    Puppet::Util::Reference.references.each do |ref|
        sh "puppetdoc -m trac -r #{ref.to_s}"
    end
end

desc "Run the specs under spec/"
task :spec do
    require 'spec'
    require 'spec/rake/spectask'
    begin
        require 'rcov'
    rescue LoadError
    end

    Spec::Rake::SpecTask.new do |t|
        t.spec_opts = ['--format','s', '--loadby','mtime']
        t.spec_files = FileList['spec/**/*.rb']
        if defined?(Rcov)
            t.rcov = true
            t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*']
        end
     end
end

desc "Run the unit tests"
task :unit do
    sh "cd test; rake"
end

desc "Prep CI RSpec tests"
task :ci_prep do
    require 'rubygems'
    begin
        gem 'ci_reporter'
        require 'ci/reporter/rake/rspec'
        require 'ci/reporter/rake/test_unit'
        ENV['CI_REPORTS'] = 'results'
    rescue LoadError
       puts 'Missing ci_reporter gem. You must have the ci_reporter gem installed to run the CI spec tests'
    end
end

desc "Run the CI RSpec tests"
task :ci_spec => [:ci_prep, 'ci:setup:rspec'] do
    sh "cd spec; rake all; exit 0"
end

desc "Run CI Unit tests"
task :ci_unit => [:ci_prep, 'ci:setup:testunit'] do
    sh "cd test; rake test; exit 0"
end

desc "Send patch information to the puppet-dev list"
task :mail_patches do
    if Dir.glob("00*.patch").length > 0
        raise "Patches already exist matching '00*.patch'; clean up first"
    end

    unless %x{git status} =~ /On branch (.+)/
        raise "Could not get branch from 'git status'"
    end
    branch = $1

    unless branch =~ %r{^([^\/]+)/([^\/]+)/([^\/]+)$}
        raise "Branch name does not follow <type>/<parent>/<name> model; cannot autodetect parent branch"
    end

    type, parent, name = $1, $2, $3

    # Create all of the patches
    sh "git format-patch -C -M -s -n --subject-prefix='PATCH/puppet' #{parent}..HEAD"

    # And then mail them out.

    # If we've got more than one patch, add --compose
    if Dir.glob("00*.patch").length > 1
        compose = "--compose"
    else
        compose = ""
    end

    # Now send the mail.
    sh "git send-email #{compose} --no-signed-off-by-cc --suppress-from --to puppet-dev@googlegroups.com 00*.patch"

    # Finally, clean up the patches
    sh "rm 00*.patch"
end

desc "Create a changelog based on your git commits."
task :changelog do
    CHANGELOG_DIR = "#{Dir.pwd}"
    mkdir(CHANGELOG_DIR) unless File.directory?(CHANGELOG_DIR)
    change_body=`git log --pretty=format:'%aD%n%an <%ae>%n%s%n'`
    File.open(File.join(CHANGELOG_DIR, "CHANGELOG.git"), 'w') do |f|
        f << change_body
    end

    # Changelog commit
    `git add #{CHANGELOG_DIR}/CHANGELOG.git`
    `git commit -m "Update CHANGELOG.git"`
end