forked from jzhu2009/csharp-cloudfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile.rb
115 lines (96 loc) · 3.12 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
require 'rubygems'
require 'albacore'
require "Properties.rb"
require "fileutils"
desc "compiles, runs tests and creates zip file"
task :all => [:default]
desc "compiles, runs tests and creates zip file"
task :default => [:compile, :tests, :zip]
################
# COMPILE THE CODE
################
desc "Update the version information for the build"
assemblyinfo :assemblyinfo do |asm|
puts "The build number is #{RELEASE_BUILD_NUMBER}"
asm.version = RELEASE_BUILD_NUMBER
asm.company_name = COMPANY
asm.product_name = PRODUCT
asm.description = DESCRIPTION
asm.copyright = COPYRIGHT
asm.output_file = COMMON_ASSEMBLY_INFO
end
desc "Compiles the app"
msbuild :compile => :assemblyinfo do |msb|
msb.command = MSBUILD_EXE
msb.properties :configuration => COMPILE_TARGET
msb.targets :Rebuild
msb.verbosity = "minimal"
msb.solution = SLN_FILE
end
################
# RUN TESTS
################
desc "Run integration and unit tests"
task :tests => [:unit_tests, :integration_tests]
desc "Run unit tests"
nunit :unit_tests => :compile do |nunit|
nunit.command = NUNIT_CMD_EXE
nunit.assemblies UNIT_TESTS_DLL
nunit.options '/xml=csharp-cloudfiles-unit-tests-results.xml'
end
desc "Run integration tests"
nunit :integration_tests => :compile do |nunit|
if ENV['CRED_FILE_LOC']
puts "ENVIRONMENT VARIABLE: #{ENV['CRED_FILE_LOC']}"
puts "copying file from #{ENV['CRED_FILE_LOC']} to #{INTEGRATION_TESTS_CONFIG_FILE}"
copy(ENV['CRED_FILE_LOC'], INTEGRATION_TESTS_CONFIG_FILE)
end
if !File.exists?(INTEGRATION_TESTS_CONFIG_FILE)
if File.exists?("#{ABSOLUTE_PATH}/Credentials.config")
puts "copying file from #{ABSOLUTE_PATH}/Credentials.config to #{INTEGRATION_TESTS_CONFIG_FILE}"
copy("#{ABSOLUTE_PATH}/Credentials.config", INTEGRATION_TESTS_CONFIG_FILE)
exit
end
puts "Credentials.config file does not exist. Please run 'rake create_credentials_config'"
exit
end
nunit.command = NUNIT_CMD_EXE
nunit.assemblies INTEGRATION_TESTS_DLL
nunit.options '/xml=csharp-cloudfiles-integration-tests-results.xml'
end
########################
# CREATING ZIP FILES
########################
desc "Create a binary zip"
zip do |zip|
puts "CREATING ZIP"
Dir.mkdir BUILDS_DIR if !File.directory?(BUILDS_DIR)
file = "#{ZIP_FILE_PREFIX}-bin-#{RELEASE_BUILD_NUMBER}.zip"
File.delete(file) if File.exists?(file)
zip.output_path = BUILDS_DIR
zip.directories_to_zip CORE_DLL_DIR
zip.output_file = file
puts "ZIP CREATION COMPLETE"
end
##################
# CONFIG FILE
##################
desc "create credentials config template file"
task :create_credentials_config do
credentialsConfigTemplateBuilder = IntegrationTestsCredentialsFilesBuilder.new
credentialsConfigTemplateBuilder.write
end
class IntegrationTestsCredentialsFilesBuilder
def write
template = %q{<?xml version="1.0" encoding="utf-8"?>
<credentials>
<username>PUT USERNAME HERE</username>
<api_key>PUT API KEY HERE</api_key>
</credentials>
}.gsub(/^ /, '')
erb = ERB.new(template, 0, "%<>")
File.open("#{ABSOLUTE_PATH}/Credentials.config", 'w') do |file|
file.puts erb.result(binding)
end
end
end