/
rakeFile.rb
205 lines (171 loc) · 6.39 KB
/
rakeFile.rb
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
require 'C:/PeninsulaRuby/geminstallations'
require 'C:/PeninsulaRuby/iissetup'
require 'albacore'
require 'colorize'
require 'win32console'
require 'albacore/albacoretask'
require 'open-uri'
srcpath = File.dirname(__FILE__).gsub("/","\\")
task :default => :all
task :push => [:up , :add,:build,:jslint,:test,:acceptancetest]
task :all => [:up,:dbsetup,:build,:create_iis,:test,:acceptancetest]
desc "Create IIS"
iissetup :create_iis do |d|
d.path = "\"#{srcpath}\\BusinessSafe.WebSite\""
d.apppoolname = "businesssafe"
d.pipeline = "Integrated"
d.site = "businesssafe"
d.port = "8070"
d.deploy_to = :website
end
desc "Warmup Sites"
task :warmupsites do
open("http://localhost:8070") do |f|
print "warming business safe \n"
end
open("http://localhost:8072") do |f|
print "warming client data services \n"
end
begin
open("http://localhost:8076") do |f|
print "warming peninsula web \n"
end
open("http://localhost:8074") do |f|
print "warming peninsula maintenance \n"
end
open("http://localhost:8070/checklists") do |f|
print "warming checklists \n"
end
rescue
# handle e
end
end
desc "Build"
msbuild :build do |msb|
msb.properties :configuration => :Debug
msb.targets :Clean, :Build
msb.solution = "BusinessSafe.sln"
end
desc "All Tests"
task :alltests => [:test,:acceptancetest]
desc "Test"
nunit :test do |nunit|
nunit.command = "ThirdParty/NUnit/nunit-console.exe"
nunit.options '/nothread /exclude:finetune'
nunit.assemblies "BusinessSafe.WebSite.Test/bin/Debug/BusinessSafe.WebSite.Tests.dll",
"BusinessSafe.Application.Tests/bin/Debug/BusinessSafe.Application.Tests.dll",
"BusinessSafe.Test.Infrastructure/bin/Debug/BusinessSafe.Test.Infrastructure.dll",
"BusinessSafe.Domain.Tests/bin/Debug/BusinessSafe.Domain.Tests.dll",
"BusinessSafe.Data.Tests/bin/Debug/BusinessSafe.Data.Tests.dll",
"BusinessSafe.Data.Tests/bin/Debug/BusinessSafe.Data.Tests.dll"
end
desc "Acceptance Tests"
nunit :acceptancetest do |nunit|
nunit.command = "ThirdParty/NUnit/nunit-console.exe"
nunit.options '/nothread'
nunit.assemblies "AcceptanceTests/bin/Debug/BusinessSafe.AcceptanceTests.dll"
end
desc "Create the BusinessSafe database known context"
sqlcmd :create_businesssafe_database_known_context do |sql|
script_CreateBusinessSafeDatabaseKnownContext = "SQLScripts\\BusinessSafeBaseData.sql"
server = "(local)\\sql2008r2"
database = "master"
sql.command = "sqlcmd.exe"
sql.server = server
sql.database = database
sql.scripts script_CreateBusinessSafeDatabaseKnownContext
end
desc "Run NCover Console code coverage"
ncoverconsole :coverage do |ncc|
ncc.command = "C:/Program Files/NCover/NCover.Console.exe"
ncc.output :xml => "TestResults/test-coverage.xml"
ncc.exclude_attributes("BusinessSafe.Infrastructure.Attributes.CoverageExcludeAttribute")
ncc.exclude_assemblies("Iesi.Collections.dll","NHibernate.dll","NHibernate.ByteCode.Castle",".*Tests.dll")
nunit = NUnitTestRunner.new("ThirdParty/NUnit/nunit-console.exe")
nunit.options '/noshadow'
nunit.assemblies "BusinessSafe.WebSite.Test/bin/Debug/BusinessSafe.WebSite.Tests.dll",
"BusinessSafe.Application.Tests/bin/Debug/BusinessSafe.Application.Tests.dll",
"BusinessSafe.Test.Infrastructure/bin/Debug/BusinessSafe.Test.Infrastructure.dll",
"BusinessSafe.Domain.Tests/bin/Debug/BusinessSafe.Domain.Tests.dll",
"BusinessSafe.Data.Tests/bin/Debug/BusinessSafe.Data.Tests.dll"
ncc.testrunner = nunit
end
desc "Run a sample NCover Report to check code coverage"
ncoverreport :ncoverreport do |ncr|
print "test"
@xml_coverage = "TestResults/test-coverage.xml"
ncr.command = "C:/Program Files/NCover/NCover.Reporting.exe"
ncr.coverage_files @xml_coverage
fullcoveragereport = NCover::FullCoverageReport.new
fullcoveragereport.output_path = "TestResults"
ncr.reports fullcoveragereport
ncr.required_coverage(
NCover::BranchCoverage.new(:minimum => 10),
NCover::CyclomaticComplexity.new(:maximum => 1)
)
end
desc "Pull and Up"
task :up do
begin
dir = Dir[".hg"]
print "Dir : #{dir}\n".green
if dir.nil?
print 'Local copy of repository does not exists.'.red
else
system "#{"hg pull -u"}"
end
rescue => e
print "Failed because: #{e}".red
end
end
desc "Hg Add"
task :add do
begin
dir = Dir[".hg"]
print "Dir : #{dir}\n".green
if dir.nil?
print 'Local copy of repository does not exists.'.red
else
system "#{"hg add"}"
end
rescue => e
print "Failed because: #{e}".red
end
end
desc "DBDeploy"
task :dbdeploy do
print "Starting DB Deploy...\n".green
system "#{"nant -buildfile:DBDeploy_Local.build "}"
end
task :dbsetup => [:create_initial_db,:dbdeploy,:create_businesssafe_database_known_context]
desc "Create the initial BusinessSafe database"
sqlcmd :create_initial_db do |sql|
script_CreateUser = "SQLScripts\\CREATE Security Login - intranetadmin.sql"
script_CreateBusinessSafe = "SQLScripts\\CREATE BusinessSafe database.localhost_sql2008R2.sql"
script_AddChangeLog = "SQLScripts\\CREATE ChangeLog table - BusinessSafe.sql"
server = "(local)\\sql2008r2"
database = "master"
sql.command = "sqlcmd.exe"
sql.server = server
sql.database = database
sql.scripts script_CreateBusinessSafe, script_CreateUser, script_AddChangeLog
print "BusinessSafe Database has been created successfully!\n".green
end
desc "Check the JavaScript source with JSLint - exit with status 1 if any of the files fail."
task :jslint do
failed_files = []
Dir['BusinessSafe.WebSite/Scripts/BusinessSafe/**/*.js'].each do |fname|
cmd = "ThirdParty/jsl-0.3.0/jsl.exe conf ThirdParty/jsl-0.3.0/jsl.default.conf process #{fname} "
results = %x{#{cmd}}
if String.try_convert(results).include? "0 error(s), 0 warning(s)"
puts "\n#{fname} is valid!".green
else
puts "#{fname} is not valid.".red
puts results.white
failed_files << fname
end
end
if failed_files.size > 0
exit 1
end
end