Commit bf4da137e71360267cf41c3cf268a210580ef508
1 parent
b8154153
Exists in
master
and in
27 other branches
gitlab-ci script
Showing
1 changed file
with
56 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,56 @@ |
1 | +#!/usr/bin/env ruby | |
2 | + | |
3 | +# These just forward the signals to the whole process group and | |
4 | +# then immediately exit. | |
5 | +pgid = Process.getpgid Process.pid | |
6 | +Signal.trap(:TERM) { Process.kill(:TERM, -pgid); exit } | |
7 | +Signal.trap(:INT) { Process.kill(:INT, -pgid); exit } | |
8 | + | |
9 | +def run command, options = {} | |
10 | + command = "#{command} 2>&1 > /dev/null" if options[:output] == false | |
11 | + #command = "time #{command}" unless options[:runtime] == false | |
12 | + puts "== #{command}" | |
13 | + system command | |
14 | +end | |
15 | + | |
16 | +@id = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join | |
17 | +@db = "gitlab-ci-#{@id}" | |
18 | + | |
19 | +def config | |
20 | + require 'yaml' | |
21 | + db_config = { | |
22 | + 'adapter' => 'postgresql', 'encoding' => 'unicode', | |
23 | + 'database' => @db, 'username' => ENV['USER'], | |
24 | + } | |
25 | + File.write 'config/database.yml', YAML.dump('test' => db_config, 'development' => db_config) | |
26 | +end | |
27 | + | |
28 | +def prepare | |
29 | + run("createdb #{@db}") and | |
30 | + run('mkdir -p tmp/pids log') and | |
31 | + run('bundle check || bundle install') and | |
32 | + run('rake db:schema:load', output: false) and | |
33 | + run('script/noosfero-plugins disableall') and | |
34 | + run('rake db:migrate') | |
35 | +end | |
36 | + | |
37 | +def test | |
38 | + %w[ | |
39 | + test:units | |
40 | + test:functionals | |
41 | + test:integration | |
42 | + cucumber | |
43 | + test:noosfero_plugins | |
44 | + ].each do |task| | |
45 | + run "rake #{task}" | |
46 | + end | |
47 | +end | |
48 | + | |
49 | +def cleanup | |
50 | + run "dropdb #{@db}" | |
51 | +end | |
52 | + | |
53 | +ret = config and prepare and test | |
54 | +cleanup | |
55 | + | |
56 | +exit (if ret == true then 0 else 1 end) | ... | ... |