aboutsummaryrefslogtreecommitdiff
blob: 27525e02aafd6d3c821d7c6dde938d92901eb58b (plain)
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
require_relative 'app'

task default: 'test'

desc 'Run the test suite'
task :test do
	Dir.glob('./test/test_*.rb') { |f| require f }
end

namespace :db do
	DB.loggers << Logger.new($stdout)

	task :migrate do
		Sequel.extension :migration
		Sequel::Migrator.run(DB, 'db/migrations')
	end

	desc 'Update the packages database with new versions and targets'
	task :update_packages do
		update_packages
	end

	desc 'Update the build database with logfiles from ci-logs/'
	task :update_ci do
		update_ci
	end

	desc 'Clear the build database'
	task :clear_ci do
		clear_ci
	end

	desc 'Update the repoman database with logfiles from repo-logs/'
	task :update_repoman do
		update_repoman
	end

	desc 'Clear the repoman database'
	task :clear_repoman do
		clear_repoman
	end
end

namespace :docker do
	num_of_packages = ENV['NUM_OF_PACKAGES']
	begin
		num_of_packages = Integer(num_of_packages)
	rescue
	end

	desc 'Build a docker image to use with subsequent tasks'
	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__)))
		@ci_image = Docker::Image.build_from_dir(docker_path)
	end

	desc 'Remove a previously built docker image'
	task :teardown do
		@ci_image.delete
		@volume_container.delete(v: 1)
		@volume_image.delete
	end

	desc 'Build test packages ( NUM_OF_PACKAGES={5,all,untested} )'
	task :run_build do
		run_ci(@volume_container, @ci_image, num_of_packages)
	end

	desc 'QA test packages ( NUM_OF_PACKAGES={5,all} )'
	task :run_repoman do
		run_repoman(@ci_image, num_of_packages)
	end
end