Skip to content
This repository
Browse code

Include the CI configuration and setup instructions.

This should make it easy to set up your own copy of the CI environment, and easier for us to keep ours running.
  • Loading branch information...
commit 337b043c9373014b034b79c487f70594ebb6a910 1 parent 33ed19f
Chad Woolley authored August 24, 2008 NZKoz committed August 24, 2008
117  ci/ci_build.rb
... ...
@@ -0,0 +1,117 @@
  1
+#!/usr/bin/env ruby
  2
+require 'fileutils'
  3
+
  4
+include FileUtils
  5
+
  6
+puts "[CruiseControl] Rails build"
  7
+
  8
+build_results = {}
  9
+root_dir = File.expand_path(File.dirname(__FILE__) + "/..")
  10
+
  11
+# Requires gem home and path to be writeable and/or overridden to be ~/.gem,
  12
+# Will enable when RubyGems supports this properly (in a coming release)
  13
+# build_results[:geminstaller] = system 'geminstaller --exceptions'
  14
+
  15
+# for now, use the no-passwd sudoers approach (documented in ci_setup_notes.txt)
  16
+# A security hole, but there is nothing valuable on rails CI box anyway.
  17
+build_results[:geminstaller] = system 'sudo geminstaller --exceptions'
  18
+
  19
+cd "#{root_dir}/activesupport" do
  20
+  puts
  21
+  puts "[CruiseControl] Building ActiveSupport"
  22
+  puts
  23
+  build_results[:activesupport] = system 'rake'
  24
+end
  25
+
  26
+cd "#{root_dir}/activerecord" do
  27
+  puts
  28
+  puts "[CruiseControl] Building ActiveRecord with MySQL"
  29
+  puts
  30
+  build_results[:activerecord_mysql] = system 'rake test_mysql'
  31
+end
  32
+
  33
+# Postgres is disabled until tests are fixed
  34
+# cd "#{root_dir}/activerecord" do
  35
+#   puts
  36
+#   puts "[CruiseControl] Building ActiveRecord with PostgreSQL"
  37
+#   puts
  38
+#   build_results[:activerecord_postgresql8] = system 'rake test_postgresql'
  39
+# end
  40
+
  41
+# Sqlite2 is disabled until tests are fixed
  42
+# cd "#{root_dir}/activerecord" do
  43
+#  puts
  44
+#  puts "[CruiseControl] Building ActiveRecord with SQLite 2"
  45
+#  puts
  46
+#  build_results[:activerecord_sqlite] = system 'rake test_sqlite'
  47
+# end
  48
+
  49
+cd "#{root_dir}/activerecord" do
  50
+  puts
  51
+  puts "[CruiseControl] Building ActiveRecord with SQLite 3"
  52
+  puts
  53
+  build_results[:activerecord_sqlite3] = system 'rake test_sqlite3'
  54
+end
  55
+
  56
+cd "#{root_dir}/activemodel" do
  57
+  puts
  58
+  puts "[CruiseControl] Building ActiveModel"
  59
+  puts
  60
+  build_results[:activemodel] = system 'rake'
  61
+end
  62
+
  63
+cd "#{root_dir}/activeresource" do
  64
+  puts
  65
+  puts "[CruiseControl] Building ActiveResource"
  66
+  puts
  67
+  build_results[:activeresource] = system 'rake'
  68
+end
  69
+
  70
+cd "#{root_dir}/actionpack" do
  71
+  puts
  72
+  puts "[CruiseControl] Building ActionPack"
  73
+  puts
  74
+  build_results[:actionpack] = system 'rake'
  75
+end
  76
+
  77
+cd "#{root_dir}/actionmailer" do
  78
+  puts
  79
+  puts "[CruiseControl] Building ActionMailer"
  80
+  puts
  81
+  build_results[:actionmailer] = system 'rake'
  82
+end
  83
+
  84
+cd "#{root_dir}/railties" do
  85
+  puts
  86
+  puts "[CruiseControl] Building RailTies"
  87
+  puts
  88
+  build_results[:railties] = system 'rake'
  89
+end
  90
+
  91
+
  92
+puts
  93
+puts "[CruiseControl] Build environment:"
  94
+puts "[CruiseControl]   #{`cat /etc/issue`}"
  95
+puts "[CruiseControl]   #{`uname -a`}"
  96
+puts "[CruiseControl]   #{`ruby -v`}"
  97
+puts "[CruiseControl]   #{`mysql --version`}"
  98
+puts "[CruiseControl]   #{`pg_config --version`}"
  99
+puts "[CruiseControl]   SQLite2: #{`sqlite -version`}"
  100
+puts "[CruiseControl]   SQLite3: #{`sqlite3 -version`}"
  101
+`gem env`.each {|line| print "[CruiseControl]   #{line}"}
  102
+puts "[CruiseControl]   Local gems:"
  103
+`gem list`.each {|line| print "[CruiseControl]     #{line}"}
  104
+
  105
+failures = build_results.select { |key, value| value == false }
  106
+
  107
+if failures.empty?
  108
+  puts
  109
+  puts "[CruiseControl] Rails build finished sucessfully"
  110
+  exit(0)
  111
+else
  112
+  puts
  113
+  puts "[CruiseControl] Rails build FAILED"
  114
+  puts "[CruiseControl] Failed components: #{failures.map { |component| component.first }.join(', ')}"
  115
+  exit(-1)
  116
+end
  117
+
120  ci/ci_setup_notes.txt
... ...
@@ -0,0 +1,120 @@
  1
+# Rails Continuous Integration Server Setup Notes
  2
+# This procedure was used to set up http://ci.rubyonrails.org on Ubuntu 8.04
  3
+# It can be used as a guideline for setting up your own CI server against your local rails branches
  4
+
  5
+* Set up ci user:
  6
+# log in as root
  7
+$ adduser ci
  8
+enter user info and password
  9
+$ visudo
  10
+# give ci user same sudo rights as root
  11
+
  12
+* Disable root login:
  13
+# log in as ci
  14
+$ sudo vi /etc/shadow
  15
+# overwrite and disable encrypted root password to disable root login:
  16
+root:*:14001:0:99999:7:::
  17
+
  18
+* Change Hostname:
  19
+$ sudo vi /etc/hostname
  20
+change to 'ci'
  21
+$ sudo vi /etc/hosts
  22
+replace old hostname with 'ci'
  23
+# reboot to use new hostname (and test reboot)
  24
+$ sudo shutdown -r now
  25
+
  26
+* Update aptitude:
  27
+$ sudo aptitude update
  28
+
  29
+* Use cinabox to perform rest of ruby/ccrb setup: 
  30
+* http://github.com/thewoolleyman/cinabox/tree/master/README.txt
  31
+
  32
+# This is not yet properly supported by RubyGems...
  33
+# * Configure RubyGems to not require root access for gem installation
  34
+# $ vi ~/.profile
  35
+# # add this line at bottom:
  36
+# PATH="$HOME/.gem/ruby/1.8/bin:$PATH"
  37
+# $ sudo vi /etc/init.d/cruise
  38
+# # edit the start_cruise line to source CRUISE_USER/.profile:
  39
+#   start_cruise "cd #{CRUISE_HOME} && source /home/#{CRUISE_USER}/.profile && ./cruise start -d"
  40
+# $ vi ~/.gemrc
  41
+# # add these lines:
  42
+# ---
  43
+# gemhome: /home/ci/.gem/ruby/1.8
  44
+# gempath: 
  45
+# - /home/ci/.gem/ruby/1.8
  46
+
  47
+* If you did not configure no-root-gem installation via ~/.gemrc as shown above, then allow no-password sudo for gem installation:
  48
+$ sudo visudo
  49
+# add this line to bottom:
  50
+ci      ALL=NOPASSWD: /usr/local/bin/geminstaller, /usr/local/bin/ruby, /usr/local/bin/gem
  51
+
  52
+* Start ccrb via init script and check for default homepage at port 3333
  53
+
  54
+* Install/setup nginx:
  55
+$ sudo aptitude install nginx
  56
+$ sudo vi /etc/nginx/sites-available/default
  57
+# comment two lines and add one to proxy to ccrb:
  58
+#               root   /var/www/nginx-default;
  59
+#               index  index.html index.htm;
  60
+                proxy_pass      http://127.0.0.1:3333;
  61
+$ sudo /etc/init.d/nginx start
  62
+
  63
+* Add project to cruise (It will still fail until everything is set up):
  64
+$ cd ~/ccrb
  65
+$ ./cruise add rails -s git -r git://github.com/rails/rails.git  # or the URI of your branch
  66
+
  67
+* Copy and configure cruise site config file:
  68
+$ cp ~/.cruise/projects/rails/work/ci/site_config.rb ~/.cruise/site_config.rb
  69
+# Edit ~/.cruise/site_config.rb as desired, for example:
  70
+ActionMailer::Base.smtp_settings = {
  71
+  :address =>        "localhost",
  72
+  :domain =>         "ci.yourdomain.com",
  73
+}
  74
+Configuration.dashboard_refresh_interval = 60.seconds
  75
+Configuration.dashboard_url = 'http://ci.yourdomain.com/'
  76
+Configuration.serialize_builds = true
  77
+Configuration.serialized_build_timeout = 1.hours
  78
+BuildReaper.number_of_builds_to_keep = 100
  79
+  
  80
+* Copy and configure cruise project config file
  81
+$ cp ~/.cruise/projects/rails/work/ci/cruise_config.rb ~/.cruise/projects/rails
  82
+$ vi ~/.cruise/projects/rails/cruise_config.rb:
  83
+# Edit ~/.cruise/projects/rails/cruise_config.rb as desired, for example:
  84
+Project.configure do |project|
  85
+ project.build_command = 'ruby ci/ci_build.rb'
  86
+ project.email_notifier.emails = ['recipient@yourdomain.com']
  87
+ project.email_notifier.from = 'sender@yourdomain.com'
  88
+end
  89
+
  90
+* Set up mysql
  91
+$ sudo aptitude install mysql-server-5.0 libmysqlclient-dev
  92
+# no password for mysql root user
  93
+
  94
+* setup sqlite
  95
+$ sudo aptitude install sqlite sqlite3 libsqlite-dev libsqlite3-dev
  96
+# Note: there's some installation bugs with sqlite3-ruby 1.2.2 gem file permissions:
  97
+#   http://www.icoretech.org/2008/07/06/no-such-file-to-load-sqlite3-database
  98
+#   cd /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2 && sudo find . -perm 0662 -exec chmod 664 {} \;
  99
+
  100
+* setup postgres
  101
+$ sudo aptitude install postgresql postgresql-server-dev-8.3
  102
+$ sudo su - postgres -c 'createuser -s ci'
  103
+
  104
+* Install and run GemInstaller to get all dependency gems
  105
+$ sudo gem install geminstaller
  106
+$ cd ~/.cruise/projects/rails/work
  107
+$ sudo geminstaller --config=ci/geminstaller.yml # turn up debugging with these options: --geminstaller-output=all --rubygems-output=all
  108
+
  109
+* Create ActiveRecord test databases for mysql
  110
+$ mysql -uroot -e 'grant all on *.* to rails@localhost;'
  111
+$ mysql -urails -e 'create database activerecord_unittest;'
  112
+$ mysql -urails -e 'create database activerecord_unittest2;'
  113
+
  114
+* Create ActiveRecord test databases for postgres
  115
+# cd to rails activerecord dir
  116
+$ rake postgresql:build_databases
  117
+
  118
+* Reboot and make sure everything is working
  119
+$ sudo shutdown -r now
  120
+$ http://ci.yourdomain.com
5  ci/cruise_config.rb
... ...
@@ -0,0 +1,5 @@
  1
+Project.configure do |project|
  2
+ project.build_command = 'ruby ci/ci_build.rb'
  3
+ project.email_notifier.emails = ['thewoolleyman@gmail.com','michael@koziarski.com']
  4
+ project.email_notifier.from = 'thewoolleyman+railsci@gmail.com'
  5
+end
17  ci/geminstaller.yml
... ...
@@ -0,0 +1,17 @@
  1
+---
  2
+gems:
  3
+- name: geminstaller
  4
+  version: >= 0.4.3
  5
+- name: mocha
  6
+  version: >= 0.9.0
  7
+- name: mysql
  8
+  #version: >= 2.7
  9
+  version: = 2.7
  10
+- name: postgres
  11
+  version: >= 0.7.9.2008.01.28
  12
+- name: rake
  13
+  version: >= 0.8.1
  14
+- name: sqlite-ruby
  15
+  version: >= 2.2.3
  16
+- name: sqlite3-ruby
  17
+  version: >= 1.2.2
13  ci/site.css
... ...
@@ -0,0 +1,13 @@
  1
+/* this is a copy of /home/ci/.cruise/site.css, please make any changes to it there */
  2
+
  3
+/* this is a copy of /home/ci/.cruise/site.css, please make any changes to it there */
  4
+
  5
+/* if you'd like to add custom styles to cruise, add them here */
  6
+/* the following will make successful builds green */
  7
+a.success, a.success:visited {
  8
+  color: #0A0;
  9
+}
  10
+
  11
+.build_success {
  12
+  background-image: url(/images/green_gradient.png);
  13
+}
72  ci/site_config.rb
... ...
@@ -0,0 +1,72 @@
  1
+# site_config.rb contains examples of various configuration options for the local installation
  2
+# of CruiseControl.rb.
  3
+
  4
+# YOU MUST RESTART YOUR CRUISE CONTROL SERVER FOR ANY CHANGES MADE HERE TO TAKE EFFECT!!!
  5
+
  6
+# EMAIL NOTIFICATION
  7
+# ------------------
  8
+
  9
+# CruiseControl.rb can notify you about build status via email. It uses ActionMailer component of Ruby on Rails 
  10
+# framework. Obviously, ActionMailer needs to know how to send out email messages. 
  11
+# If you have an SMTP server on your network, and it needs no authentication, write this in your site_config.rb:
  12
+# 
  13
+ActionMailer::Base.smtp_settings = {
  14
+  :address =>        "localhost",
  15
+  :domain =>         "ci.rubyonrails.org",
  16
+}
  17
+#
  18
+# If you have no SMTP server at hand, you can configure email notification to use GMail SMTP server, as follows
  19
+# (of course, you'll need to create a GMail account):
  20
+#
  21
+# ActionMailer::Base.smtp_settings = {
  22
+#   :address =>        "smtp.gmail.com",
  23
+#   :port =>           587,
  24
+#   :domain =>         "yourdomain.com",
  25
+#   :authentication => :plain,
  26
+#   :user_name =>      "yourgmailaccount",
  27
+#   :password =>       "yourgmailpassword"
  28
+# }
  29
+# 
  30
+# The same approach works for other SMTP servers thet require authentication. Note that GMail's SMTP server runs on a 
  31
+# non-standard port 587 (standard port for SMTP is 25).
  32
+#
  33
+# For further details about configuration of outgoing email, see Ruby On Rails documentation for ActionMailer::Base.
  34
+
  35
+# Other site-wide options are available through Configuration class:
  36
+
  37
+# Change how often CC.rb pings Subversion for new requests. Default is 10.seconds, which should be OK for a local
  38
+# SVN repository, but probably isn't very polite for a public repository, such as RubyForge. This can also be set for
  39
+# each project individually, through project.scheduler.polling_interval option:
  40
+# Configuration.default_polling_interval = 1.minute
  41
+
  42
+# How often the dashboard page refreshes itself. If you have more than 10-20 dashboards open,
  43
+# it is advisable to set it to something higher than the default 5 seconds:
  44
+Configuration.dashboard_refresh_interval = 60.seconds
  45
+
  46
+# Site-wide setting for the email "from" field. This can also be set on per-project basis,
  47
+# through project.email.notifier.from attribute
  48
+Configuration.email_from = 'thewoolleyman+railsci@gmail.com'
  49
+
  50
+# Root URL of the dashboard application. Setting this attribute allows various notifiers to include a link to the
  51
+# build page in the notification message.
  52
+Configuration.dashboard_url = 'http://ci.rubyonrails.org/'
  53
+
  54
+# If you don't want to allow triggering builds through dashboard Build Now button. Useful when you host CC.rb as a
  55
+# public web site (such as http://cruisecontrolrb.thoughtworks.com/projects - try clicking on Build Now button there
  56
+# and see what happens):
  57
+# Configuration.disable_build_now = true
  58
+
  59
+# If you want to only allow one project to build at a time, uncomment this line
  60
+# by default, cruise allows multiple projects to build at a time
  61
+Configuration.serialize_builds = true
  62
+
  63
+# Amount of time a project will wait to build before failing when build serialization is on
  64
+Configuration.serialized_build_timeout = 3.hours
  65
+
  66
+# To delete build when there are more than a certain number present, uncomment this line - it will make the dashboard 
  67
+# perform better
  68
+BuildReaper.number_of_builds_to_keep = 100
  69
+
  70
+# any files that you'd like to override in cruise, keep in ~/.cruise, and copy over when this file is loaded like this
  71
+site_css = CRUISE_DATA_ROOT + "/site.css"
  72
+FileUtils.cp site_css, RAILS_ROOT + "/public/stylesheets/site.css" if File.exists? site_css

0 notes on commit 337b043

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