Skip to content
This repository
Browse code

Added a .travis.yml config and travis specific ci script.

Don't install ruby-debug if running the test suite on Travis,
linecache19 is the main offender, very very slow.

And do not install pg if Travis is bundling the gems, pg will be setup
on Travis soon.

Conflicts:

	Gemfile
  • Loading branch information...
commit 047b979eae3e3c11d57b736e6952e11e5be1b273 1 parent 9ade587
Josh Kalderimis authored July 15, 2011 fxn committed July 18, 2011
12  .travis.yml
... ...
@@ -0,0 +1,12 @@
  1
+script: 'ci/travis.rb'
  2
+notifications:
  3
+  disabled: true
  4
+rvm:
  5
+  - 1.8.7
  6
+  - 1.9.2
  7
+env:
  8
+  - "GEM=railties"
  9
+  - "GEM=ap,am,amo,ares,as"
  10
+  - "GEM=ar:mysql"
  11
+  - "GEM=ar:mysql2"
  12
+  - "GEM=ar:sqlite3"
6  Gemfile
@@ -21,13 +21,13 @@ gem "memcache-client", ">= 1.8.5"
21 21
 
22 22
 platforms :mri_18 do
23 23
   gem "system_timer"
24  
-  gem "ruby-debug", ">= 0.10.3"
  24
+  gem "ruby-debug", ">= 0.10.3" unless ENV['TRAVIS']
25 25
   gem 'ruby-prof'
26 26
 end
27 27
 
28 28
 platforms :mri_19 do
29 29
   # TODO: Remove the conditional when ruby-debug19 supports Ruby >= 1.9.3
30  
-  gem "ruby-debug19", :require => 'ruby-debug' if RUBY_VERSION < "1.9.3"
  30
+  gem "ruby-debug19", :require => 'ruby-debug' unless > "1.9.2" || ENV['TRAVIS']
31 31
 end
32 32
 
33 33
 platforms :ruby do
@@ -39,7 +39,7 @@ platforms :ruby do
39 39
   gem "sqlite3", "~> 1.3.3"
40 40
 
41 41
   group :db do
42  
-    gem "pg", ">= 0.9.0"
  42
+    gem "pg", ">= 0.9.0" unless ENV['TRAVIS'] # once pg is on travis this can be removed
43 43
     gem "mysql", ">= 2.8.1"
44 44
     gem "mysql2", "~> 0.2.11"
45 45
   end
142  ci/travis.rb
... ...
@@ -0,0 +1,142 @@
  1
+#!/usr/bin/env ruby
  2
+require 'fileutils'
  3
+include FileUtils
  4
+
  5
+commands = [
  6
+  'mysql -e "create database activerecord_unittest;"',
  7
+  'mysql -e "create database activerecord_unittest2;"',
  8
+  'psql  -c "create database activerecord_unittest;" -U postgres',
  9
+  'psql  -c "create database activerecord_unittest2;" -U postgres'
  10
+]
  11
+
  12
+commands.each do |command|
  13
+  system("#{command} > /dev/null 2>&1")
  14
+end
  15
+
  16
+class Build
  17
+  MAP = {
  18
+    'railties' => 'railties',
  19
+    'ap'   => 'actionpack',
  20
+    'am'   => 'actionmailer',
  21
+    'amo'  => 'activemodel',
  22
+    'ares' => 'activeresource',
  23
+    'as'   => 'activesupport',
  24
+    'ar'   => 'activerecord'
  25
+  }
  26
+
  27
+  attr_reader :component, :options
  28
+
  29
+  def initialize(component, options = {})
  30
+    @component = component
  31
+    @options = options
  32
+  end
  33
+
  34
+  def run!(options = {})
  35
+    self.options.update(options)
  36
+    Dir.chdir(dir) do
  37
+      announce(heading)
  38
+      ENV['IM'] = identity_map?.inspect
  39
+      rake(*tasks)
  40
+    end
  41
+  end
  42
+
  43
+  def announce(heading)
  44
+    puts "\n\e[1;33m[Travis CI] #{heading}\e[m\n"
  45
+  end
  46
+
  47
+  def heading
  48
+    heading = [gem]
  49
+    heading << "with #{adapter} IM #{identity_map? ? 'enabled' : 'disabled'}" if activerecord?
  50
+    heading << "in isolation" if isolated?
  51
+    heading.join(' ')
  52
+  end
  53
+
  54
+  def tasks
  55
+    if activerecord?
  56
+      ['mysql:rebuild_databases', "#{adapter}:#{'isolated_' if isolated?}test"]
  57
+    else
  58
+      ["test#{':isolated' if isolated?}"]
  59
+    end
  60
+  end
  61
+
  62
+  def key
  63
+    key = [gem]
  64
+    key << adapter if activerecord?
  65
+    key << 'IM' if identity_map?
  66
+    key << 'isolated' if isolated?
  67
+    key.join(':')
  68
+  end
  69
+
  70
+  def activerecord?
  71
+    gem == 'activerecord'
  72
+  end
  73
+
  74
+  def identity_map?
  75
+    options[:identity_map]
  76
+  end
  77
+
  78
+  def isolated?
  79
+    options[:isolated]
  80
+  end
  81
+
  82
+  def gem
  83
+    MAP[component.split(':').first]
  84
+  end
  85
+  alias :dir :gem
  86
+
  87
+  def adapter
  88
+    component.split(':').last
  89
+  end
  90
+
  91
+  def rake(*tasks)
  92
+    tasks.each do |task|
  93
+      cmd = "bundle exec rake #{task}"
  94
+      puts "Running command: #{cmd}"
  95
+      return false unless system(cmd)
  96
+    end
  97
+    true
  98
+  end
  99
+end
  100
+
  101
+results = {}
  102
+
  103
+ENV['GEM'].split(',').each do |gem|
  104
+  [false, true].each do |isolated|
  105
+    next if gem == 'railties' && isolated
  106
+
  107
+    build = Build.new(gem, :isolated => isolated)
  108
+    results[build.key] = build.run!
  109
+
  110
+    if build.activerecord?
  111
+      build.options[:identity_map] = true
  112
+      results[build.key] = build.run!
  113
+    end
  114
+  end
  115
+end
  116
+
  117
+# puts
  118
+# puts "Build environment:"
  119
+# puts "  #{`cat /etc/issue`}"
  120
+# puts "  #{`uname -a`}"
  121
+# puts "  #{`ruby -v`}"
  122
+# puts "  #{`mysql --version`}"
  123
+# # puts "  #{`pg_config --version`}"
  124
+# puts "  SQLite3: #{`sqlite3 -version`}"
  125
+# `gem env`.each_line {|line| print "   #{line}"}
  126
+# puts "   Bundled gems:"
  127
+# `bundle show`.each_line {|line| print "     #{line}"}
  128
+# puts "   Local gems:"
  129
+# `gem list`.each_line {|line| print "     #{line}"}
  130
+
  131
+failures = results.select { |key, value| value == false }
  132
+
  133
+if failures.empty?
  134
+  puts
  135
+  puts "Rails build finished sucessfully"
  136
+  exit(true)
  137
+else
  138
+  puts
  139
+  puts "Rails build FAILED"
  140
+  puts "Failed components: #{failures.map { |component| component.first }.join(', ')}"
  141
+  exit(false)
  142
+end

0 notes on commit 047b979

Aaron Patterson

Common bros. Was this patch reviewed or tested?

Xavier Noria
Owner

My fault, that was a manual merge and I asked for review on Campfire, but did not test it.

Aaron Patterson

I'm giving you a hard time bro. :heart:

Please sign in to comment.
Something went wrong with that request. Please try again.