Skip to content
Newer
Older
100644 169 lines (147 sloc) 4.22 KB
12b18c4 Updated to a newer version of albacore.
Matt Burke authored Oct 5, 2010
1 require 'rubygems'
2 require 'bundler/setup'
891df0f Added a watchr-based autobuilder.
Matt Burke authored Oct 26, 2009
3 require 'albacore'
4 require 'rexml/document'
dce4265 Automated some of the release process. (h/t jeweler)
Matt Burke authored Oct 5, 2010
5 require 'jeweler/version_helper'
6 require 'git'
891df0f Added a watchr-based autobuilder.
Matt Burke authored Oct 26, 2009
7
8 task :default => %W(
9 build
10 runtests
11 )
12
13 def build task_name, *targets
14 build_properties = { :configuration => 'Debug', :platform => 'x86' }
15 build_properties.merge!(targets.pop) if Hash === targets.last
12b18c4 Updated to a newer version of albacore.
Matt Burke authored Oct 5, 2010
16 msbuild task_name do |msb|
891df0f Added a watchr-based autobuilder.
Matt Burke authored Oct 26, 2009
17 msb.properties build_properties
18 msb.targets targets
19 msb.solution = 'GitTfs.sln'
20 end
21 end
22
12b18c4 Updated to a newer version of albacore.
Matt Burke authored Oct 5, 2010
23 task :build => 'build:debug'
24 namespace :build do
25 desc "Build in debug mode"
26 build :debug, 'Build'
27 task :debug
28
29 desc "Build in release mode"
30 build :release, 'Build', :configuration => 'Release'
31 task :release
32 end
33
891df0f Added a watchr-based autobuilder.
Matt Burke authored Oct 26, 2009
34
35 desc 'Run the tests'
36 task :runtests do
37 rm 'results.trx' if File.exist? 'results.trx'
38 mstest_cmd =%W(mstest
39 /testcontainer:GitTfsTest\\bin\\Debug\\GitTfsTest.dll
40 /resultsfile:results.trx)
41 sh(*mstest_cmd) do |ok, status|
42 analyze_tests('results.trx')
43 end
44 end
45
46 def analyze_tests(results_file)
47 fail_count = 0
48 File.open(results_file) do |file|
49 xml =REXML::Document.new(file)
50 xml.elements.each '//UnitTestResult[@outcome="Failed"]' do |e|
51 puts ''
52 puts '**********************************'
53 puts e.attributes['testName']
54 puts e.elements['Output/ErrorInfo/Message'].get_text.value
55 puts e.elements['Output/ErrorInfo/StackTrace'].get_text.value
56 %W(StdOut StdErr).each do |s|
57 show_stream e, s
58 end
59 puts ''
60 fail_count = fail_count.succ
61 end
62 end
63 fail "#{fail_count} tests failed" if fail_count > 0
64 end
65
66 def show_stream(e, s)
67 data = e.elements["Output/#{s}"]
68 if data
69 puts "#{s}:", data.get_text.value
70 end
71 end
dce4265 Automated some of the release process. (h/t jeweler)
Matt Burke authored Oct 5, 2010
72
73
74 desc "Package a release zip"
75 task :release => ['checks:clean_workdir', 'build:release', 'zip:release', 'tag']
76
77 namespace :checks do
78 task :clean_workdir do
79 unless clean_working_dir?
80 system 'git status'
81 raise "Unclean working directory! Be sure to commit or .gitignore everything first!"
82 end
83 end
84 end
85
86 namespace :zip do
87 zip :release do |zip|
88 zip.directories_to_zip 'GitTfs/bin/Release'
89 zip.output_file = "GitTfs-#{version_helper.to_s}.zip"
90 zip.output_path = File.expand_path('../pkg', __FILE__)
91 end
92 task :release => :pkg
93 end
94
95 directory 'pkg'
96
97 def version_helper
98 @version_helper ||= Jeweler::VersionHelper.new(File.dirname(__FILE__))
99 end
100
101 def repo
102 @repo ||= Git.open(File.dirname(__FILE__))
103 end
104
105 def commit opts
106 repo.add opts[:files]
107 repo.commit opts[:message]
108 end
109
110 def clean_working_dir?
4dfba1a Tried to get clean_working_dir? right again. I think this matches jew…
Matt Burke authored Oct 5, 2010
111 `git ls-files --deleted --modified --others --exclude-standard` == ''
dce4265 Automated some of the release process. (h/t jeweler)
Matt Burke authored Oct 5, 2010
112 end
113
3dee062 Make the version task advertise itself on rake -T.
Matt Burke authored Mar 11, 2011
114 desc 'Show the current version'
dce4265 Automated some of the release process. (h/t jeweler)
Matt Burke authored Oct 5, 2010
115 task :version do
116 $stdout.puts "Current version: #{version_helper.to_s}"
117 end
118
119 namespace :version do
120 task :cs do
121 File.open('Version.cs', 'w') do |f|
122 f.puts(
123 'partial class GitTfsProperties',
124 '{',
125 " public const string Version = \"#{version_helper.to_s}\";",
126 '}'
127 )
128 end
129 $stdout.puts 'Wrote Version.cs'
130 Rake::Task['version:cs'].reenable
131 end
132
133 namespace :bump do
134 desc "Bump to next major version"
135 task :major => :version do
136 version_helper.bump_major
137 version_helper.write
138 $stdout.puts "Updated version to #{version_helper.to_s}"
139 Rake::Task['version:cs'].invoke
140 commit(:files => ['VERSION', 'Version.cs'], :message => "Bumped to version #{version_helper.to_s}")
141 end
142 desc "Bump to next minor version"
143 task :minor => :version do
144 version_helper.bump_minor
145 version_helper.write
146 $stdout.puts "Updated version to #{version_helper.to_s}"
147 Rake::Task['version:cs'].invoke
148 commit(:files => ['VERSION', 'Version.cs'], :message => "Bumped to version #{version_helper.to_s}")
149 end
150 desc "Bump to next patch version"
151 task :patch => :version do
152 version_helper.bump_patch
153 version_helper.write
154 $stdout.puts "Updated version to #{version_helper.to_s}"
155 Rake::Task['version:cs'].invoke
156 commit(:files => ['VERSION', 'Version.cs'], :message => "Bumped to version #{version_helper.to_s}")
157 end
158 end
159 end
160
161 task :tag do
162 release_tag = "v#{version_helper.to_s}"
163 tag = repo.tag(release_tag) rescue nil
164 unless tag
165 $stdout.puts "Tagging #{release_tag}"
166 repo.add_tag(release_tag)
167 end
168 end
Something went wrong with that request. Please try again.