forked from causiq/logary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
232 lines (203 loc) · 8.15 KB
/
Rakefile
File metadata and controls
232 lines (203 loc) · 8.15 KB
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
#encoding: utf-8
require 'bundler/setup'
require 'pathname'
require 'albacore'
require 'albacore/task_types/nugets_pack'
require 'albacore/tasks/versionizer'
require 'albacore/tasks/release'
require './tools/paket_pack'
include ::Albacore::NugetsPack
Configuration = ENV['CONFIGURATION'] || 'Release'
LogaryStrongName = (ENV['LOGARY_STRONG_NAME'] && true) || false
Albacore::Tasks::Versionizer.new :versioning
task :paket_bootstrap do
system 'tools/paket.bootstrapper.exe', clr_command: true unless \
File.exists? 'tools/paket.exe'
end
desc 'restore all nugets as per the packages.config files'
task :restore => :paket_bootstrap do
system 'tools/paket.exe', 'restore', clr_command: true
end
desc 'create assembly infos'
asmver_files :assembly_info => :versioning do |a|
a.files = FileList['**/*proj'] # optional, will find all projects recursively by default
a.attributes assembly_description: 'Logary is a high performance, multi-target logging, metric and health-check library for mono and .Net.',
assembly_configuration: Configuration,
assembly_company: 'Logibit AB',
assembly_copyright: "(c) #{Time.now.year} by 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 = conf.namespace + "AsmVer"
if LogaryStrongName
path = Pathname.new(File.join(FileUtils.pwd, 'tools/logary.snk')).
relative_path_from(Pathname.new(File.join(FileUtils.pwd, 'src', proj.proj_path_base, '..'))).
to_s
conf.change_attributes do |attrs|
attrs[:assembly_key_file] = path unless proj.proj_filename.include? 'csproj' or proj.proj_filename.include? 'Services' or proj.proj_filename.include? 'Tests'
end
end
conf
end
end
task :paket_replace do
sh %{ruby -pi.bak -e "gsub(/module Aether/, 'module Logary.Utils.Aether')" paket-files/xyncro/aether/src/Aether/Aether.fs}
sh %{ruby -pi.bak -e "gsub(/module Chiron/, 'module Logary.Utils.Chiron')" paket-files/xyncro/chiron/src/Chiron/Chiron.fs}
sh %{ruby -pi.bak -e "gsub(/module.* YoLo/, 'module internal Logary.YoLo')" paket-files/haf/YoLo/YoLo.fs}
sh %{ruby -pi.bak -e "gsub(/module Hopac/, 'namespace Logary.Internals')" paket-files/logary/RingBuffer/RingBuffer.fs}
sh %{ruby -pi.bak -e "gsub(/namespace Logary.Facade/, 'namespace Libryy.Logging')" paket-files/logary/logary/src/Logary.Facade/Facade.fs}
sh %{ruby -pi.bak -e "gsub(/namespace Logary.Facade/, 'namespace Cibryy.Logging')" paket-files/logary/logary/src/Logary.CSharp.Facade/Facade.cs}
end
build :clean_sln do |b|
b.target = 'Clean'
b.sln = 'src/v4.sln'
b.prop 'Configuration', Configuration
end
desc 'clean'
task :clean => [:clean_sln] do
FileUtils.rm_rf 'build'
end
def maybe_sign conf
pfx, pass, sign = [
ENV['LOGARY_SIGN_ASSEMBLY_PFX'],
ENV['LOGARY_SIGN_ASSEMBLY_PASSWORD'],
ENV['LOGARY_SIGN_ASSEMBLY'] || File.exists?('./tools/logary.password')
]
if LogaryStrongName
conf.prop 'StrongNameAssembly', 'true'
end
return unless sign
pass ||= File.read 'tools/logary.password'
info 'signing assembly'
if pfx && pass
info 'signing assembly with pfx'
conf.prop 'SignAssemblyPfx', pfx
conf.prop 'SignAssemblyPassword', pass
else
# brew install osslsigncode
info 'signing assembly with spc/pvk'
conf.prop 'SignAssembly', 'true'
conf.prop 'SignAssemblyPassword', pass
end
end
desc 'Perform quick build'
build :build_quick do |b|
b.prop 'Configuration', Configuration
b.sln = 'src/Logary.sln'
maybe_sign b
end
desc 'Perform full build'
task :build => [:versioning, :assembly_info, :restore, :paket_replace, :build_quick]
directory 'build/pkg'
task :nugets_quick => [:versioning, 'build/pkg'] do
projects = FileList['src/**/*.{csproj,fsproj}'].exclude(/Example|Tests|Spec|Rutta|Health|Logary[.]Facade|Logary[.]CSharp[.]Facade|sample|packages/i)
knowns = Set.new(projects.map { |f| Albacore::Project.new f }.map { |p| p.id })
authors = "Henrik Feldt, Logibit AB"
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}
tags logging f# log logs metrics metrics.net measure gauge semantic structured
description Logary is a high performance, multi-target logging, metric and health-check library for mono and .Net.
language en-GB
copyright #{authors}
licenseUrl https://www.apache.org/licenses/LICENSE-2.0.html
projectUrl https://github.com/logary/logary
iconUrl https://raw.githubusercontent.com/logary/logary-assets/master/graphics/LogaryLogoSquare32x32.png
files
#{p.proj_path_base}/#{p.output_dll Configuration} ==\> lib/net452
#{p.proj_path_base}/#{p.output_dll(Configuration).to_s.sub('.dll', '.xml')} ==\> lib/net452
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 'package nugets - finds all projects and package them'
task :nugets => ['build/pkg', :versioning, :build, :nugets_quick]
task :tests_unit do
Dir.glob("src/tests/**/bin/#{Configuration}/*.Tests.exe").
reject { |exe| exe.include? '.DB' }.
keep_if { |exe| !exe.include?('Mailgun') || (ENV['MAILGUN_API_KEY'] && exe.include?('Mailgun')) }.
keep_if { |exe| !exe.include?('ElmahIO') || (ENV['ELMAH_IO_LOG_ID'] && exe.include?('ElmahIO')) }.
keep_if { |exe| !exe.include?('Stackdriver') || (ENV["STACKDRIVER_PROJECT"] && ENV["STACKDRIVER_LOG"] && exe.include?('Stackdriver')) }.
each do |exe|
system exe, %W|--sequenced #{ENV['DEBUG'] ? "--debug" : ""}|, clr_command: true
end
end
desc 'run integration tests'
task :tests_integration do
system "src/tests/Logary.IntegrationTests/bin/#{Configuration}/Logary.IntegrationTests.exe", clr_command: true
end
Albacore::Tasks::Release.new :release,
pkg_dir: 'build/pkg',
depend_on: :nugets,
nuget_exe: 'tools/NuGet.exe',
api_key: ENV['NUGET_KEY']
desc 'push all packages in build/pkg'
task :nugets_push do
Dir.glob 'build/pkg/*.nupkg' do |path|
begin
system 'tools/NuGet.exe',
%W|push #{path} #{ENV['NUGET_KEY']} -source https://api.nuget.org/v3/index.json|,
clr_command: true
rescue => e
error e
end
end
end
test_runner :tests_spec do |tests|
tests.files = FileList['src/tests/Logary.CSharp.Tests/bin/Release/*.Tests.dll']
tests.exe = 'packages\Machine.Specifications.Runner.Console\tools\mspec-clr4.exe'
#tests.add_parameter ''
#tests.native_exe # when you don't want to use 'mono' as the native executable on non-windows systems
end
desc 'run unit tests'
task :tests => [:build, :tests_unit, :tests_spec]
task :default => [:tests, :nugets]
namespace :docs do
task :pre_reqs do
{ 'FAKE' => '2.17.9',
'FSharp.Formatting' => '2.4.10' }.
each do |name, version|
system 'tools/NuGet.exe', %W|
install #{name} -OutputDirectory tools -Version #{version} -ExcludeVersion
|, clr_command: true
end
end
directory 'build/api'
directory 'docs/files'
directory 'docs/content'
desc 'build docs'
task :build => [:pre_reqs, 'docs/files', 'docs/content', 'build/api'] do
system 'tools/FAKE/tools/Fake.exe', 'tools/docs.fsx', clr_command: true
end
# unused!! for reference only
task :build2 => :pre_reqs do
system 'tools/FSharp.Formatting.CommandTool/tools/fsformatting.exe', %w|
metadataFormat --generate
--sourceRepo https://github.com/logary/logary
--sourceFolder /src/Logary
--dllFiles src/Logary/bin/Release/Logary.dll
--outDir docs/output-api
--layoutRoots docs/layouts
--libDirs src/Logary/bin/Release
|, clr_command: true
end
end