-
-
Notifications
You must be signed in to change notification settings - Fork 470
/
Copy pathrakefile.rb
177 lines (134 loc) · 4.27 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
require 'json'
# bumping the CI
COMPILE_TARGET = ENV['config'].nil? ? "debug" : ENV['config']
RESULTS_DIR = "results"
BUILD_VERSION = '3.0.0'
CONNECTION = ENV['connection']
tc_build_number = ENV["BUILD_NUMBER"]
build_revision = tc_build_number || Time.new.strftime('5%H%M')
build_number = "#{BUILD_VERSION}.#{build_revision}"
BUILD_NUMBER = build_number
task :ci => [:connection, :default, :storyteller, 'pack']
task :default => [:mocha, :test, :storyteller]
desc "Prepares the working directory for a new build"
task :clean do
#TODO: do any other tasks required to clean/prepare the working directory
FileUtils.rm_rf RESULTS_DIR
FileUtils.rm_rf 'artifacts'
end
desc "Update the version information for the build"
task :version do
asm_version = build_number
begin
commit = `git log -1 --pretty=format:%H`
rescue
commit = "git unavailable"
end
puts "##teamcity[buildNumber '#{build_number}']" unless tc_build_number.nil?
puts "Version: #{build_number}" if tc_build_number.nil?
options = {
:description => 'Postgresql as a Document Db and Event Store for .Net Development',
:product_name => 'Marten',
:copyright => 'Copyright 2016-17 Jeremy D. Miller et al. All rights reserved.',
:trademark => commit,
:version => asm_version,
:file_version => build_number,
:informational_version => asm_version
}
end
desc 'Builds the connection string file'
task :connection do
File.open('src/Marten.Testing/connection.txt', 'w') do |file|
file.write CONNECTION
end
end
desc 'Runs the Mocha tests'
task :mocha do
sh "npm install"
sh "npm run test"
end
desc 'Compile the code'
task :compile => [:clean, :restore] do
sh "dotnet build src/Marten.Testing/Marten.Testing.csproj --framework netcoreapp2.1 --configuration #{COMPILE_TARGET}"
end
desc 'Run the unit tests'
task :test => [:compile] do
sh 'dotnet test src/Marten.Testing/Marten.Testing.csproj --framework netcoreapp2.1'
end
desc "Launches VS to the Marten solution file"
task :sln do
sh "start src/Marten.sln"
end
desc "Run the storyteller specifications"
task :storyteller => [:compile] do
Dir.chdir("src/Marten.Storyteller") do
system "dotnet storyteller run -r artifacts --culture en-US"
end
end
desc "Run the storyteller specifications"
task :open_st => [:compile] do
Dir.chdir("src/Marten.Storyteller") do
system "dotnet storyteller open --culture en-US"
end
end
"Launches the documentation project in editable mode"
task :docs do
Dir.chdir("tools/stdocs") do
sh "dotnet restore"
sh "dotnet stdocs run -d ../../documentation -c ../../src -v #{BUILD_VERSION}"
end
end
"Exports the documentation to jasperfx.github.io/marten - requires Git access to that repo though!"
task :publish do
FileUtils.remove_dir('doc-target') if Dir.exists?('doc-target')
if !Dir.exists? 'doc-target'
Dir.mkdir 'doc-target'
sh "git clone -b gh-pages https://github.com/jasperfx/marten.git doc-target"
else
Dir.chdir "doc-target" do
sh "git checkout --force"
sh "git clean -xfd"
sh "git pull origin master"
end
end
Dir.chdir("tools/stdocs") do
sh "dotnet restore"
sh "dotnet stdocs export ../../doc-target ProjectWebsite -d ../../documentation -c ../../src --version #{BUILD_VERSION} --project marten"
end
Dir.chdir "doc-target" do
sh "git add --all"
sh "git commit -a -m \"Documentation Update for #{BUILD_VERSION}\" --allow-empty"
sh "git push origin gh-pages"
end
end
desc 'Restores nuget packages'
task :restore do
sh 'dotnet restore src/Marten.sln'
end
desc 'Run Benchmarks'
task :benchmarks => [:restore] do
sh 'dotnet run --project src/MartenBenchmarks --configuration Release'
end
desc 'Record Benchmarks'
task :recordbenchmarks do
if !ENV['profile'].nil?
dir = 'benchmarks/' + ENV['profile']
if Dir.exists? dir
Dir.rmdir dir
end
puts 'Creating directory ' + dir
Dir.mkdir dir;
cp_r 'BenchmarkDotNet.Artifacts/results', dir
end
end
desc 'Build the Nupkg file'
task :pack => [:compile] do
sh "dotnet pack ./src/Marten -o ./../../artifacts --configuration Release"
sh "dotnet pack ./src/Marten.CommandLine -o ./../../artifacts --configuration Release"
end
def load_project_file(project)
File.open(project) do |file|
file_contents = File.read(file, :encoding => 'bom|utf-8')
JSON.parse(file_contents)
end
end