Skip to content

Commit

Permalink
Way better dev workflow using dev builds and deploying often
Browse files Browse the repository at this point in the history
When deploying an SDK, rake now complains about files it can't delete and retries for a while, then fails. This is a lot better than silently skipping files it can't overwrite, leading to you running out of date builds, which can be very frustrating and demotivational.
  • Loading branch information
SmilyOrg committed Sep 23, 2016
1 parent 86e3058 commit 8fcca2d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ namespace :deploy do
sdk_path = File.join("#{ENV['HOME']}/.loom", "sdks", args[:sdk_version])

# Remove the previous version
FileUtils.rm_rf sdk_path if File.directory? sdk_path
rm_rf_persistent(sdk_path) if File.directory? sdk_path
unzip_file("pkg/loomsdk.zip", sdk_path)

puts "Installing sdk locally for loomcli under the name #{args[:sdk_version]}"
Expand All @@ -764,7 +764,7 @@ namespace :deploy do
sdk_path = File.join("#{ENV['HOME']}/.loom", "sdks", args[:sdk_version])

# Remove the previous version
FileUtils.rm_rf sdk_path if File.directory? sdk_path
rm_rf_persistent(sdk_path) if File.directory? sdk_path
unzip_file("pkg/freesdk.zip", sdk_path)

puts "Installing sdk locally for loomcli under the name #{args[:sdk_version]}"
Expand Down
29 changes: 28 additions & 1 deletion build/libs/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,39 @@ def cp_safe(src, dst)
end
end

def rm_rf_persistent(path)
start_time = nil
time_limit = 60
Dir.glob(path + '/**/*') { |f|
next if File.directory?(f)
while true
begin
File.delete(f)
if start_time
puts "Removed successfully!"
start_time = nil
end
break
rescue SystemCallError => e
break if e.errno == Errno::ENOENT
start_time = Time.now if !start_time
time_left = time_limit - (Time.now - start_time)
throw "Timed out trying to remove #{f}" if time_left < 0
puts e
puts "Unable to remove file, retrying for another #{time_left.ceil}s!"
sleep 1
end
end
}
FileUtils.rm_rf path
end

def unzip_file (file, destination)
Zip::File.open(file) do |zip_file|
zip_file.each do |f|
f_path=File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path) unless File.exist?(f_path)
zip_file.extract(f, f_path)
end
end
end

0 comments on commit 8fcca2d

Please sign in to comment.