diff options
author | Peter Wilmott <p@p8952.info> | 2015-02-26 13:53:41 +0000 |
---|---|---|
committer | Peter Wilmott <p@p8952.info> | 2015-02-26 13:58:42 +0000 |
commit | 694b2abe3d50002f71b2821967acd1baca8b668f (patch) | |
tree | 26719c996b11800cbd6c29f645dd17ac8d47c00f /web | |
parent | Rename from Ruby Stats to Ruby Tinderbox (diff) | |
download | ruby-tinderbox-694b2abe3d50002f71b2821967acd1baca8b668f.tar.gz ruby-tinderbox-694b2abe3d50002f71b2821967acd1baca8b668f.tar.bz2 ruby-tinderbox-694b2abe3d50002f71b2821967acd1baca8b668f.zip |
Use a dedicated container to cache binary packages
Diffstat (limited to 'web')
-rw-r--r-- | web/Rakefile | 29 | ||||
-rw-r--r-- | web/lib/ci.rb | 14 |
2 files changed, 31 insertions, 12 deletions
diff --git a/web/Rakefile b/web/Rakefile index ae1abfe..7f52636 100644 --- a/web/Rakefile +++ b/web/Rakefile @@ -60,37 +60,52 @@ namespace :docker do task :setup do Docker.options[:read_timeout] = 36_000 Docker.options[:write_timeout] = 36_000 + + @volume_image = Docker::Image.build('FROM busybox') + @volume_container = Docker::Container.create( + Image: @volume_image.id, + Volumes: { + '/usr/portage/packages' => { + '/usr/portage/packages' => 'rw' + } + } + ) + @volume_container.start + @volume_container.wait(36_000) + docker_path = File.dirname(File.expand_path(File.dirname(__FILE__))) - @docker_image = Docker::Image.build_from_dir(docker_path) + @ci_image = Docker::Image.build_from_dir(docker_path) end desc 'Remove a previously built docker image' task :teardown do - @docker_image.remove + @ci_image.delete + @volume_container.delete(v: 1) + @volume_image.delete end desc 'Build and test all packages' task :run_ci_all do - run_ci(@docker_image, :all) + run_ci(@volume_container, @ci_image, :all) end desc 'Build and test a fixed number of packages (NUM_OF_PACKAGES=5)' task :run_ci_some do - run_ci(@docker_image, num_of_packages) + run_ci(@volume_container, @ci_image, num_of_packages) end desc 'Build and test all untested packages and their reverse dependencies' task :run_ci_untested do - run_ci(@docker_image, :untested) + run_ci(@volume_container, @ci_image, :untested) end desc 'QA test all packages' task :run_repoman_all do - run_repoman(@docker_image, :all) + run_repoman(@ci_image, :all) end desc 'QA test a fixed number of packages (NUM_OF_PACKAGES=5)' task :run_repoman_some do - run_repoman(@docker_image, num_of_packages) + run_repoman(@ci_image, num_of_packages) end end diff --git a/web/lib/ci.rb b/web/lib/ci.rb index b7a133d..3805b90 100644 --- a/web/lib/ci.rb +++ b/web/lib/ci.rb @@ -1,4 +1,4 @@ -def run_ci(docker_image, num_of_packages) +def run_ci(volume_container, ci_image, num_of_packages) packages = [] Package.order { [category, lower(name), version] }.each do |package| packages << package[:identifier] @@ -32,12 +32,16 @@ def run_ci(docker_image, num_of_packages) packages = packages.uniq packages.each do |package| - docker_container = docker_image.run("/ruby-tinderbox/tinder.sh #{package}") - docker_container.wait(36_000) + ci_container = Docker::Container.create( + Cmd: %W[/ruby-tinderbox/tinder.sh #{package}], + Image: ci_image.id + ) + ci_container.start(VolumesFrom: volume_container.id) + ci_container.wait(36_000) tar = Tempfile.new('tar') File.open(tar, 'w') do |file| - docker_container.copy('/ruby-tinderbox/ci-logs') do |chunk| + ci_container.copy('/ruby-tinderbox/ci-logs') do |chunk| file.write(chunk) end end @@ -45,7 +49,7 @@ def run_ci(docker_image, num_of_packages) tar.close tar.unlink - docker_container.delete + ci_container.delete end end |