gitlab-ci
1.3 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
#!/usr/bin/env ruby
# These just forward the signals to the whole process group and
# then immediately exit.
pgid = Process.getpgid Process.pid
Signal.trap(:TERM) { Process.kill(:TERM, -pgid); exit }
Signal.trap(:INT) { Process.kill(:INT, -pgid); exit }
def run command, options = {}
command = "#{command} 2>&1 > /dev/null" if options[:output] == false
#command = "time #{command}" unless options[:runtime] == false
puts "== #{command}"
system command
end
@id = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
@db = "gitlab-ci-#{@id}"
def config
require 'yaml'
db_config = {
'adapter' => 'postgresql', 'encoding' => 'unicode',
'database' => @db, 'username' => ENV['USER'],
}
File.write 'config/database.yml', YAML.dump('test' => db_config, 'development' => db_config)
end
def prepare
run("createdb #{@db}") and
run('mkdir -p tmp/pids log') and
run('bundle check || bundle install') and
run('rake db:schema:load', output: false) and
run('script/noosfero-plugins disableall') and
run('rake db:migrate')
end
def test
%w[
test:units
test:functionals
test:integration
cucumber
test:noosfero_plugins
].each do |task|
run "rake #{task}"
end
end
def cleanup
run "dropdb #{@db}"
end
ret = config and prepare and test
cleanup
exit (if ret == true then 0 else 1 end)