-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRakefile
218 lines (177 loc) · 7.48 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
require 'rubygems'
require 'rubygems/package_task'
require 'ci/reporter/rake/rspec'
require 'rake'
require 'rspec/core/rake_task'
require 'rake/clean'
require 'rake/testtask'
require 'pathname'
require 'zip'
require File.expand_path("#{File.expand_path(File.dirname(__FILE__))}/lib/squeak-ci/build")
require File.expand_path("#{File.expand_path(File.dirname(__FILE__))}/lib/squeak-ci/version")
CLEAN.include('target')
FU = FileUtils::Verbose
#FU = FileUtils
task :default => :test
# Take the base CI image and move it into a (possibly newly) prepared test
# environment in the target/ directory.
task :build do
TEST_IMAGE_NAME = "Squeak4.6"
assert_target_dir
os_name = identify_os
cog_vm = assert_cog_vm(os_name)
interpreter_vm = assert_interpreter_vm(os_name)
puts "Cog VM at #{cog_vm}" if cog_vm
puts "Interpreter VM at #{interpreter_vm}" if interpreter_vm
raise "No VMs!" if !cog_vm && !interpreter_vm
FU.cp("#{TEST_IMAGE_NAME}.image", "#{SRC}/target/#{TRUNK_IMAGE}.image")
FU.cp("#{TEST_IMAGE_NAME}.changes", "#{SRC}/target/#{TRUNK_IMAGE}.changes")
Dir.chdir(TARGET_DIR) {
assert_interpreter_compatible_image(interpreter_vm, TRUNK_IMAGE, os_name)
}
puts "=== BUILD FINISHED"
end
task :spur_build do
TEST_IMAGE_NAME = "Squeak5.1"
assert_target_dir
os_name = identify_os
cog_vm = assert_cog_spur_vm(os_name)
puts "Cog VM at #{cog_vm}" if cog_vm
raise "No VMs!" if !cog_vm
FU.cp("#{TEST_IMAGE_NAME}.image", "#{SRC}/target/#{SPUR_TRUNK_IMAGE}.image")
FU.cp("#{TEST_IMAGE_NAME}.changes", "#{SRC}/target/#{SPUR_TRUNK_IMAGE}.changes")
puts "=== BUILD FINISHED"
end
# Run performance tests on the prepared TrunkImage (regardless of which step
# produced the current test environment).
task :perf => :build do
perf_image = "PerfTest"
os_name = identify_os
cog_vm = assert_cog_vm(os_name)
interpreter_vm = assert_interpreter_vm(os_name)
puts "Cog VM at #{cog_vm}" if cog_vm
puts "Interpreter VM at #{interpreter_vm}" if interpreter_vm
raise "No VMs!" if !cog_vm && !interpreter_vm
Dir.chdir(TARGET_DIR) {
FU.cp("#{TRUNK_IMAGE}.image", "#{perf_image}.image")
FU.cp("#{TRUNK_IMAGE}.changes", "#{perf_image}.changes")
run_image_with_cmd((cog_vm || interpreter_vm), vm_args(os_name), perf_image, "#{SRC}/benchmarks.st")
}
puts "=== PERF FINISHED"
end
# Take the prepared TrunkImage image and update it.
task :update_base_image => :build do
squeak_update_number = latest_downloaded_trunk_version(SRC)
base_name = "#{SQUEAK_VERSION}"
os_name = identify_os
cog_vm = assert_cog_vm(os_name)
interpreter_vm = assert_interpreter_vm(os_name)
puts "Using #{interpreter_vm}"
puts "Preparing to update image of #{base_name} vintage"
squeak_update_number = Dir.chdir(TARGET_DIR) {
run_image_with_cmd((cog_vm || interpreter_vm), vm_args(os_name), TRUNK_IMAGE, "#{SRC}/update-image.st", 25.minutes)
assert_interpreter_compatible_image(interpreter_vm, TRUNK_IMAGE, os_name)
zImage = "#{TRUNK_IMAGE}.zip"
FU.rm(zImage) if File.exist?(zImage)
Zip::File.open(zImage, Zip::File::CREATE) { |z|
['changes', 'image', 'manifest', 'version'].each { |suffix|
fName = "#{TRUNK_IMAGE}.#{suffix}"
z.add(fName, fName) if File.exist?(fName)
}
}
image_version(interpreter_vm, vm_args(os_name), "#{TRUNK_IMAGE}.image")
}
puts "Updated to #{SQUEAK_VERSION}-#{squeak_update_number}"
puts "=== UPDATE_BASE_IMAGE FINISHED"
end
task :spur_update_base_image => :spur_build do
squeak_update_number = latest_downloaded_trunk_version(SRC)
base_name = "#{SQUEAK_VERSION}"
os_name = identify_os
cog_vm = assert_cog_spur_vm(os_name)
puts "Preparing to update image of #{base_name} vintage"
squeak_update_number = Dir.chdir(TARGET_DIR) {
run_image_with_cmd(cog_vm, vm_args(os_name), SPUR_TRUNK_IMAGE, "#{SRC}/update-image.st", 25.minutes)
zImage = "#{TRUNK_IMAGE}.zip"
FU.rm(zImage) if File.exist?(zImage)
Zip::File.open(zImage, Zip::File::CREATE) { |z|
['changes', 'image', 'manifest', 'version'].each { |suffix|
fName = "#{SPUR_TRUNK_IMAGE}.#{suffix}"
z.add(fName, fName) if File.exist?(fName)
}
}
image_version(cog_vm, vm_args(os_name), "#{SPUR_TRUNK_IMAGE}.image")
}
puts "Updated to #{SQUEAK_VERSION}-#{squeak_update_number}"
puts "=== UPDATE_BASE_IMAGE FINISHED"
end
# Take the target/TrunkImage image, run the release process on it, and store it
# in something like target/Squeak4.5.image.
task :release => :build do
os_name = identify_os
interpreter_vm = assert_interpreter_vm(os_name)
cog_vm = assert_cog_vm(os_name)
fail "Cannot release off #{os_name} OS" unless cog_vm
squeak_update_number = image_version(interpreter_vm, vm_args(os_name), "#{SRC}/target/#{TRUNK_IMAGE}.image")
base_name = "#{SQUEAK_VERSION}-#{squeak_update_number}"
puts "Preparing to release image based on #{base_name} (TrunkImage.version says #{File.read("#{SRC}/target/#{TRUNK_IMAGE}.version")})"
FU.cp("#{SRC}/target/#{TRUNK_IMAGE}.image", "#{SRC}/target/ReleaseCandidate.image")
FU.cp("#{SRC}/target/#{TRUNK_IMAGE}.changes", "#{SRC}/target/ReleaseCandidate.changes")
puts "Releasing based off #{base_name}"
run_image_with_cmd(cog_vm, vm_args(os_name), 'ReleaseCandidate', "#{SRC}/release.st", 15.minutes)
assert_interpreter_compatible_image(interpreter_vm, 'ReleaseCandidate', os_name)
squeak_update_number = image_version(interpreter_vm, vm_args(os_name), "#{SRC}/target/ReleaseCandidate.image")
release_name = "#{SQUEAK_VERSION}-#{squeak_update_number}"
FU.cp("#{SRC}/target/ReleaseCandidate.image", "#{SRC}/target/#{release_name}.image")
FU.cp("#{SRC}/target/ReleaseCandidate.changes", "#{SRC}/target/#{release_name}.changes")
puts "Zipping #{release_name}"
FU.rm("#{SRC}/target/#{SQUEAK_VERSION}.zip") if File.exist?("#{SRC}/target/#{SQUEAK_VERSION}.zip")
Zip::File.open("#{SRC}/target/#{SQUEAK_VERSION}.zip", Zip::File::CREATE) { |z|
['changes', 'image'].each { |suffix|
z.add("#{release_name}.#{suffix}", "#{SRC}/target/#{release_name}.#{suffix}")
}
}
puts "=== RELEASE FINISHED"
end
# Take the TrunkImage, release it, and test it.
RSpec::Core::RakeTask.new(:release_and_test => :release) do |test|
test.pattern = 'test/release_test.rb'
test.verbose = true
end
RSpec::Core::RakeTask.new(:test => :build) do |test|
test.rspec_opts = '-fdoc --tag ~interpreter'
test.pattern = 'test/image_test.rb'
test.verbose = true
end
# The rest of the targets don't need to tell us when they're finished, because
# they're not links in the main build pipeline.
RSpec::Core::RakeTask.new(:interpreter_test => :build) do |test|
test.rspec_opts = '-fdoc --tag interpreter'
test.pattern = 'test/image_test.rb'
test.verbose = true
end
RSpec::Core::RakeTask.new(:spur_test => :spur_build) do |test|
test.rspec_opts = '-fdoc'
test.pattern = 'test/spur_image_test.rb'
test.verbose = true
end
RSpec::Core::RakeTask.new(:package_test => :build) do |test|
test.rspec_opts = '-fdoc'
test.pattern = 'test/package_test.rb'
test.verbose = true
end
# Test one package
RSpec::Core::RakeTask.new(:test_package, [:package_name]) do |test, args|
test.rspec_opts = "-fdoc --tag #{args[:package_name]}"
test.pattern = 'test/package_test.rb'
test.verbose = true
end
RSpec::Core::RakeTask.new(:bleeding_edge_test => :build) do |test|
test.pattern = 'test/bleeding_edge_test.rb'
test.verbose = true
end
def image_version(vm, vm_args, image_name)
s = "#{vm} #{vm_args.join(" ")} \"#{image_name}\" #{as_relative_path(Pathname.new(SRC + "/image-version.st"))}"
puts s
`#{s}`.split("\n").last.to_i
end