Skip to content

Commit

Permalink
Basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bugno committed Nov 24, 2010
1 parent 557a1eb commit f73f8e8
Show file tree
Hide file tree
Showing 25 changed files with 395 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ test/performance
capybara*.html

config/*.yml
builds
13 changes: 12 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
source 'http://rubygems.org'

gem 'rails', '3.0.3'
gem "rails", "3.0.3"
gem "pg"
gem "haml"
gem "delayed_job"

group :development, :test do
gem "capybara"
gem "launchy"
gem "faker"
gem "ruby-debug"
gem "machinist"
gem "nokogiri"
gem "mocha"
gem "database_cleaner"
end
129 changes: 129 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.4)
builder (2.1.2)
capybara (0.4.0)
celerity (>= 0.7.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.2)
celerity (0.8.4)
childprocess (0.1.4)
ffi (~> 0.6.3)
columnize (0.3.2)
configuration (1.2.0)
culerity (0.2.12)
daemons (1.1.0)
database_cleaner (0.6.0)
delayed_job (2.1.1)
activesupport (~> 3.0)
daemons
erubis (2.6.6)
abstract (>= 1.0.0)
faker (0.3.1)
ffi (0.6.3)
rake (>= 0.8.7)
haml (3.0.24)
i18n (0.4.2)
json_pure (1.4.6)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
machinist (1.0.6)
mail (2.2.10)
activesupport (>= 2.3.6)
i18n (~> 0.4.1)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mocha (0.9.9)
rake
nokogiri (1.4.4)
pg (0.9.0)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
rubyzip (0.9.4)
selenium-webdriver (0.1.0)
childprocess (= 0.1.4)
ffi (~> 0.6.3)
json_pure
rubyzip
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
xpath (0.1.2)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara
database_cleaner
delayed_job
faker
haml
launchy
machinist
mocha
nokogiri
pg
rails (= 3.0.3)
ruby-debug
22 changes: 22 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class ProjectsController < ApplicationController
def index
@projects = Project.order("created_at DESC")
end

def show
@project = Project.find(params[:id])
end

def new
@project = Project.new
end

def create
@project = Project.new(params[:project])
if @project.save
redirect_to project_path(@project)
else
render :new
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ProjectsHelper
end
35 changes: 35 additions & 0 deletions app/models/build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Build < ActiveRecord::Base
belongs_to :project

# Delayed::Job interface
def perform
# FileUtils.mkdir_p(File.join("builds", project_dir))
project_dir = project.build_dir
# FileUtils.mkdir_p(File.join("builds", project_dir))
build_dir = File.join(project_dir, Time.now.strftime("%Y%m%d%H%M") + "_" + commit)
command = "git clone #{project.vcs_source} \"#{build_dir}\""
`#{command}`
self.stdout = `cd #{build_dir} && rake 2>&1 | tee rake.log`
Rails.logger.debug("*" * 5000)
Rails.logger.debug(self.stdout.inspect)
Rails.logger.debug(self.save!)
Rails.logger.debug("*" * 5000)
return false
end

def after(job)
Rails.logger.debug("Job after hook")
Rails.logger.debug(job.inspect)
end

def success(job)
Rails.logger.debug("Job success hook")
Rails.logger.debug(job.inspect)
end

def error(job, exception)
Rails.logger.debug("Job error hook")
Rails.logger.debug(job.inspect)
Rails.logger.debug(exception.inspect)
end
end
13 changes: 13 additions & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Project < ActiveRecord::Base
has_many :builds

def build!
commit = `git log --format=oneline --max-count=1`.split(" ")[0]
build = self.builds.create!(:commit => commit)
Delayed::Job.enqueue(build)
end

def build_dir
File.join("builds", name.downcase.gsub(/[^A-Za-z0-9]/, "_"))
end
end
14 changes: 0 additions & 14 deletions app/views/layouts/application.html.erb

This file was deleted.

14 changes: 14 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!!!
%html
%head
%title BigTuna Continuous Integration
= stylesheet_link_tag "master.css"
= csrf_meta_tag
%meta{:"http-equiv" => "Content-Type", :content => "text/html;charset=UTF-8"}
%meta{:name => "keywords", :content => "keywords"}
%meta{:name => "description", :content => "description"}
%body
%header
%h1 BigTuna
#content
= yield
11 changes: 11 additions & 0 deletions app/views/projects/_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%div
= f.label(:name)
= f.text_field(:name)
%div
= f.label(:vcs_type)
= f.text_field(:vcs_type)
%div
= f.label(:vcs_source)
= f.text_field(:vcs_source)
%div
= f.submit(f.object.new_record? ? "Create" : "Update")
4 changes: 4 additions & 0 deletions app/views/projects/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= link_to("Add project", new_project_path)
%ol
- @projects.each do |project|
%li= link_to(project.name, project_path(project))
2 changes: 2 additions & 0 deletions app/views/projects/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
= form_for(@project, :url => projects_path) do |f|
= render :partial => "form", :locals => {:f => f}
3 changes: 3 additions & 0 deletions app/views/projects/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%h2= @project.name
%span= @project.vcs_type
%span= @project.vcs_source
Empty file added builds/.gitkeep
Empty file.
26 changes: 26 additions & 0 deletions config/database.yml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
development:
adapter: postgresql
encoding: utf8
database: big_tuna_development
pool: 5
username: msq
password:
template: template0

test:
adapter: postgresql
encoding: utf8
database: big_tuna_test
pool: 5
username: msq
password:
template: template0

production:
adapter: postgresql
encoding: utf8
database: big_tuna_production
pool: 5
username: msq
password:
template: template0
1 change: 1 addition & 0 deletions config/initializers/delayed_job_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Delayed::Worker.max_attempts = 1
58 changes: 2 additions & 56 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
BigTuna::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.

# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action

# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)

# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products

# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end

# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end

# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end

# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end

# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => "welcome#index"

# See how all your routes lay out with "rake routes"

# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
resources :projects
root :to => "projects#index"
end
14 changes: 14 additions & 0 deletions db/migrate/20101124105347_create_projects.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreateProjects < ActiveRecord::Migration
def self.up
create_table :projects do |t|
t.string :name, :null => false
t.string :vcs_type, :null => false
t.string :vcs_source, :null => false
t.timestamps
end
end

def self.down
drop_table :projects
end
end
Loading

0 comments on commit f73f8e8

Please sign in to comment.