forked from SuaveIO/suave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
313 lines (267 loc) · 9.93 KB
/
Rakefile
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# Encoding: utf-8
require 'bundler/setup'
require 'albacore'
require 'albacore/nuget_model'
require 'albacore/project'
require 'albacore/tools'
require 'albacore/tasks/versionizer'
require 'albacore/tasks/release'
require 'albacore/task_types/nugets_pack'
require 'albacore/task_types/asmver'
require './tools/paket_pack'
require 'semver'
Albacore::Tasks::Versionizer.new :versioning
include ::Albacore::NugetsPack
suave_description = 'Suave is a simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition.'
Configuration = ENV['CONFIGURATION'] || 'Release'
Platform = ENV['MSBUILD_PLATFORM'] || 'Any CPU'
task :paket_files do
sh %{ruby -pi.bak -e "gsub(/module internal YoLo/, 'module internal Suave.Utils.YoLo')" paket-files/haf/YoLo/YoLo.fs}
sh %{ruby -pi.bak -e "gsub(/module internal YoLo/, 'module internal Suave.Utils.YoLo')" paket-files/examples/haf/YoLo/YoLo.fs}
sh %{ruby -pi.bak -e "gsub(/namespace Logary.Facade/, 'namespace Suave.Logging')" paket-files/logary/logary/src/Logary.Facade/Facade.fs}
end
desc "Restore paket.exe"
task :restore_paket do
system 'tools/paket.bootstrapper.exe', clr_command: true unless
File.exists? 'tools/paket.exe'
end
task :paket_restore do
system 'tools/paket.exe', 'restore', clr_command: true
system 'tools/paket.exe', %w|restore group Build|, clr_command: true
end
desc 'Restore all packages'
task :restore => [:restore_paket, :paket_restore, :paket_files]
desc 'create assembly infos'
asmver_files :asmver => :versioning do |a|
a.files = FileList[
'examples/**/*.fsproj',
'src/{Suave,Suave.*,Experimental}/*proj'
]
a.attributes assembly_description: suave_description,
assembly_configuration: Configuration,
assembly_company: 'Suave.io',
assembly_copyright: "(c) #{Time.now.year} by Ademar Gonzalez, Henrik Feldt",
assembly_version: ENV['LONG_VERSION'],
assembly_file_version: ENV['LONG_VERSION'],
assembly_informational_version: ENV['BUILD_VERSION']
a.handle_config do |proj, conf|
conf.namespace = proj.namespace + "Asm"
conf
end
end
task :libs do
unless Albacore.windows?
system "pkg-config --cflags libuv" do |ok, res|
if !ok
raise %{
You seem to be missing `libuv`, which needs to be installed. See https://github.com/SuaveIO/suave#libuv-installation
}
end
end
end
end
desc 'Perform full build'
task :compile => [:libs, :versioning, :restore, :asmver, :compile_quick]
desc 'clean the project'
build :clean do |b|
b.file = 'src/Suave.sln'
b.prop 'Configuration', Configuration
b.target = 'Clean'
end
build :compile_quick do |b|
b.file = 'src/Suave.sln'
b.prop 'Configuration', Configuration
b.prop 'Platform', Platform
end
namespace :dotnetcli do
directory 'tools/coreclr'
dotnet_exe_path = "dotnet" #from PATH
def get_installed_dotnet_version
begin
installed_dotnet_version = `dotnet --version`
return "" unless $?.success?
if installed_dotnet_version.nil? then "" else installed_dotnet_version.strip end
rescue
""
end
end
task :coreclr_binaries => 'tools/coreclr' do
dotnet_version = '1.0.0-preview2-003131'
dotnet_installed_version = get_installed_dotnet_version
# check if required version of .net core sdk is already installed, otherwise download and install it
if dotnet_installed_version == dotnet_version then
puts ".NET Core SDK #{dotnet_version} already installed. Skip install"
dotnet_exe_path = "dotnet"
next
elsif dotnet_installed_version == "" then
puts ".NET Core SDK #{dotnet_version} not found. Downloading and installing in ./tools/coreclr"
else
puts "Found .NET Core SDK #{dotnet_installed_version} but require #{dotnet_version}. Downloading and installing in ./tools/coreclr"
end
case RUBY_PLATFORM
when /darwin/
filename = "dotnet-dev-osx-x64.#{dotnet_version}.tar.gz"
system 'curl',
%W|-o tools/#{filename}
-L https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/#{dotnet_version}/#{filename}| \
unless File.exists? "tools/#{filename}"
system 'tar',
%W|xf tools/#{filename}
--directory tools/coreclr|
when /linux/
filename = "dotnet-dev-ubuntu.14.04-x64.#{dotnet_version}.tar.gz"
system 'curl',
%W|-o tools/#{filename}
-L https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/#{dotnet_version}/#{filename}| \
unless File.exists? "tools/#{filename}"
system 'tar',
%W|xf tools/#{filename}
--directory tools/coreclr|
end
if Albacore.windows?
system 'powershell',
%W|Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile "dotnet_cli_install.ps1"|
system 'powershell',
%W|-ExecutionPolicy Unrestricted ./dotnet_cli_install.ps1 -InstallDir "tools/coreclr" -Channel "preview" -version "#{dotnet_version}"|
end
dotnet_exe_path = "#{Dir.pwd}/tools/coreclr/dotnet"
end
desc 'Restore the CoreCLR binaries'
task :restore => :coreclr_binaries do
Dir.chdir "src" do
system dotnet_exe_path, "restore"
end
end
task :build_lib => :coreclr_binaries do
Dir.chdir "src/Suave" do
system dotnet_exe_path, %W|--verbose build --configuration #{Configuration} -f netstandard1.6|
end
end
desc 'Build Suave and test project'
task :build => [:build_lib]
desc 'Create Suave nugets packages'
task :pack => :coreclr_binaries do
Dir.chdir "src/Suave" do
system dotnet_exe_path, %W|--verbose pack --configuration #{Configuration} --no-build|
end
end
task :do_netcorepackage => [ :restore, :build, :pack ]
desc 'Merge standard and dotnetcli nupkgs; note the need to run :nugets before'
task :merge => :coreclr_binaries do
Dir.chdir("src/Suave") do
version = SemVer.find.format("%M.%m.%p%s")
sourcenupkg = "../../build/pkg/Suave.#{version}.nupkg"
clinupkg = "bin/#{Configuration}/Suave.#{version}-dotnetcli.nupkg"
system dotnet_exe_path, %W|mergenupkg --source "#{sourcenupkg}" --other "#{clinupkg}" --framework netstandard1.6|
end
end
end
namespace :tests do
task :stress_quick do
system "examples/Pong/bin/#{Configuration}/Pong.exe", clr_command: true
end
desc 'run a stress test'
task :stress => [:compile, :stress_quick]
task :unit_quick do
system "src/Suave.Tests/bin/#{Configuration}/Suave.Tests.exe", %w|--sequenced|, clr_command: true
end
desc 'run unit tests'
task :unit => [:compile, :unit_quick]
end
desc 'run all tests (stress, unit)'
task :tests => [:'tests:stress', :'tests:unit']
directory 'build/pkg'
task :create_nuget_quick => [:versioning, 'build/pkg'] do
projects = FileList['src/**/*.fsproj'].exclude(/Tests/)
knowns = Set.new(projects.map { |f| Albacore::Project.new f }.map { |p| p.id })
authors = "Ademar Gonzalez, Henrik Feldt"
projects.each do |f|
p = Albacore::Project.new f
n = create_nuspec p, knowns
d = get_dependencies n
m = %{type file
id #{p.id}
version #{ENV['NUGET_VERSION']}
title #{p.id}
authors #{authors}
owners #{authors}
description #{suave_description}
language en-GB
copyright #{authors}
licenseUrl https://github.com/SuaveIO/Suave/blob/master/COPYING
projectUrl http://suave.io
iconUrl https://raw.githubusercontent.com/SuaveIO/resources/master/images/head_trans.png
files
#{p.proj_path_base}/bin/#{Configuration}/#{p.id}.* ==\> lib/net40
releaseNotes
#{n.metadata.release_notes.each_line.reject{|x| x.strip == ""}.join}
dependencies
#{d}
}
begin
File.open("paket.template", "w") do |template|
template.write m
end
system "tools/paket.exe", %w|pack output build/pkg|, clr_command: true
ensure
File.delete "paket.template"
end
end
end
desc 'create suave nuget'
task :nugets => ['build/pkg', :versioning, :compile, :create_nuget_quick]
desc 'create suave nuget with .NET Core'
task :nugets_with_netcore => [:nugets, 'dotnetcli:do_netcorepackage', 'dotnetcli:merge']
desc 'compile, gen versions, test and create nuget'
task :appveyor => [:compile, :'tests:unit', :nugets_with_netcore]
desc 'compile, gen versions, test'
task :default => [:compile, :'tests:unit', :'docs:build']
task :increase_version_number do
# inc patch version in .semver
s = SemVer.find
s.minor += 1
s.save
version = s.format("%M.%m.%p%s")
ENV['NUGET_VERSION'] = version
projectjson = 'src/Suave/project.json'
contents = File.read(projectjson).gsub(/"version": ".*-dotnetcli"/, %{"version": "#{version}-dotnetcli"})
File.open(projectjson, 'w') do |out|
out << contents
end
end
namespace :docs do
desc 'clean generated documentation'
task :clean do
FileUtils.rm_rf 'docs/_site' if Dir.exists? 'docs/_site'
end
task :reference => :restore_paket do
# Last worked in 0a0851f
# 'System.Exception: Failed to escape text properly: []'
#system 'packages/docs/FsLibTool/tools/FsLibTool.exe', %W|src docs/_site|, clr_command: true
puts "Reference docs generated successfully."
end
task :jekyll do
Dir.chdir 'docs' do
Bundler.with_clean_env do
system 'bundle'
system 'bundle exec jekyll build'
end
end
end
desc 'build documentation'
task :build => [:clean, :restore_paket, :jekyll, :reference]
desc 'deploy the suave.io site'
task :deploy => :build do
# In ~/.ssh/config:
# Host suave.io
# User suaveio
# IdentityFile ~/.ssh/suaveio_deployer
system %{rsync -crvz --delete-after --exclude server --delete-excluded docs/_site/ [email protected]:}
end
end
task :docs => :'docs:build'
Albacore::Tasks::Release.new :release,
pkg_dir: 'build/pkg',
depend_on: [:compile, :nugets_with_netcore, :'docs:deploy'],
nuget_exe: 'packages/build/NuGet.CommandLine/tools/NuGet.exe',
api_key: ENV['NUGET_KEY']